Skip to content

Commit 5333815

Browse files
committed
fix update style
1 parent 3f73080 commit 5333815

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-tween-one",
3-
"version": "2.3.2",
3+
"version": "2.3.3",
44
"description": "tween-one anim component for react",
55
"keywords": [
66
"react",

src/Tween.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,16 +450,16 @@ p.resetDefaultStyle = function () {
450450
});
451451
};
452452

453-
p.reStart = function (style) {
453+
p.reStart = function (style, preStyle, isTween) {
454454
this.start = {};
455-
this.target.style.cssText = getDefaultStyle(this.target.style.cssText,
456-
this.startDefaultData.style,
457-
this.data);
455+
this.tween = {};
458456
Object.keys(style || {}).forEach(key => {
459-
this.target.style[key] = stylesToCss(key, style[key]);
457+
if (isTween || !preStyle || style[key] !== preStyle[key]) {
458+
this.target.style[key] = stylesToCss(key, style[key]);
459+
}
460460
});
461461
this.setAttrIsStyle();
462-
this.resetDefaultStyle();
462+
this.computedStyle = null;
463463
};
464464

465465
p.onChange = noop;

src/TweenOne.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ class TweenOne extends Component {
117117
if (!styleEqual) {
118118
// 在动画时更改了 style, 作为更改开始数值。
119119
if (this.tween) {
120-
this.tween.reStart(nextProps.style);
120+
this.tween.reStart(nextProps.style, this.props.style,
121+
this.tween.progressTime < this.tween.totalTime);
121122
if (this.paused) {
122123
this.raf();
123124
}

0 commit comments

Comments
 (0)