Interactive interface for browsing global, full-resolution satellite imagery
Prevent anim keypress actions when modal is open #1787
Benjamin Kingbba2cfab83a2
diff --git a/web/js/app.js b/web/js/app.jsindex 6160fa01e..ca3accd84 100644--- a/web/js/app.js+++ b/web/js/app.js@@ -75,6 +75,7 @@ import '../css/modal.css';import '../css/list.css';import '../css/vectorMeta.css';import '../pages/css/document.css';+import { keyPress } from './modules/key-press/actions';class App extends React.Component {constructor(props) {@@ -173,7 +174,7 @@ function mapStateToProps(state, ownProps) {}const mapDispatchToProps = dispatch => ({keyPressAction: keyCode => {- dispatch({ type: 'KEY_PRESS_ACTION', keyCode });+ dispatch(keyPress(keyCode));},screenResize: (width, height) => {dispatch(calculateResponsiveState(window));diff --git a/web/js/modules/animation/reducers.js b/web/js/modules/animation/reducers.jsindex 546bd78d6..10ca3e2d5 100644--- a/web/js/modules/animation/reducers.js+++ b/web/js/modules/animation/reducers.js@@ -38,9 +38,7 @@ export function animationReducer(state = defaultState, action) {startDate: state.startDate? state.startDate: util.dateAdd(action.date, 'day', -7),- endDate: state.endDate- ? state.endDate- : action.date+ endDate: state.endDate ? state.endDate : action.date});case EXIT_ANIMATION:return lodashAssign({}, state, {@@ -86,7 +84,7 @@ export function animationReducer(state = defaultState, action) {gifActive: !state.gifActive,isPlaying: false});- case 'KEY_PRESS_ACTION':+ case 'ANIMATION_KEY_PRESS_ACTION':if (action.keyCode === 32 && state.isActive) {return lodashAssign({}, state, {isPlaying: !state.isPlayingdiff --git a/web/js/modules/key-press/actions.js b/web/js/modules/key-press/actions.jsnew file mode 100644index 000000000..69eb9e26c--- /dev/null+++ b/web/js/modules/key-press/actions.js@@ -0,0 +1,19 @@+/**+ * Function to dispatch actions+ * based on keyCode and active+ * State+ *+ * @param {Number} keyCode+ */+export function keyPress(keyCode) {+ return (dispatch, getState) => {+ const { modal, animation } = getState();+ if (animation.isActive && !modal.isOpen) {+ // can get more specific modal.key !== "LAYER_PICKER_COMPONENT"+ dispatch({+ type: 'ANIMATION_KEY_PRESS_ACTION',+ keyCode+ });+ }+ };+}