Skip to content

Commit 6821fcf

Browse files
author
zhaokai
committed
解决多个动画对象同时作用产生的问题
1 parent 13e55e0 commit 6821fcf

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

src/service/PlotBase/Animation/AnimationTypes/PlotBaseAnimation.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: zk
44
* @Date: 2022-03-23 10:02:49
55
* @LastEditors: zk
6-
* @LastEditTime: 2022-06-15 20:11:18
6+
* @LastEditTime: 2022-06-16 17:38:39
77
*/
88
import { AnimationUtil } from '../utils/AnimationUtil';
99
import { easingFunc } from '../utils/Easing';
@@ -159,6 +159,7 @@ export default class PlotBaseAnimation {
159159
* @return {*}
160160
*/
161161
restore() {
162+
this.updateGeometry()
162163
this.reset();
163164
}
164165

@@ -275,11 +276,14 @@ export default class PlotBaseAnimation {
275276
}
276277
return false;
277278
}
279+
resetGeometryStatus(){
280+
this.render(0.001)
281+
}
278282
updateGeometry() {
279283
if (this._updateGeometry) {
280284
this._updateGeometry = false;
281285
this.update();
282-
this.render(0.00001);
286+
// this.render(0.00001);
283287
}
284288
}
285289
}

src/service/PlotBase/Animation/AnimationTypes/PlotExtendAnimation/PlotAttributeAnimation.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: zk
44
* @Date: 2022-03-23 10:02:49
55
* @LastEditors: zk
6-
* @LastEditTime: 2022-06-16 11:45:57
6+
* @LastEditTime: 2022-06-16 15:46:02
77
*/
88
import { AnimationUtil } from '../../utils/AnimationUtil';
99
import { GradientColor } from '../../utils/GradientColor';
@@ -101,11 +101,11 @@ export default class PlotAttributeAnimation extends PlotBaseAnimation {
101101
this._plotObjects.forEach((s) => {
102102
this._attrsItems.forEach((item) => {
103103
const t = item.getRateValue(rate);
104-
s.setValue(item.type, t, item.ids, false);
104+
s.setValue(item.type, t, item.ids, true);
105105
});
106106
});
107107
}
108108
}
109109
PlotAttributeAnimation.limitColorItems = ['compareLineColor', 'wallColor', 'wallGradColor', 'strokeStyle', 'fillGradColor', 'fillStyle'];
110110
PlotAttributeAnimation.limitNumberItems = ['compareLineWidth', 'dimModHeight', 'lineWidth'];
111-
PlotAttributeAnimation.cacheProperty = 'attrItem';
111+
PlotAttributeAnimation.cacheProperty = 'attrsItem';

src/service/PlotBase/Animation/AnimationTypes/PlotExtendAnimation/PlotGrowAnimation/PlotCoordsAnimation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: zk
44
* @Date: 2022-03-23 10:02:49
55
* @LastEditors: zk
6-
* @LastEditTime: 2022-06-16 14:36:33
6+
* @LastEditTime: 2022-06-16 17:21:09
77
*/
88
import Point from '../../../../../PlotUtilBase/Geometry/Point';
99
import PlotBaseAnimation from '../../PlotBaseAnimation';
@@ -34,10 +34,10 @@ export default class PlotCoordsAnimation extends PlotBaseAnimation {
3434
super.restore();
3535
this._plotObjects.forEach((s, i) => {
3636
this._setPnts(s, this._animationPolys[i]);
37+
s.isInitCoords = false;
3738
});
3839
}
3940
_setPnts(obj, positions) {
40-
4141
if (obj.positions) {
4242
obj.positions = positions;
4343
}

src/service/PlotBase/Animation/AnimationTypes/PlotExtendAnimation/PlotGrowAnimation/PlotGrowAnimation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: zk
44
* @Date: 2022-03-23 10:02:49
55
* @LastEditors: zk
6-
* @LastEditTime: 2022-06-16 11:37:25
6+
* @LastEditTime: 2022-06-16 17:20:50
77
*/
88
import Point from '../../../../../PlotUtilBase/Geometry/Point';
99
import Spline from '../../../../../PlotUtilBase/Geometry/Spline';

src/service/PlotBase/Animation/TimeLine/TimeLine.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: zk
44
* @Date: 2022-03-23 11:53:45
55
* @LastEditors: zk
6-
* @LastEditTime: 2022-06-16 10:42:15
6+
* @LastEditTime: 2022-06-16 17:38:44
77
*/
88

99
import { AnimationReg } from '../AnimationTypes';
@@ -24,6 +24,8 @@ export default class TimeLine {
2424
this.raf = null;
2525
// 是否重新刷新动画队列
2626
// this._refreshAnimationList = false;
27+
// 统一设置初始状态
28+
this._initGeometryStatus=false
2729
}
2830

2931
/**
@@ -87,8 +89,16 @@ export default class TimeLine {
8789
* @return {*}
8890
*/
8991
play() {
92+
// 重置当前时间
9093
this.resetTime();
94+
// 修改动画状态
9195
this.animationAction((t) => t.play())();
96+
// 动画对象默认从rate=0处开始
97+
if(this._initGeometryStatus){
98+
this._initGeometryStatus=false
99+
this.animationAction((t) => t.resetGeometryStatus())();
100+
}
101+
// 强制刷新
92102
this.handleRender();
93103
let activeInstances = this._animationArr.concat([]);
94104
const that = this;
@@ -309,6 +319,7 @@ export default class TimeLine {
309319
* @return {*}
310320
*/
311321
restore() {
322+
this._initGeometryStatus=true
312323
this.reversed(false);
313324
this.setSpeed(1);
314325
this.animationAction((t) => t.restore())();

src/service/PlotBase/Animation/limit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @Author: zk
55
* @Date: 2022-06-06 21:00:52
66
* @LastEditors: zk
7-
* @LastEditTime: 2022-06-08 11:32:50
7+
* @LastEditTime: 2022-06-16 15:42:45
88
*/
99

1010
/**

0 commit comments

Comments
 (0)