Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-fittext

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-fittext - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

client/scripts/index.js

@@ -5,3 +5,3 @@ 'use strict';

var React = require("react");
var ReactFitText = require('../../src/ReactFitText');
var ReactFitText = require('../../lib/ReactFitText');

@@ -8,0 +8,0 @@ var Body = React.createClass({

@@ -0,1 +1,10 @@

/*
* React FitText v0.0.3
* https://github.com/gianu/react-fittext
*
* A port of the jQuery plugin: http://github.com/davatron5000/FitText.js
*
* Released under the MIT license
* http://gianu.mit-license.org
*/
'use strict';

@@ -10,3 +19,6 @@

propTypes: {
compressor: ReactPropTypes.number
children: ReactPropTypes.element.isRequired,
compressor: ReactPropTypes.number,
minFontSize: ReactPropTypes.number,
maxFontSize: ReactPropTypes.number
},

@@ -22,32 +34,23 @@

getInitialState: function() {
return {
width: 920
}
},
componentDidMount: function() {
console.log(' --- COMPRESSOR ---> ' + this.props.compressor);
// var width = this.refs.fitTextContainer.getDOMNode().offsetWidth;
var width = this.getDOMNode().offsetWidth
this.setState({width: width});
// document.body.onresize = this._onBodyResize;
window.addEventListener("resize", this._onBodyResize);
this._onBodyResize();
},
componentWillUnmount: function() {
window.removeEventListener("resize", this._onBodyResize);
},
_onBodyResize: function() {
// var width = this.refs.fitTextContainer.getDOMNode().offsetWidth;
var width = this.getDOMNode().offsetWidth;
this.setState({width: width});
var element = this.getDOMNode();
var width = element.offsetWidth;
element.style.fontSize = Math.max(
Math.min((width / (this.props.compressor*10)),
parseFloat(this.props.maxFontSize)),
parseFloat(this.props.minFontSize)) + 'px';
},
render: function() {
var divStyle = {
'font-size': Math.max(Math.min((this.state.width / (this.props.compressor*10)), parseFloat(this.props.maxFontSize)), parseFloat(this.props.minFontSize))
};
return React.createElement("div", {ref: "fitTextContainer", style: divStyle},
this.props.children
);
return this.props.children;
}
});
{
"name": "react-fittext",
"version": "0.0.3",
"version": "0.0.4",
"description": "A React plugin to fit the text in the screen",

@@ -5,0 +5,0 @@ "main": "lib/ReactFitText.js",

@@ -31,3 +31,3 @@ # React Fit text

* __compressor__: you can tweak this variable to increase / decrase the font-size. Default is 1.
* __compressor__: you can tweak this variable to increase / decrease the font-size. Default is 1.
* __minFontSize__: the minimun font size (in px) this component should use.

@@ -38,4 +38,8 @@ * __maxFontSize__: the maximum font size (in px) this component should use.

If you found any issue with this componente, please [report it](https://github.com/gianu/react-fittext/issues).
If you found any issue with this component, please [report it](https://github.com/gianu/react-fittext/issues).
If you want to improve the code, feel free to create a PR!
## Thanks
* [KyleAMathews](https://github.com/KyleAMathews)
* [revolunet](https://github.com/revolunet)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc