Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Only retain anim state in permalink if active #1755

Benjamin King6c620afbd8d4
diff --git a/web/js/location.js b/web/js/location.js
index 63088e8ba..b546bc8dd 100644
--- a/web/js/location.js
+++ b/web/js/location.js
@@ -236,10 +236,11 @@ const getParameters = function(config, parameters) {
type: 'date',
options: {
serializeNeedsGlobalState: true,
- serialize: (currentItemState) => {
- return serializeDate(
- currentItemState || nowMinusSevenDays
- );
+ serialize: (currentItemState, state) => {
+ const isAnimActive = get(state, 'animation.isActive');
+ return isAnimActive
+ ? serializeDate(currentItemState || nowMinusSevenDays)
+ : undefined;
},
parse: str => {
return tryCatchDate(str, nowMinusSevenDays);
@@ -252,10 +253,11 @@ const getParameters = function(config, parameters) {
type: 'date',
options: {
serializeNeedsGlobalState: true,
- serialize: (currentItemState) => {
- return serializeDate(
- currentItemState || now
- );
+ serialize: (currentItemState, state) => {
+ const isAnimActive = get(state, 'animation.isActive');
+ return isAnimActive
+ ? serializeDate(currentItemState || now)
+ : undefined;
},
parse: str => {
return tryCatchDate(str, now);
@@ -336,12 +338,26 @@ const getParameters = function(config, parameters) {
al: {
stateKey: 'animation.loop',
initialState: false,
- type: 'bool'
+ type: 'bool',
+ options: {
+ serializeNeedsGlobalState: true,
+ serialize: (boo, state) => {
+ const isAnimActive = get(state, 'animation.isActive');
+ return isAnimActive ? boo : undefined;
+ }
+ }
},
av: {
stateKey: 'animation.speed',
initialState: 3,
- type: 'number'
+ type: 'number',
+ options: {
+ serializeNeedsGlobalState: true,
+ serialize: (num, state) => {
+ const isAnimActive = get(state, 'animation.isActive');
+ return isAnimActive ? num : undefined;
+ }
+ }
},
ab: {
stateKey: 'animation.isActive',