Skip to content

Commit

Permalink
[fix] Fixed disappearing animation time control (#2625)
Browse files Browse the repository at this point in the history
* Fixed disapiaring animation time control

Signed-off-by: Sergey Markov <mar.ser.dlx@gmail.com>
  • Loading branch information
mars-dlx committed Sep 13, 2024
1 parent c70ae07 commit ef32f71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface AnimationControllerProps<T extends number | number[]> {
pauseAnimation: () => void,
resetAnimation: () => void,
timeline: Timeline | undefined,
setTimelineValue: (x: any) => void
setTimelineValue: (x: T) => void
) => React.ReactElement | null;
}

Expand Down
11 changes: 6 additions & 5 deletions src/components/src/layer-animation-controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface LayerAnimationControllerProps {
pauseAnimation: () => void,
resetAnimation: () => void,
timeline: Timeline | undefined,
setTimelineValue: (x: any) => void
setTimelineValue: (x: number | number[]) => void
) => React.ReactElement | null;
}

Expand All @@ -33,13 +33,14 @@ function LayerAnimationControllerFactory(
const {timeSteps, domain} = animationConfig;

const setTimelineValue = useCallback(
(value: number) => {
(value: number | number[]) => {
const timelineValue = toArray(value)[0];
if (Array.isArray(timeSteps)) {
setLayerAnimationTime(snapToMarks(toArray(value)[0], timeSteps));
setLayerAnimationTime(snapToMarks(timelineValue, timeSteps));

// TODO: merge slider in to avoid this step
} else if (domain && value >= domain[0] && value <= domain[1]) {
setLayerAnimationTime(value);
} else if (domain && timelineValue >= domain[0] && timelineValue <= domain[1]) {
setLayerAnimationTime(timelineValue);
}
},
[domain, setLayerAnimationTime, timeSteps]
Expand Down

0 comments on commit ef32f71

Please sign in to comment.