Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ export function generateTimelineObj(
const segmentDuration = segment.duration;
currentDelay += segmentDuration;
const { position, scale, ...segmentValues } = segment;
// 移除所有值类型不是 number 的属性
const filteredSegmentValues = omitBy(segmentValues, (value) => typeof value !== 'number');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

这里的过滤逻辑虽然排除了非数字类型的属性(如 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');

// 不能用 scale,因为 popmotion 不能用嵌套
values.push({ x: position.x, y: position.y, scaleX: scale.x, scaleY: scale.y, ...segmentValues });
values.push({ x: position.x, y: position.y, scaleX: scale.x, scaleY: scale.y, ...filteredSegmentValues });
// Easing 需要比 values 的长度少一个
if (i > 0) {
easeArray.push(stringToEasing(segment.ease));
Expand Down
Loading