Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[fix] Fixed disappearing animation time control (#2625)

Sergey Markovef32f71191ea
diff --git a/src/components/src/common/animation-control/animation-controller.ts b/src/components/src/common/animation-control/animation-controller.ts
index f56fe8d4d..ae7bc184a 100644
--- a/src/components/src/common/animation-control/animation-controller.ts
+++ b/src/components/src/common/animation-control/animation-controller.ts
@@ -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;
}
diff --git a/src/components/src/layer-animation-controller.tsx b/src/components/src/layer-animation-controller.tsx
index 0bc2a28bc..57c37def0 100644
--- a/src/components/src/layer-animation-controller.tsx
+++ b/src/components/src/layer-animation-controller.tsx
@@ -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;
}
@@ -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]