Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the timeline generation logic in packages/webgal to filter out non-numeric properties from animation segments before they are processed by the animation engine. A review comment suggests explicitly excluding the duration property from the filtered values, as it is a numeric property that should not be passed to the animation interpolation logic to avoid unnecessary calculations.
| currentDelay += segmentDuration; | ||
| const { position, scale, ...segmentValues } = segment; | ||
| // 移除所有值类型不是 number 的属性 | ||
| const filteredSegmentValues = omitBy(segmentValues, (value) => typeof value !== 'number'); |
Contributor
There was a problem hiding this comment.
这里的过滤逻辑虽然排除了非数字类型的属性(如 ease),但 duration 也是数字类型,因此会被保留在 filteredSegmentValues 中。这会导致 duration 被传递给 popmotion 进行插值动画,并在 onUpdate 中不断赋值给 PIXI 容器。由于 duration 并不是 PIXI 容器的变换属性,建议在过滤时显式排除它,以避免不必要的计算和属性赋值。
Suggested change
| const filteredSegmentValues = omitBy(segmentValues, (value) => typeof value !== 'number'); | |
| const filteredSegmentValues = omitBy(segmentValues, (value, key) => typeof value !== 'number' || key === 'duration'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
介绍
修复 transform 含有非 number 类型字段时,popmotion 连带游戏卡死的情况
popmotion 似乎只支持 number 和一小部分特定格式的 string,并且只提取第一层属性,其他类型都会报错。position 和 scale 因为已经自行提取出来了,没什么问题
更改
在生成 timeline 的 values 前先对每个 segment 过滤掉所有值不是 number 类型的字段。
测试