Skip to content

Commit 0f02c79

Browse files
committed
simplify shape when animation completes
1 parent e4583d2 commit 0f02c79

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

internal/animate/frames.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ export const renderFramesAt = (input: RenderInput): RenderOutput => {
7272
endKeyframe = currentFrames[i];
7373
}
7474

75+
// Return initial end points when past the end of the animation.
76+
const endKeyframeIsLast = endKeyframe === currentFrames[currentFrames.length - 1];
77+
const animationIsPastEndKeyframe = endKeyframe.timestamp < input.timestamp;
78+
if (animationIsPastEndKeyframe && endKeyframeIsLast) {
79+
return {
80+
renderCache,
81+
lastFrameId: endKeyframe.id,
82+
points: endKeyframe.initialPoints,
83+
};
84+
}
85+
7586
// Use and cache prepared points for current interpolation.
7687
let preparedStartPoints: Point[] | undefined =
7788
renderCache[startKeyframe.id]?.preparedStartPoints;
@@ -95,7 +106,7 @@ export const renderFramesAt = (input: RenderInput): RenderOutput => {
95106
(input.timestamp - startKeyframe.timestamp) /
96107
(endKeyframe.timestamp - startKeyframe.timestamp);
97108

98-
// Keep progress withing expected range (ex. division by 0).
109+
// Keep progress within expected range (ex. division by 0).
99110
const clampedProgress = Math.max(0, Math.min(1, progress));
100111

101112
// Apply timing function of end frame.

0 commit comments

Comments
 (0)