diff options
Diffstat (limited to 'apps/web/src/lib/animation/interpolation.ts')
| -rw-r--r-- | apps/web/src/lib/animation/interpolation.ts | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/apps/web/src/lib/animation/interpolation.ts b/apps/web/src/lib/animation/interpolation.ts index 9609441c..67456aa0 100644 --- a/apps/web/src/lib/animation/interpolation.ts +++ b/apps/web/src/lib/animation/interpolation.ts @@ -9,6 +9,7 @@ import type { ScalarSegmentType, } from "@/lib/animation/types"; import { TIME_EPSILON_SECONDS } from "@/constants/animation-constants"; +import { clamp } from "@/utils/math"; import { getBezierPoint, getDefaultLeftHandle, @@ -41,10 +42,6 @@ function isWithinTimePair({ ); } -function clamp01({ value }: { value: number }): number { - return Math.max(0, Math.min(1, value)); -} - function lerpNumber({ leftValue, rightValue, @@ -287,8 +284,10 @@ export function getScalarChannelValueAtTime({ return rightKey.value; } - const progress = clamp01({ + const progress = clamp({ value: (time - leftKey.time) / span, + min: 0, + max: 1, }); if (leftKey.segmentToNext === "linear") { return lerpNumber({ |
