Skip to content

Commit f99e5ed

Browse files
Fix: setTransform cannot execute continuously when targeting the same object
1 parent f191b10 commit f99e5ed

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

packages/webgal/src/Core/Modules/perform/performController.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class PerformController {
5050
// perform.isOver = true;
5151
if (!perform.isHoldOn) {
5252
// 如果不是保持演出,清除
53-
this.unmountPerform(perform.performName);
53+
this.softUnmountPerformObject(perform);
5454
}
5555
}, perform.duration);
5656

@@ -103,6 +103,26 @@ export class PerformController {
103103
}
104104
}
105105

106+
public softUnmountPerformObject(perform: IPerform) {
107+
const idx = this.performList.indexOf(perform)
108+
if (idx < 0) return;
109+
perform.stopFunction();
110+
clearTimeout(perform.stopTimeout as unknown as number);
111+
/**
112+
* 在演出列表里删除演出对象的操作必须在调用 goNextWhenOver 之前
113+
* 因为 goNextWhenOver 会调用 nextSentence,而 nextSentence 会清除目前未结束的演出
114+
* 那么 nextSentence 函数就会删除这个演出,但是此时,在这个上下文,i 已经被确定了
115+
* 所以 goNextWhenOver 后的代码会多删东西,解决方法就是在调用 goNextWhenOver 前先删掉这个演出对象
116+
* 此问题对所有 goNextWhenOver 属性为真的演出都有影响,但只有 2 个演出有此问题
117+
*/
118+
this.performList.splice(idx, 1);
119+
if (perform.goNextWhenOver) {
120+
// nextSentence();
121+
this.goNextWhenOver();
122+
}
123+
124+
}
125+
106126
public erasePerformFromState(name: string) {
107127
webgalStore.dispatch(stageActions.removePerformByName(name));
108128
}

0 commit comments

Comments
 (0)