Skip to content

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

[Bug] Fix saving animation speed (#752)

Shan Hefb813e15a098
diff --git a/src/components/common/animation-control/animation-control.js b/src/components/common/animation-control/animation-control.js
index cad5bb0ad..af5cba80d 100644
--- a/src/components/common/animation-control/animation-control.js
+++ b/src/components/common/animation-control/animation-control.js
@@ -110,7 +110,7 @@ function AnimationControlFactory(
_nextFrame = () => {
this._animation = null;
- const {currentTime, domain, speed} = this.props.animationConfig;
+ const {currentTime, domain, speed = 1} = this.props.animationConfig;
const adjustedSpeed = ((domain[1] - domain[0]) / BASE_SPEED) * speed;
const nextTime =
currentTime + speed > domain[1]
diff --git a/src/reducers/vis-state-merger.js b/src/reducers/vis-state-merger.js
index 1a2704845..7fd920613 100644
--- a/src/reducers/vis-state-merger.js
+++ b/src/reducers/vis-state-merger.js
@@ -303,8 +303,9 @@ export function mergeAnimationConfig(state, animation) {
return {
...state,
animationConfig: {
- domain: null,
- currentTime: animation.currentTime
+ ...state.animationConfig,
+ ...animation,
+ domain: null
}
}
}
diff --git a/src/schemas/vis-state-schema.js b/src/schemas/vis-state-schema.js
index 70294a626..54838b374 100644
--- a/src/schemas/vis-state-schema.js
+++ b/src/schemas/vis-state-schema.js
@@ -688,7 +688,8 @@ export const propertiesV1 = {
animationConfig: new Schema({
version: VERSIONS.v1,
properties: {
- currentTime: null
+ currentTime: null,
+ speed: null
},
key: 'animationConfig'
})
diff --git a/test/node/schemas/vis-state-schema-test.js b/test/node/schemas/vis-state-schema-test.js
index 31289ce1a..6ae3302e2 100644
--- a/test/node/schemas/vis-state-schema-test.js
+++ b/test/node/schemas/vis-state-schema-test.js
@@ -179,7 +179,7 @@ test('#visStateSchema -> v1 -> save animation', t => {
'visState should have all 5 entries');
const expectedSavedLayers = [expectedSavedTripLayer];
- const expectedAnimationConfig = {currentTime: 1565577261000};
+ const expectedAnimationConfig = {currentTime: 1565577261000, speed: 1};
cmpSavedLayers(t, expectedSavedLayers, vsToSave.layers);
t.deepEqual(vsToSave.animationConfig, expectedAnimationConfig, 'should save animationConfig');