1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import type {
AnimationPropertyGroup,
AnimationPropertyPath,
ElementAnimations,
} from "@/lib/animation/types";
import { ANIMATION_PROPERTY_GROUPS } from "@/lib/animation/types";
import { getKeyframeAtTime } from "./keyframe-query";
export interface GroupKeyframeRef {
propertyPath: AnimationPropertyPath;
keyframeId: string;
}
export function getGroupKeyframesAtTime({
animations,
group,
time,
}: {
animations: ElementAnimations | undefined;
group: AnimationPropertyGroup;
time: number;
}): GroupKeyframeRef[] {
return ANIMATION_PROPERTY_GROUPS[group].flatMap((propertyPath) => {
const keyframe = getKeyframeAtTime({ animations, propertyPath, time });
return keyframe ? [{ propertyPath, keyframeId: keyframe.id }] : [];
});
}
export function hasGroupKeyframeAtTime({
animations,
group,
time,
}: {
animations: ElementAnimations | undefined;
group: AnimationPropertyGroup;
time: number;
}): boolean {
return getGroupKeyframesAtTime({ animations, group, time }).length > 0;
}
|