Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

stop animation on proj switch

Jason Kent5542f6c70adf
diff --git a/web/js/containers/projection.js b/web/js/containers/projection.js
index 0fdedce81..f7b71da47 100644
--- a/web/js/containers/projection.js
+++ b/web/js/containers/projection.js
@@ -5,6 +5,7 @@ import { get as lodashGet } from 'lodash';
import googleTagManager from 'googleTagManager';
import changeProjection from '../modules/projection/actions';
import { onToggle } from '../modules/modal/actions';
+import { stop } from '../modules/animation/actions';
import { resetProductPickerState } from '../modules/product-picker/actions';
import IconList from '../components/util/list';
@@ -94,6 +95,7 @@ const mapDispatchToProps = (dispatch) => ({
updateProjection: (id, config) => {
dispatch(changeProjection(id));
dispatch(resetProductPickerState(id));
+ dispatch(stop());
},
onCloseModal: () => {
dispatch(onToggle());
diff --git a/web/js/modules/animation/reducers.js b/web/js/modules/animation/reducers.js
index 43fefa384..72b2dbfd7 100644
--- a/web/js/modules/animation/reducers.js
+++ b/web/js/modules/animation/reducers.js
@@ -1,4 +1,3 @@
-import { assign as lodashAssign } from 'lodash';
import util from '../../util/util';
import {
OPEN_ANIMATION,
@@ -26,79 +25,93 @@ export const defaultState = {
boundaries: undefined,
};
export function getInitialState(config) {
- return lodashAssign({}, defaultState, {
+ return {
+ ...defaultState,
startDate: util.dateAdd(config.initialDate, 'day', -7),
endDate: config.initialDate,
- });
+ };
}
export function animationReducer(state = defaultState, action) {
switch (action.type) {
case OPEN_ANIMATION:
- return lodashAssign({}, state, {
+ return {
+ ...state,
isActive: true,
gifActive: false,
- });
+ };
case EXIT_ANIMATION:
- return lodashAssign({}, state, {
+ return {
+ ...state,
isActive: false,
gifActive: false,
isPlaying: false,
- });
+ };
case PLAY_ANIMATION:
- return lodashAssign({}, state, {
+ return {
+ ...state,
isPlaying: true,
gifActive: false,
- });
+ };
case STOP_ANIMATION:
- return lodashAssign({}, state, {
+ return {
+ ...state,
isPlaying: false,
- });
+ };
case UPDATE_FRAME_RATE:
- return lodashAssign({}, state, {
+ return {
+ ...state,
speed: action.value,
- });
+ };
case UPDATE_START_AND_END_DATE:
- return lodashAssign({}, state, {
+ return {
+ ...state,
startDate: action.startDate,
endDate: action.endDate,
isPlaying: false,
- });
+ };
case UPDATE_START_DATE:
- return lodashAssign({}, state, {
+ return {
+ ...state,
startDate: action.value,
isPlaying: false,
- });
+ };
case UPDATE_END_DATE:
- return lodashAssign({}, state, {
+ return {
+ ...state,
endDate: action.value,
isPlaying: false,
- });
+ };
case UPDATE_CROP_BOUNDS:
- return lodashAssign({}, state, {
+ return {
+ ...state,
boundaries: action.value,
- });
+ };
case TOGGLE_LOOPING:
- return lodashAssign({}, state, {
+ return {
+ ...state,
loop: !state.loop,
- });
+ };
case TOGGLE_GIF:
- return lodashAssign({}, state, {
+ return {
+ ...state,
gifActive: !state.gifActive,
isPlaying: false,
- });
+ };
case KEY_PRESS_ACTION:
if (action.keyCode === 32 && state.isActive) {
- return lodashAssign({}, state, {
+ return {
+ ...state,
isPlaying: !state.isPlaying,
- });
+ };
}
if (action.keyCode === 27) {
- return lodashAssign({}, state, {
+ return {
+ ...state,
isActive: false,
gifActive: false,
isPlaying: false,
- });
+ };
}
return state;
diff --git a/web/js/modules/projection/reducer.js b/web/js/modules/projection/reducer.js
index 5ae534790..ff6fa05e5 100644
--- a/web/js/modules/projection/reducer.js
+++ b/web/js/modules/projection/reducer.js
@@ -1,4 +1,3 @@
-import { assign as lodashAssign } from 'lodash';
import { CHANGE_PROJECTION } from './constants';
export const projectionState = {
@@ -9,10 +8,11 @@ export const projectionState = {
export default function projectionReducer(state = projectionState, action) {
switch (action.type) {
case CHANGE_PROJECTION:
- return lodashAssign({}, state, {
+ return {
+ ...state,
id: action.id,
selected: action.selected,
- });
+ };
default:
return state;
}