From 81e7a7fb32466633d38fa14bd5e14c2dca7bf658 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Mon, 2 Mar 2026 15:08:21 +0100 Subject: feat: implement keyframe support for more properties at the core (no ui yet) --- apps/web/src/lib/animation/resolve.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'apps/web/src/lib/animation/resolve.ts') diff --git a/apps/web/src/lib/animation/resolve.ts b/apps/web/src/lib/animation/resolve.ts index 58f292b1..450ae983 100644 --- a/apps/web/src/lib/animation/resolve.ts +++ b/apps/web/src/lib/animation/resolve.ts @@ -1,6 +1,7 @@ -import type { ElementAnimations } from "@/types/animation"; +import type { AnimationPropertyPath, ElementAnimations } from "@/types/animation"; import type { Transform } from "@/types/timeline"; -import { getNumberChannelValueAtTime } from "./interpolation"; +import { getColorValueAtTime, getNumberChannelValueAtTime } from "./interpolation"; +import { getColorChannelForPath } from "./color-channel"; import { getNumberChannelForPath } from "./number-channel"; export function getElementLocalTime({ @@ -91,6 +92,24 @@ export function resolveOpacityAtTime({ }); } +export function resolveColorAtTime({ + baseColor, + animations, + propertyPath, + localTime, +}: { + baseColor: string; + animations: ElementAnimations | undefined; + propertyPath: AnimationPropertyPath; + localTime: number; +}): string { + return getColorValueAtTime({ + channel: getColorChannelForPath({ animations, propertyPath }), + time: Math.max(0, localTime), + fallbackValue: baseColor, + }); +} + export function resolveVolumeAtTime({ baseVolume, animations, -- cgit v1.3.1