Skip to content

Commit 674a669

Browse files
fix: post bg state set
1 parent 49344f4 commit 674a669

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

  • packages/webgal/src/Core/gameScripts/changeBg

packages/webgal/src/Core/gameScripts/changeBg/index.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ export const changeBg = (sentence: ISentence): IPerform => {
3232
dispatch(unlockCgInUserData({ name: unlockName, url, series }));
3333
}
3434

35+
/**
36+
* 判断背景 URL 是否发生了变化
37+
*/
38+
const isUrlChanged = webgalStore.getState().stage.bgName !== sentence.content;
39+
3540
/**
3641
* 删掉相关 Effects,因为已经移除了
3742
*/
38-
if (webgalStore.getState().stage.bgName !== sentence.content) {
43+
if (isUrlChanged) {
3944
dispatch(stageActions.removeEffectByTargetId(`bg-main`));
4045
}
4146

@@ -85,6 +90,17 @@ export const changeBg = (sentence: ISentence): IPerform => {
8590
duration = getAnimateDuration(exitAnimation);
8691
}
8792

93+
/**
94+
* 背景状态后处理
95+
*/
96+
function postBgStateSet() {
97+
if (isUrlChanged) {
98+
// 当 URL 发生变化时,清理旧的 hold 动画
99+
WebGAL.gameplay.performController.unmountPerform(`animation-bg-main`, true);
100+
}
101+
}
102+
103+
postBgStateSet();
88104
dispatch(setStage({ key: 'bgName', value: sentence.content }));
89105

90106
return {

0 commit comments

Comments
 (0)