Skip to content

Commit 9d45ea7

Browse files
authored
Merge pull request #1954 from VisActor/fix/fix-bug-of-animation-change-state
fix: fix bug of animation change
2 parents 0420bff + ae380b6 commit 9d45ea7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/vrender-animate/src/executor/animate-executor.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { IGraphic, EasingType, IAnimate } from '@visactor/vrender-core';
1+
import { type IGraphic, type EasingType, type IAnimate, AnimateStatus } from '@visactor/vrender-core';
22
import type {
33
IAnimationConfig,
44
IAnimationTimeline,
@@ -746,10 +746,12 @@ export class AnimateExecutor implements IAnimateExecutor {
746746
/**
747747
* 停止所有由该执行器管理的动画
748748
*/
749-
stop(type?: 'start' | 'end' | Record<string, any>): void {
749+
stop(type?: 'start' | 'end' | Record<string, any>, callEnd: boolean = true): void {
750750
// animate.stop会从数组里删除,所以需要while循环,不能forEach
751751
while (this._animates.length > 0) {
752752
const animate = this._animates.pop();
753+
// 不执行回调时 标记动画为结束状态
754+
callEnd === false && (animate.status = AnimateStatus.END);
753755
animate?.stop(type);
754756
}
755757

@@ -760,7 +762,7 @@ export class AnimateExecutor implements IAnimateExecutor {
760762
// 如果动画正在运行,触发结束回调
761763
if (this._started) {
762764
this._started = false;
763-
this.onEnd();
765+
callEnd && this.onEnd();
764766
}
765767
}
766768
}

packages/vrender-animate/src/state/animation-state.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ export class AnimationStateManager {
122122
}
123123

124124
// 停止动画
125+
// 停止的动画应该不触发回调
125126
shouldStopState.forEach(state => {
126-
state.executor.stop();
127+
state.executor.stop(null, false);
127128
});
128129

129130
// 立即应用动画,串行的应用
@@ -225,8 +226,9 @@ export class AnimationStateManager {
225226

226227
clearState(): void {
227228
// 清空状态
229+
// 清空状态时,不触发回调
228230
this.stateList?.forEach(state => {
229-
state.executor.stop();
231+
state.executor.stop(null, false);
230232
});
231233
this.stateList = null;
232234
}

0 commit comments

Comments
 (0)