Skip to content

Commit

Permalink
Fix #49
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinyChang committed Jun 11, 2017
1 parent 4c8e42b commit 795f439
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var TextTruncate = require('react-text-truncate'); // CommonJS or UMD
Please polyfill `requestAnimationFrame` before you called `<TextTruncated />`

## Changelog
* 0.10.2 Fix truncated wrong when font property changed
* 0.10.1 Fix unknown prop `element`
* 0.10.0 Allow pass `element` to specify root element type
* 0.9.3 Fix SSR window not found (removed raf polyfill)
Expand Down
3 changes: 3 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
}
_this.rafId = window.requestAnimationFrame(_this.update.bind(_this));
}, _this.update = function () {
var style = window.getComputedStyle(_this.scope);
var font = [style['font-weight'], style['font-style'], style['font-size'], style['font-family']].join(' ');
_this.canvas.font = font;
_this.forceUpdate();
}, _temp), _possibleConstructorReturn(_this, _ret);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-text-truncate",
"version": "0.10.1",
"version": "0.10.2",
"description": "Truncate text for React.js",
"main": "lib/index.js",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/TextTruncate.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export default class TextTruncate extends Component {
};

update = () => {
const style = window.getComputedStyle(this.scope);
const font = [
style['font-weight'],
style['font-style'],
style['font-size'],
style['font-family']
].join(' ');
this.canvas.font = font;
this.forceUpdate();
};

Expand Down

0 comments on commit 795f439

Please sign in to comment.