Skip to content

Commit 5983492

Browse files
committed
Bump to 0.9.1
1 parent 3bc5bf0 commit 5983492

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var TextTruncate = require('react-text-truncate'); // CommonJS or UMD
3838

3939

4040
## Changelog
41+
* 0.9.1 Fix async this.forceUpdate() issue
4142
* 0.9.0 Fix infinity loop bug, upgrade react to 15.5.4 and support yarn
4243
* 0.8.3 IE 11 compatibility
4344
* 0.8.2 Fix wrong truncating when a container has long words without spaces

lib/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
8888
}
8989

90+
var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
91+
var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;
92+
9093
var TextTruncate = function (_Component) {
9194
_inherits(TextTruncate, _Component);
9295

@@ -102,7 +105,10 @@
102105
}
103106

104107
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = TextTruncate.__proto__ || Object.getPrototypeOf(TextTruncate)).call.apply(_ref, [this].concat(args))), _this), _this.onResize = function () {
105-
window.requestAnimationFrame(_this.update.bind(_this));
108+
if (_this.rafId) {
109+
cancelAnimationFrame(_this.rafId);
110+
}
111+
_this.rafId = requestAnimationFrame(_this.update.bind(_this));
106112
}, _this.update = function () {
107113
_this.forceUpdate();
108114
}, _temp), _possibleConstructorReturn(_this, _ret);
@@ -126,6 +132,9 @@
126132
key: 'componentWillUnmount',
127133
value: function componentWillUnmount() {
128134
window.removeEventListener('resize', this.onResize);
135+
if (this.rafId) {
136+
cancelAnimationFrame(this.rafId);
137+
}
129138
}
130139
}, {
131140
key: 'measureWidth',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-text-truncate",
3-
"version": "0.9.0",
3+
"version": "0.9.1",
44
"description": "Truncate text for React.js",
55
"main": "lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)