Skip to content

Commit 37fee30

Browse files
authored
Merge pull request #1917 from VisActor/fix/reApplyState
fix: fix issue with reApplyState when this state is not running yet
2 parents ff5ac37 + e81b0fa commit 37fee30

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@visactor/vrender-animate",
5+
"comment": "fix: fix issue with reApplyState when this state is not running yet",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@visactor/vrender-animate"
10+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export class AnimateExecutor implements IAnimateExecutor {
4747
this._target = target;
4848
}
4949

50+
get started(): boolean {
51+
return this._started;
52+
}
53+
5054
/**
5155
* 注册一个回调,当动画开始时调用
5256
*/

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ export class AnimationStateManager {
233233

234234
reApplyState(state: string): void {
235235
const stateInfo = this.stateList?.find(stateInfo => stateInfo.state === state);
236-
if (stateInfo) {
236+
// 只有当状态存在且动画正在运行时才重新应用
237+
if (stateInfo && stateInfo.executor.started) {
237238
// stop状态会改变stateList,但因为是reapply,所以保留原始的stateList
238239
const stateList = this.stateList.slice();
239240
stateInfo.executor.stop();

0 commit comments

Comments
 (0)