Skip to content

Conversation

@ChangeSuger
Copy link

@ChangeSuger ChangeSuger commented Jan 11, 2026

背景

目前的 bg 和 figure 的 exit 动画设置都不能正常生效,如果想正常生效,需要在下一个 changeBg 或 changeFigure 设置相同的 exit 动画(用 setTransition 也一样),最小复现示例(替换 start.txt 即可):

changeBg:bg.webp -exit=shake -next;

changeFigure:stand.webp -left -enter=enter-from-left -exit=shake -next;
:点击测试;
changeFigure:none -left -next;
:退场特效应为 shake,实际为 exit;

changeFigure:stand.webp -left -enter=enter-from-left -next;
:点击测试;
changeFigure:none -exit=shake -left -next;
:退场特效应为 exit,实际为 shake;

:点击测试;
changeBg:none -next;
:退场特效应为 shake,实际为 exit;

changeBg:bg.webp -next;
:点击测试;
changeBg:none -next -exit=shake;
:退场特效应为 exit,实际为 shake;

end;

问题排查 & 修复思路

bg 和 figure 用的是相同的逻辑,这里以 bg 为例展开

核心问题是目前的 bg 和 figure 的切换依赖于相关的状态:“旧bg”的设定在相关指令中就被清除了,取而代之的是“新bg”的设定,在这些状态变更后,才依次执行“旧bg”的 exit 与“新bg” 的 enter,故两者在 getEnterExitAnimation 时拿到的都是“新bg”的设定。

dispatch(stageActions.removeAnimationSettingsByTarget(`bg-main`));

修复思路是将原先的仅移除操作改为在移除的同时,使用 ${target}-off 存储“旧bg”的设定(重复设定时移除之前的设定),保证在 exit 中能拿到“旧bg”的设定。

测试

使用最小复现示例的 txt 文件就可以进行测试。

这个修改方案的缺点是会往状态里增加一倍的 animationSetting,但是想不到别的更好的方案了。

@gemini-code-assist
Copy link

Summary of Changes

Hello @ChangeSuger, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在修复 changeBgchangeFigure 指令中退场动画无法正确应用的问题。通过改进动画设置的存储机制,确保在元素被替换或移除时,其原有的退场动画设置能够被保留并正确检索,从而使预期的动画效果得以正常播放。

Highlights

  • 修复退场动画失效问题: 解决了 changeBgchangeFigure 指令中设置的退场动画无法正常生效的 bug。
  • 动画设置存储优化: 在移除背景或人物时,将其旧的动画设置以 '-off' 后缀的形式存储,确保在执行退场动画时能正确获取到这些设置。
  • 动画查找逻辑调整: 调整了 getEnterExitAnimation 函数中查找退场动画设置的逻辑,使其直接匹配目标名称,修复了原先可能导致错误匹配的问题。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

你好,感谢你的贡献。这个 PR 很好地解决了 changeBgchangeFigureexit 动画无法正常生效的问题。通过在 removeAnimationSettingsByTarget 中保留旧的动画设置(使用 -off 后缀),并在 getEnterExitAnimation 中正确查找这些设置,确保了退场动画能够使用正确的参数。

代码修改的思路清晰,解决了根本问题。我只在 animationFunctions.ts 中发现了一个可以优化的地方,即避免重复的数组查找操作,这有助于提升代码性能和可读性。具体建议请看我的评论。

总体来说,这是一个高质量的修复,做得很好!

Comment on lines 93 to +100
duration =
webgalStore.getState().stage.animationSettings.find((setting) => setting.target + '-off' === target)
?.exitDuration ?? duration;
webgalStore.getState().stage.animationSettings.find((setting) => setting.target === target)?.exitDuration ??
duration;
// 走默认动画
let animation: IAnimationObject | null = generateUniversalSoftOffAnimationObj(realTarget ?? target, duration);
const animationName = webgalStore
.getState()
.stage.animationSettings.find((setting) => setting.target + '-off' === target)?.exitAnimationName;
.stage.animationSettings.find((setting) => setting.target === target)?.exitAnimationName;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了提高代码的可读性和性能,建议将 webgalStore.getState().stage.animationSettings.find(...) 的查找操作提取到一个变量中。这样可以避免重复访问 Redux store 和遍历数组,使代码更高效简洁。

Suggested change
duration =
webgalStore.getState().stage.animationSettings.find((setting) => setting.target + '-off' === target)
?.exitDuration ?? duration;
webgalStore.getState().stage.animationSettings.find((setting) => setting.target === target)?.exitDuration ??
duration;
// 走默认动画
let animation: IAnimationObject | null = generateUniversalSoftOffAnimationObj(realTarget ?? target, duration);
const animationName = webgalStore
.getState()
.stage.animationSettings.find((setting) => setting.target + '-off' === target)?.exitAnimationName;
.stage.animationSettings.find((setting) => setting.target === target)?.exitAnimationName;
const animationSetting = webgalStore.getState().stage.animationSettings.find((setting) => setting.target === target);
duration = animationSetting?.exitDuration ?? duration;
// 走默认动画
let animation: IAnimationObject | null = generateUniversalSoftOffAnimationObj(realTarget ?? target, duration);
const animationName = animationSetting?.exitAnimationName;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants