diff --git a/packages/webgal/src/Core/Modules/animationFunctions.ts b/packages/webgal/src/Core/Modules/animationFunctions.ts index bf9d167ae..f72cf0df5 100644 --- a/packages/webgal/src/Core/Modules/animationFunctions.ts +++ b/packages/webgal/src/Core/Modules/animationFunctions.ts @@ -91,18 +91,19 @@ export function getEnterExitAnimation( if (isBg) { duration = DEFAULT_BG_OUT_DURATION; } - duration = - webgalStore.getState().stage.animationSettings.find((setting) => setting.target === target)?.exitDuration ?? - duration; + const animationSettings = webgalStore + .getState() + .stage.animationSettings.find((setting) => setting.target === target); + duration = animationSettings?.exitDuration ?? duration; // 走默认动画 let animation: IAnimationObject | null = generateUniversalSoftOffAnimationObj(realTarget ?? target, duration); - const animationName = webgalStore - .getState() - .stage.animationSettings.find((setting) => setting.target === target)?.exitAnimationName; + const animationName = animationSettings?.exitAnimationName; if (animationName) { logger.debug('取代默认退出动画', target); animation = getAnimationObject(animationName, realTarget ?? target, getAnimateDuration(animationName), false); duration = getAnimateDuration(animationName); + } + if (animationSettings) { // 退出动画拿完后,删了这个设定 webgalStore.dispatch(stageActions.removeAnimationSettingsByTargetOff(target)); logger.debug('删除退出动画设定', target); diff --git a/packages/webgal/src/store/stageReducer.ts b/packages/webgal/src/store/stageReducer.ts index 901c3624e..57e1ffe42 100644 --- a/packages/webgal/src/store/stageReducer.ts +++ b/packages/webgal/src/store/stageReducer.ts @@ -160,7 +160,7 @@ const stageSlice = createSlice({ const prev = state.animationSettings[index]; state.animationSettings.splice(index, 1); - if (prev.exitAnimationName) { + if (prev.exitAnimationName || prev.exitDuration !== undefined) { // 如果有退出动画设定,保留一个 -off 的设定 const prevTarget = `${action.payload}-off`; const prevSetting = {