Skip to content

Conversation

@HardyNLee
Copy link
Contributor

介绍

修复 timeline 动画仅有一段, 但 duration 不为 0 时, 此后所有动画都失效的问题

fix #808

测试

changeBg:bg.webp;
changeFigure:stand.webp -id=aaa;
; 执行下面这一句后, 所有动画失效
setTempAnimation:[{"duration":1000,"position":{"x":-300}}] -target=aaa;
setTransform:{"position":{"x":300}} -duration=1000 -target=aaa;

@gemini-code-assist
Copy link

Summary of Changes

Hello @HardyNLee, 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!

此拉取请求旨在解决时间轴动画系统中的一个错误。此前,如果一个动画仅包含一个片段但设置了非零持续时间,会导致后续所有动画无法正常执行。本次修复通过在创建动画实例前增加对时间轴长度的检查,确保只有在存在多个动画关键帧时才初始化 popmotion 动画,从而避免了这种意外的行为,提高了动画系统的稳定性。

Highlights

  • 动画失效修复: 修复了时间轴动画的一个关键问题,即当只有一个动画片段但持续时间不为零时,后续所有动画都会失效。
  • 条件逻辑优化: 通过修改 generateTimelineObj 函数中的条件,确保 popmotion.animate 实例仅在动画持续时间大于0且时间轴长度大于1时才被创建。

🧠 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.

Changelog
  • packages/webgal/src/Core/controller/stage/pixi/animations/timeline.ts
    • 修改了 generateTimelineObj 函数中 popmotion.animate 实例的创建条件,增加了 timeline.length > 1 的判断。
Activity
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

你好!这次的 Pull Request 很好地修复了当时间轴动画只有一个关键帧且持续时间不为零时,导致后续动画失效的严重问题。你通过增加 timeline.length > 1 的检查,精准地定位并解决了问题根源,避免了为单一关键帧创建无效动画。这个修复逻辑清晰,代码简洁。我还发现一个相关的边界情况,并已在代码中提出了具体的改进建议,希望能帮助代码更加健壮。

// 只有有 duration 的时候才有动画
if (duration > 0) {
// 只有有 duration 且 timeline 长度大于 1 的时候才有动画
if (duration > 0 && timeline.length > 1) {

Choose a reason for hiding this comment

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

medium

这个条件很好地解决了只有一个关键帧时创建动画的问题。然而,我注意到一个相关的边界情况:当 timeline 数组为空时,此函数将在第 64 行因试图解构 undefined 而崩溃。虽然这可能超出了本次修复的范围,但为了增强函数的健壮性,建议在函数开头添加一个检查来处理空时间轴的情况,例如:

if (timeline.length === 0) {
  // 返回一个无操作的动画对象或直接返回
  return {
    setStartState: () => {},
    setEndState: () => {},
    tickerFunc: () => {},
    getEndStateEffect: () => ({}),
    forceStopWithoutSetEndState: () => {},
  };
}

@MakinoharaShoko MakinoharaShoko merged commit 7d4aaf1 into OpenWebGAL:dev Feb 6, 2026
1 check passed
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