Interactive interface for browsing global, full-resolution satellite imagery
add left/right key change date functionality
Edward Plato7f6c7e6fc957
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.jsindex 6588eb6f3..419f4f89a 100644--- a/web/js/components/timeline/timeline-axis/timeline-axis.js+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js@@ -196,14 +196,14 @@ class TimelineAxis extends React.Component {draggerVisible,draggerPositionB: draggerPositionB - pixelsToAdd + position - this.state.draggerWidth,draggerVisibleB,- deque: deque,+ deque,currentTimeRange: current.dates,transformX: -pixelsToAdd - 2,gridNumber,gridWidth,- numberOfVisibleTiles: numberOfVisibleTiles,+ numberOfVisibleTiles,moved: false,- dragSentinelChangeNumber: dragSentinelChangeNumber,+ dragSentinelChangeNumber,position,midPoint: position,dragSentinelCount: 0,@@ -218,19 +218,20 @@ class TimelineAxis extends React.Component {// changes timeScale statewheelZoom = (e) => {- let timeScaleNumber = Number(timeScaleToNumberKey[this.props.timeScale]);- let maxTimeScaleNumber = this.props.hasSubdailyLayers ? 5 : 3;+ let { timeScale, hasSubdailyLayers, changeTimeScale } = this.props;+ let timeScaleNumber = Number(timeScaleToNumberKey[timeScale]);+ let maxTimeScaleNumber = hasSubdailyLayers ? 5 : 3;if (e.deltaY > 0) { // wheel zoom outif (timeScaleNumber > 1) {this.setState({wheelZoom: true- }, this.props.changeTimeScale(timeScaleNumber - 1));+ }, changeTimeScale(timeScaleNumber - 1));}} else {if (timeScaleNumber < maxTimeScaleNumber) { // wheel zoom inthis.setState({wheelZoom: true- }, this.props.changeTimeScale(timeScaleNumber + 1));+ }, changeTimeScale(timeScaleNumber + 1));}}}@@ -1194,7 +1195,7 @@ class TimelineAxis extends React.Component {}// update animation dragger helper function- getAnimationLocateDateUpdate = (diffZeroValues, diffFactor, deltaX, animationStartLocationDate, animationDraggerLocation, frontDate) => {+ getAnimationLocateDateUpdate = (diffZeroValues, diffFactor, deltaX, animLocationDate, animDraggerLocation, frontDate) => {if (!diffZeroValues) { // month or yearlet {position,@@ -1203,7 +1204,7 @@ class TimelineAxis extends React.Component {} = this.state;let { timeScale } = this.props;- let startDraggerPositionRelativeToFrontDate = animationDraggerLocation - position - transformX + deltaX;+ let startDraggerPositionRelativeToFrontDate = animDraggerLocation - position - transformX + deltaX;let gridWidthCoef = startDraggerPositionRelativeToFrontDate / gridWidth;let draggerDateAdded = frontDate.clone().add((Math.floor(gridWidthCoef)), timeScale);let daysCount;@@ -1216,7 +1217,7 @@ class TimelineAxis extends React.Component {let remainderMilliseconds = daysCount * 86400000 * gridWidthCoefRemainder;return draggerDateAdded.clone().add(remainderMilliseconds).format();} else {- let draggerTimeStartValue = moment.utc(animationStartLocationDate).valueOf();+ let draggerTimeStartValue = moment.utc(animLocationDate).valueOf();return moment.utc(draggerTimeStartValue + (diffFactor * deltaX)).format();}}diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex dc925700b..c6d8424bb 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -12,8 +12,10 @@ import DateSelector from '../../components/date-selector/date-selector';import DateChangeArrows from '../../components/timeline/timeline-controls/date-change-arrows';import AnimationWidget from '../../containers/animation-widget';import AnimationButton from '../../components/timeline/timeline-controls/animation-button';-import AxisTimeScaleChange from '../../components/timeline/timeline-controls/axis-timescale-change';++import lodashDebounce from 'lodash/debounce';+import {hasSubDaily,lastDate as layersLastDateTime@@ -37,7 +39,8 @@ class Timeline extends React.Component {super(props);this.state = {timelineHidden: false,- customIntervalModalOpen: false+ customIntervalModalOpen: false,+ animationInProcess: false};// left/right arrowsthis.animator = 0;@@ -48,13 +51,11 @@ class Timeline extends React.Component {* @return {void}*/stopper = () => {- if (this.state.animationInProcess) {- clearInterval(this.animator);- this.animator = 0;- this.setState({- animationInProcess: false- });- }+ clearInterval(this.animator);+ this.animator = 0;+ this.setState({+ animationInProcess: false+ });}/*** Add timeout to date change when buttons are being held so that@@ -88,11 +89,13 @@ class Timeline extends React.Component {changeDate(util.dateAdd(selectedDate, increment, delta));}}- this.animator = setTimeout(animate, ANIMATION_DELAY);- this.setState({- animationInProcess: true- });+ if (this.state.animationInProcess) {+ this.animator = setInterval(() => animate, ANIMATION_DELAY);+ }};+ this.setState({+ animationInProcess: true+ });animate();}@@ -177,6 +180,30 @@ class Timeline extends React.Component {// ui.anim.rangeselect.updateRange(startDate, endDate, true);};+ // handles left/right arrow down to decrement/increment date+ handleKeyDown = lodashDebounce((e) => {+ if (e.keyCode === 37) {+ this.decrementDate();+ e.preventDefault();+ } else if (e.keyCode === 39) {+ this.incrementDate();+ e.preventDefault();+ }+ }, 0, { leading: true, trailing: false })++ // handles stopping change date in process and to allow faster key downs+ handleKeyUp = (e) => {+ if (e.keyCode === 37 || e.keyCode === 39) {+ this.stopper();+ e.preventDefault();+ }+ }++ componentDidMount() {+ document.addEventListener('keydown', this.handleKeyDown);+ document.addEventListener('keyup', this.handleKeyUp);+ }+render() {const {dateFormatted,@@ -213,6 +240,8 @@ class Timeline extends React.Component {dateB={new Date(dateFormattedB)}hasSubdailyLayers={hasSubdailyLayers}draggerSelected={draggerSelected}+ maxDate={new Date(timelineEndDateLimit)}+ minDate={new Date(timelineStartDateLimit)}/></div><div id="zoom-buttons-group">