Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Prevent data-download click while animating to event #1883

Benjamin King623ec3d98e18
diff --git a/web/js/components/sidebar/nav/nav-case.js b/web/js/components/sidebar/nav/nav-case.js
index f487f42ef..33e22c25b 100644
--- a/web/js/components/sidebar/nav/nav-case.js
+++ b/web/js/components/sidebar/nav/nav-case.js
@@ -10,14 +10,15 @@ class NavCase extends React.Component {
isMobile,
isCompareMode,
onTabClick,
- activeTab
+ activeTab,
+ isDataDisabled
} = this.props;
if (tabTypes.download) {
return (
<CustomNavItem
isMobile={isMobile}
shouldHideInMobile={true}
- isDisabled={!!isCompareMode}
+ isDisabled={!!isCompareMode || isDataDisabled}
onTabClick={onTabClick}
text="Data"
id="download"
@@ -111,6 +112,7 @@ class NavCase extends React.Component {
NavCase.propTypes = {
activeTab: PropTypes.string,
isCompareMode: PropTypes.bool,
+ isDataDisabled: PropTypes.bool,
isMobile: PropTypes.bool,
onTabClick: PropTypes.func,
tabTypes: PropTypes.object,
diff --git a/web/js/containers/sidebar/sidebar.js b/web/js/containers/sidebar/sidebar.js
index ef0c062b0..a8403e599 100644
--- a/web/js/containers/sidebar/sidebar.js
+++ b/web/js/containers/sidebar/sidebar.js
@@ -157,7 +157,8 @@ class Sidebar extends React.Component {
activeTab,
tabTypes,
isMobile,
- changeTab
+ changeTab,
+ isDataDisabled
} = this.props;
if (isMobile && activeTab === 'download') changeTab('layers');
const wheelCallBack = util.browser.chrome ? util.preventPinch : null;
@@ -197,6 +198,7 @@ class Sidebar extends React.Component {
isMobile={isMobile}
toggleSidebar={this.toggleSidebar.bind(this)}
isCompareMode={isCompareMode}
+ isDataDisabled={isDataDisabled}
/>
<TabContent activeTab={activeTab}>
<TabPane tabId="layers">
@@ -228,7 +230,16 @@ class Sidebar extends React.Component {
}
}
function mapStateToProps(state) {
- const { browser, sidebar, compare, layers, config, modal, animation } = state;
+ const {
+ browser,
+ sidebar,
+ compare,
+ layers,
+ config,
+ modal,
+ animation,
+ events
+ } = state;
const { screenHeight } = browser;
const { activeTab, isCollapsed, mobileCollapsed } = sidebar;
const { activeString } = compare;
@@ -243,6 +254,7 @@ function mapStateToProps(state) {
isCompareMode: compare.active,
activeString,
numberOfLayers,
+ isDataDisabled: events.isAnimatingToEvent,
isCollapsed: isMobile
? mobileCollapsed
: isCollapsed ||
@@ -295,6 +307,7 @@ Sidebar.propTypes = {
hasLocalStorage: PropTypes.bool,
isCollapsed: PropTypes.bool,
isCompareMode: PropTypes.bool,
+ isDataDisabled: PropTypes.bool,
isMobile: PropTypes.bool,
loadedCustomPalettes: PropTypes.func,
numberOfLayers: PropTypes.number,
diff --git a/web/js/map/natural-events/ui.js b/web/js/map/natural-events/ui.js
index f64e8e52a..a91a15a09 100644
--- a/web/js/map/natural-events/ui.js
+++ b/web/js/map/natural-events/ui.js
@@ -10,7 +10,7 @@ import { naturalEventsUtilGetEventById } from './util';
import { CHANGE_TAB as CHANGE_SIDEBAR_TAB } from '../../modules/sidebar/constants';
import * as EVENT_CONSTANTS from '../../modules/natural-events/constants';
import { activateLayersForEventCategory } from '../../modules/layers/actions';
-import { deselectEvent as deselectEventAction } from '../../modules/natural-events/actions';
+import { deselectEvent as deselectEventAction, selected as selectedAction } from '../../modules/natural-events/actions';
import { selectDate } from '../../modules/date/actions';
import { CHANGE_PROJECTION } from '../../modules/projection/constants';
@@ -302,6 +302,7 @@ export default function naturalEventsUI(ui, config, store, models) {
ui.map.updateDate();
}
naturalEventsTrack.update(event, ui.map.selected, date, self.selectEvent);
+ store.dispatch(selectedAction());
});
};
diff --git a/web/js/modules/natural-events/actions.js b/web/js/modules/natural-events/actions.js
index 724b5cb1c..819ddad97 100644
--- a/web/js/modules/natural-events/actions.js
+++ b/web/js/modules/natural-events/actions.js
@@ -6,7 +6,8 @@ import {
DESELECT_EVENT,
SHOW_ALL_EVENTS,
ONLY_SHOW_VISIBLE,
- TOGGLE_SHOW_ALL
+ TOGGLE_SHOW_ALL,
+ FINISHED_ANIMATING_TO_EVENT
} from './constants';
import { requestAction } from '../core/actions';
@@ -73,3 +74,8 @@ export function onlyShowVisible() {
type: ONLY_SHOW_VISIBLE
};
}
+export function selected() {
+ return {
+ type: FINISHED_ANIMATING_TO_EVENT
+ };
+}
diff --git a/web/js/modules/natural-events/constants.js b/web/js/modules/natural-events/constants.js
index 1609578c9..1a1b8a2ff 100644
--- a/web/js/modules/natural-events/constants.js
+++ b/web/js/modules/natural-events/constants.js
@@ -18,3 +18,4 @@ export const SELECT_EVENT = 'EVENTS/SELECT_EVENT';
export const SHOW_ALL_EVENTS = 'EVENTS/SHOW_ALL_EVENTS';
export const ONLY_SHOW_VISIBLE = 'EVENTS/ONLY_SHOW_VISIBLE';
export const TOGGLE_SHOW_ALL = 'EVENTS/TOGGLE_SHOW_ALL';
+export const FINISHED_ANIMATING_TO_EVENT = 'EVENTS/FINISHED_ANIMATING_TO_EVENT';
diff --git a/web/js/modules/natural-events/reducers.js b/web/js/modules/natural-events/reducers.js
index 77b89bb6b..94b69d474 100644
--- a/web/js/modules/natural-events/reducers.js
+++ b/web/js/modules/natural-events/reducers.js
@@ -6,7 +6,8 @@ import {
DESELECT_EVENT,
SHOW_ALL_EVENTS,
ONLY_SHOW_VISIBLE,
- TOGGLE_SHOW_ALL
+ TOGGLE_SHOW_ALL,
+ FINISHED_ANIMATING_TO_EVENT
} from './constants';
import { CHANGE_TAB as CHANGE_SIDEBAR_TAB } from '../sidebar/constants';
import {
@@ -47,7 +48,8 @@ export const eventsReducerState = {
date: null
},
active: false,
- showAll: true
+ showAll: true,
+ isAnimatingToEvent: false
};
export function eventsReducer(state = eventsReducerState, action) {
@@ -57,7 +59,8 @@ export function eventsReducer(state = eventsReducerState, action) {
selected: {
id: action.id,
date: action.date
- }
+ },
+ isAnimatingToEvent: true
});
case DESELECT_EVENT:
@@ -85,6 +88,10 @@ export function eventsReducer(state = eventsReducerState, action) {
return lodashAssign({}, state, {
active: isActive
});
+ case FINISHED_ANIMATING_TO_EVENT:
+ return lodashAssign({}, state, {
+ isAnimatingToEvent: false
+ });
default:
return state;
}