Interactive interface for browsing global, full-resolution satellite imagery
add left/right bound axis conditions in update scale, add modular updatePositioning functions, fix wheel left/right drag and setlinetime not working near bounds
Edward Plato4b2320b601d1
diff --git a/web/js/components/timeline/timeline-axis/dragger-container.js b/web/js/components/timeline/timeline-axis/dragger-container.jsindex d833708a7..9f65ec105 100644--- a/web/js/components/timeline/timeline-axis/dragger-container.js+++ b/web/js/components/timeline/timeline-axis/dragger-container.js@@ -176,6 +176,10 @@ class DraggerContainer extends PureComponent {}componentDidMount() {+ this.setInitDraggerTimeStates();+ }++ setInitDraggerTimeStates = () => {this.setState({draggerTimeState: this.props.draggerTimeState,draggerTimeStateB: this.props.draggerTimeStateBdiff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.jsindex 63e153f5d..c0e9605fd 100644--- a/web/js/components/timeline/timeline-axis/timeline-axis.js+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js@@ -42,7 +42,7 @@ class TimelineAxis extends Component {}/**- * @desc main function to update axis scale, time range, grids tiles/text, draggerA/B positions, animation start/end draggers+ * @desc main function to update axis scale, time range, grids tiles/text, dragger A/B positions, animation start/end draggers* @param {String} inputDate* @param {String} timeScale* @param {Number} axisWidthInput@@ -51,63 +51,72 @@ class TimelineAxis extends Component {* @returns {void}*/updateScale = (inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff, hoverChange) => {- // console.log(inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff, hoverChange)- let minDateTimelineStartDateLimit = this.props.timelineStartDateLimit;- let maxDateTimelineEndDateLimit = this.props.timelineEndDateLimit;+ let {+ timelineStartDateLimit,+ timelineEndDateLimit+ } = this.props;let options = timeScaleOptions[timeScale].timeAxis;let gridWidth = options.gridWidth;let axisWidth = axisWidthInput || this.props.axisWidth;- let leftOffset = leftOffsetFixedCoeff ? axisWidth * leftOffsetFixedCoeff : this.props.leftOffset;+ let leftOffset = leftOffsetFixedCoeff+ ? axisWidth * leftOffsetFixedCoeff+ : this.props.leftOffset;if (leftOffset === 0) {- leftOffset = axisWidth * 0.75;+ leftOffset = axisWidth * 0.80;}let numberOfVisibleTiles = Number((axisWidth / gridWidth).toFixed(8));- let gridNumber = Math.floor(numberOfVisibleTiles * 1.5); // should get from state?+ let gridNumber = Math.floor(numberOfVisibleTiles * 1.5);let dragSentinelChangeNumber = gridWidth * (Math.floor(numberOfVisibleTiles * 0.25) + 1);if (timeScale === 'year') {- let endLimitYear = moment.utc(this.props.timelineEndDateLimit).year() + 1;- let startLimitYear = moment.utc(this.props.timelineStartDateLimit).year();+ let endLimitYear = new Date(timelineEndDateLimit).getUTCFullYear() + 1;+ let startLimitYear = new Date(timelineStartDateLimit).getUTCFullYear();gridNumber = endLimitYear - startLimitYear;- numberOfVisibleTiles = gridNumber;}- // Floating point issues need to be handled more cleanly- let midPoint = -((gridWidth * gridNumber) / 2) + ((numberOfVisibleTiles / 2) * gridWidth);+ // this is the middle on the axis based on number of tiles determined from width of axis and gridwidth+ // this is used to determine position and also to "reset" position after an axis drag has stopped+ let midPoint = numberOfVisibleTiles / 2 * gridWidth - gridWidth * gridNumber / 2;+// horizontal scroll will disable this, so use frontDate in that case- let hoverTime = moment.utc(this.props.hoverTime || this.props.frontDate);+ let hoverTimeString = this.props.hoverTime || this.props.frontDate;// handle timeline axis start/end limits- let isBeforeStart = new Date(hoverTime) <= new Date(minDateTimelineStartDateLimit);+ let isBeforeStart = new Date(hoverTimeString) <= new Date(timelineStartDateLimit);if (isBeforeStart) {- hoverTime = moment.utc(minDateTimelineStartDateLimit);+ hoverTimeString = timelineStartDateLimit;} else {- let isAfterEnd = new Date(hoverTime) >= new Date(maxDateTimelineEndDateLimit);+ let isAfterEnd = new Date(hoverTimeString) >= new Date(timelineEndDateLimit);if (isAfterEnd) {- hoverTime = moment.utc(maxDateTimelineEndDateLimit);+ hoverTimeString = timelineEndDateLimit;}}// use input date or hoverTime- hoverTime = inputDate ? moment.utc(inputDate) : hoverTime;+ let hoverTime = inputDate ? moment.utc(inputDate) : moment.utc(hoverTimeString);+let hoverTimeZero = hoverTime.clone().startOf(timeScale);if (timeScale === 'year') {- hoverTimeZero = moment.utc(this.props.timelineStartDateLimit);+ hoverTimeZero = moment.utc(timelineStartDateLimit);}let hoverTimeNextZero = hoverTimeZero.clone().add(1, timeScale);- let draggerDateActual;- let draggerDateActualB;+ let draggerTime;+ let draggerTimeB;if (this.props.draggerSelected === 'selected') {- draggerDateActual = hoverChange ? this.props.draggerTimeState : inputDate || this.props.draggerTimeState;- draggerDateActualB = this.props.draggerTimeStateB;+ draggerTime = hoverChange+ ? this.props.draggerTimeState+ : inputDate || this.props.draggerTimeState;+ draggerTimeB = this.props.draggerTimeStateB;} else {- draggerDateActual = this.props.draggerTimeState;- draggerDateActualB = hoverChange ? this.props.draggerTimeStateB : inputDate || this.props.draggerTimeStateB;+ draggerTime = this.props.draggerTimeState;+ draggerTimeB = hoverChange+ ? this.props.draggerTimeStateB+ : inputDate || this.props.draggerTimeStateB;}- // value of hover time, hover time timeunit zeroed, hover time next unit timeunit zeroed+ // value of hover time, hover time time unit zeroed, hover time next unit time unit zeroedlet hoverTimeValue = hoverTime.valueOf();let hoverTimeZeroValue = hoverTimeZero.valueOf();let hoverTimeNextZeroValue = hoverTimeNextZero.valueOf();@@ -116,6 +125,7 @@ class TimelineAxis extends Component {let diffFactor = diffZeroValues / gridWidth;let diffStartAndZeroed = hoverTimeValue - hoverTimeZeroValue;+ // individual grid offset based on time (e.g., get 04:38:00 based on 04:00:00)let pixelsToAdd = diffStartAndZeroed / diffFactor;// offset grids needed since each zoom in won't be centered@@ -130,13 +140,13 @@ class TimelineAxis extends Component {// get front and back dateslet frontDate = moment.utc(timeRange[0].rawDate);let backDate = timeRange[timeRange.length - 1].rawDate;- // check if dragger date is between front/back dates, null set to ignore granularity (go to ms), [] for inclusive of front/back dates+ // check if dragger date is between front/back dateslet draggerPosition = 0;let draggerVisible = false;- let isBetween = getIsBetween(draggerDateActual, frontDate, backDate);+ let isBetween = getIsBetween(draggerTime, frontDate, backDate);if (isBetween) {- draggerPosition = Math.abs(frontDate.diff(draggerDateActual, timeScale, true) * gridWidth);+ draggerPosition = Math.abs(frontDate.diff(draggerTime, timeScale, true) * gridWidth);if (this.props.isCompareModeActive || this.props.draggerSelected === 'selected') {draggerVisible = true;}@@ -144,52 +154,71 @@ class TimelineAxis extends Component {let draggerPositionB = 0;let draggerVisibleB = false;- let isBetweenB = getIsBetween(draggerDateActualB, frontDate, backDate);+ let isBetweenB = getIsBetween(draggerTimeB, frontDate, backDate);if (isBetweenB) {- draggerPositionB = Math.abs(frontDate.diff(draggerDateActualB, timeScale, true) * gridWidth);+ draggerPositionB = Math.abs(frontDate.diff(draggerTimeB, timeScale, true) * gridWidth);if (this.props.isCompareModeActive || this.props.draggerSelected === 'selectedB') {draggerVisibleB = true;}}++ // update animation draggers+ let animationStartDraggerLocation = 0;+ let animationEndDraggerLocation = 0;++ if (this.props.animStartLocationDate) {+ animationStartDraggerLocation = moment.utc(this.props.animStartLocationDate).diff(frontDate, timeScale, true) * gridWidth;+ animationEndDraggerLocation = moment.utc(this.props.animEndLocationDate).diff(frontDate, timeScale, true) * gridWidth;+ }++ // get positionlet position;// axisWidthInput conditional in place to handle resize centering of positionif (axisWidthInput) {position = midPoint;} else {- // - (offSetGridsDiff * gridWidth) to compensate off center zooming repositioning- position = +(midPoint - (axisWidth / 2 - leftOffset)).toFixed(10) - (offSetGridsDiff * gridWidth);- if (gridNumber % 2 !== 0) { // handle odd number gridNumber grid offset- position += gridWidth / 2;+ if (timeScale === 'year') {+ position = 0 + axisWidth / 2 + (leftOffset - axisWidth / 2);+ } else {+ // - (offSetGridsDiff * gridWidth) to compensate off center zooming repositioning+ position = midPoint - (axisWidth / 2 - leftOffset).toFixed(10) - offSetGridsDiff * gridWidth;+ if (gridNumber % 2 !== 0) { // handle odd number gridNumber grid offset+ position += gridWidth / 2;+ }}}+ // get axis bounds+ let diffFromStartDateLimit = hoverTime.diff(timelineStartDateLimit, timeScale);+ let leftBound = frontDate.diff(timelineEndDateLimit, timeScale) * gridWidth + (midPoint * 1.5) + axisWidth;+ let rightBound = diffFromStartDateLimit * gridWidth + midPoint * 1.5 + axisWidth * 0.25;+if (timeScale === 'year') {- position = 0 + axisWidth / 2 + (leftOffset - axisWidth / 2);+ leftBound = frontDate.diff(timelineEndDateLimit, timeScale) * gridWidth + pixelsToAdd + 2 + axisWidth * 0.80;+ rightBound = axisWidth * 0.25 + pixelsToAdd + 2;}- // update animation draggers- let animationStartDraggerLocation;- let animationEndDraggerLocation;-- if (this.props.animStartLocationDate) {- animationStartDraggerLocation = moment.utc(this.props.animStartLocationDate).diff(frontDate, timeScale, true) * gridWidth;- animationEndDraggerLocation = moment.utc(this.props.animEndLocationDate).diff(frontDate, timeScale, true) * gridWidth;+ // handle position being set beyond bounds due to edge dates not precisely scaling to other timescales+ let boundsDiff = 0;+ if (rightBound < position) {+ let rightBoundDiff = position - rightBound;+ rightBound = rightBound + rightBoundDiff;+ boundsDiff = boundsDiff - rightBoundDiff;+ } else {+ if (leftBound > position) {+ let leftBoundDiff = leftBound - position;+ leftBound = leftBound - leftBoundDiff;+ boundsDiff = boundsDiff + leftBoundDiff;+ }}- // get axis bounds- let timelineStartDateLimit = this.props.timelineStartDateLimit;- let timelineEndDateLimit = this.props.timelineEndDateLimit;- let diffFromStartDateLimit = hoverTime.diff(timelineStartDateLimit, timeScale);- let leftBound = frontDate.diff(timelineEndDateLimit, timeScale) * gridWidth + (midPoint * 1.5) + axisWidth;- let rightBound = (diffFromStartDateLimit * gridWidth) + (midPoint * 1.5);- rightBound = rightBound < position ? position : rightBound;-- let transformX = -pixelsToAdd - 2;- let animationStartLocation = animationStartDraggerLocation + position - pixelsToAdd - 2;- let animationEndLocation = animationEndDraggerLocation + position - pixelsToAdd - 2;+ // update transform and dragger positioning based on calulated offsets+ let transformX = -pixelsToAdd - 2 + boundsDiff;+ let animationStartLocation = animationStartDraggerLocation + position + transformX;+ let animationEndLocation = animationEndDraggerLocation + position + transformX;- draggerPosition = draggerPosition - pixelsToAdd + position - this.state.draggerWidth;- draggerPositionB = draggerPositionB - pixelsToAdd + position - this.state.draggerWidth;+ draggerPosition = draggerPosition - pixelsToAdd + position - this.state.draggerWidth + boundsDiff;+ draggerPositionB = draggerPositionB - pixelsToAdd + position - this.state.draggerWidth + boundsDiff;let updatePositioningArguments = {hasMoved: false,@@ -218,7 +247,7 @@ class TimelineAxis extends Component {leftBound,rightBound,wheelZoom: false- }, this.props.updatePositioning(updatePositioningArguments));+ }, this.props.updatePositioning(updatePositioningArguments, timeScale === 'year' ? this.props.hoverTime : hoverTimeString));}/**@@ -426,7 +455,7 @@ class TimelineAxis extends Component {if (this.state.wheelZoom === true) {draggerDate = this.props.hoverTime;} else {- leftOffset = 0.75;+ leftOffset = 0.80;if (draggerSelected === 'selected') {draggerDate = draggerTimeState;} else {@@ -444,7 +473,7 @@ class TimelineAxis extends Component {} else {draggerDate = draggerTimeStateB;}- this.updateScale(draggerDate, timeScale, axisWidth);+ this.updateScale(draggerDate, timeScale, axisWidth, 0.80);}// handle switching A/B dragger axis focus if switched from A/B sidebar tabs@@ -466,7 +495,7 @@ class TimelineAxis extends Component {// handle A dragger changeif (draggerTimeState !== dateA || prevProps.dateA !== dateA) {// check if draggerCheck will be within acceptable visible axis width- let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateA);+ let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateA, prevProps.dateA);if (!draggerCheck.withinRange) {this.updateScaleWithOffset(dateA, timeScale, draggerCheck);}@@ -475,7 +504,7 @@ class TimelineAxis extends Component {// handle B dragger changeif (draggerTimeStateB !== dateB || prevProps.dateB !== dateB) {// check if draggerCheck will be within acceptable visible axis width- let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateB, true);+ let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateB, prevProps.dateB, true);if (!draggerCheck.withinRange) {this.updateScaleWithOffset(dateB, timeScale, draggerCheck);}@@ -486,35 +515,43 @@ class TimelineAxis extends Component {/*** @desc check if selectedDate will be within acceptable visible axis width* @param {String} selectedDate+ * @param {String} previousDate* @param {Boolean} draggerB - draggerB being checked?* @returns {Object} output - return params used for dragger visibilty/updating axis* @returns {Boolean} output.withinRange - within visible range* @returns {Boolean} output.newDateInThePast - new date older?* @returns {Number} output.newDraggerDiff - difference of new dragger from selected*/- checkDraggerMoveOrUpdateScale = (selectedDate, draggerB) => {- let draggerTimeState;- let draggerPosition;+ checkDraggerMoveOrUpdateScale = (selectedDate, previousDate, draggerB) => {+ const {+ draggerTimeState,+ draggerTimeStateB,+ draggerPosition,+ draggerPositionB,+ timeScale,+ axisWidth+ } = this.props;+ let selectedDraggerTimeState;+ let selectedDraggerPosition;if (draggerB) {- draggerTimeState = this.props.draggerTimeStateB;- draggerPosition = this.props.draggerPositionB;+ selectedDraggerTimeState = draggerTimeStateB;+ selectedDraggerPosition = draggerPositionB;} else {- draggerTimeState = this.props.draggerTimeState;- draggerPosition = this.props.draggerPosition;+ selectedDraggerTimeState = draggerTimeState;+ selectedDraggerPosition = draggerPosition;}- let timeScale = this.props.timeScale;- let gridWidth = this.state.gridWidth;- let axisWidth = this.props.axisWidth;+ let selectedDateMoment = moment.utc(previousDate);+ let draggerDateMoment = moment.utc(selectedDraggerTimeState);- let selectedDateMoment = moment.utc(selectedDate);- let draggerDateMoment = moment.utc(draggerTimeState);+ let newDraggerDiff = draggerDateMoment.diff(selectedDateMoment, timeScale, true);+ let newDateInThePast = draggerDateMoment < selectedDateMoment;- let newDraggerDiff = selectedDateMoment.diff(draggerDateMoment, timeScale, true);- let newDraggerPosition = draggerPosition + (newDraggerDiff * gridWidth);- let newDateInThePast = selectedDateMoment < draggerDateMoment;- let newDraggerWithinRangeCheck = newDraggerPosition <= (axisWidth - 80) && newDraggerPosition >= -26;+ let leftEdgeOfVisibleAxis = -26;+ let rightEdgeOfVisibleAxis = axisWidth - 80;+ let newDraggerWithinRangeCheck = selectedDraggerPosition <= rightEdgeOfVisibleAxis &&+ selectedDraggerPosition >= leftEdgeOfVisibleAxis;return {withinRange: newDraggerWithinRangeCheck,@@ -585,22 +622,7 @@ class TimelineAxis extends Component {let scrollX = this.props.position - 100;if (scrollX < this.state.leftBound) { // cancel drag if exceeds axis leftBoundclearTimeout(this.wheelTimeout);- let updatePositioningArguments = {- hasMoved: false,- isTimelineDragging: false,- position: this.props.position,- transformX: this.props.transformX,- frontDate: this.props.frontDate,- backDate: this.props.backDate,- draggerPosition: this.props.draggerPosition,- draggerPositionB: this.props.draggerPositionB,- draggerVisible: this.props.draggerVisible,- draggerVisibleB: this.props.draggerVisibleB,- animationStartLocation: this.props.animationStartLocation,- animationEndLocation: this.props.animationEndLocation- };- let hoverTime = null;- this.props.updatePositioning(updatePositioningArguments, hoverTime);+ this.props.updateTimelineMoveAndDrag(false, false);} else {let deltaObj = {deltaX: -100,@@ -609,29 +631,14 @@ class TimelineAxis extends Component {this.handleDrag(e, deltaObj);clearTimeout(this.wheelTimeout);this.wheelTimeout = setTimeout(() => {- this.handleStopDrag(null, deltaObj);+ this.handleStopDrag(null, deltaObj, true);}, 100);}} else { // multi-touch drag rightlet scrollX = this.props.position + 100;if (scrollX > this.state.rightBound) { // cancel drag if exceeds axis rightBoundclearTimeout(this.wheelTimeout);- let updatePositioningArguments = {- hasMoved: false,- isTimelineDragging: false,- position: this.props.position,- transformX: this.props.transformX,- frontDate: this.props.frontDate,- backDate: this.props.backDate,- draggerPosition: this.props.draggerPosition,- draggerPositionB: this.props.draggerPositionB,- draggerVisible: this.props.draggerVisible,- draggerVisibleB: this.props.draggerVisibleB,- animationStartLocation: this.props.animationStartLocation,- animationEndLocation: this.props.animationEndLocation- };- let hoverTime = null;- this.props.updatePositioning(updatePositioningArguments, hoverTime);+ this.props.updateTimelineMoveAndDrag(false, false);} else {let deltaObj = {deltaX: 100,@@ -640,7 +647,7 @@ class TimelineAxis extends Component {this.handleDrag(e, deltaObj);clearTimeout(this.wheelTimeout);this.wheelTimeout = setTimeout(() => {- this.handleStopDrag(null, deltaObj);+ this.handleStopDrag(null, deltaObj, true);}, 100);}}@@ -649,11 +656,13 @@ class TimelineAxis extends Component {/*** @desc set mouseDown to handle over dragging range-select and triggering false axis click+ * @desc clientXOnDrag used to determine if 'click then drag' vs 'click only'* @returns {void}*/handleMouseDown = (e) => {this.setState({- mouseDown: true+ mouseDown: true,+ clientXOnDrag: e.clientX});}@@ -668,7 +677,8 @@ class TimelineAxis extends Component {if (e.target.className.animVal !== 'axis-grid-rect') {return;}- if (!this.props.isAnimationDraggerDragging &&+ if (e.clientX === this.state.clientXOnDrag &&+ !this.props.isAnimationDraggerDragging &&!this.props.hasMoved &&(this.state.mouseDown || e.type === 'touchend')) {let {@@ -784,21 +794,7 @@ class TimelineAxis extends Component {* @returns {void}*/handleStartDrag = (e, d) => {- let updatePositioningArguments = {- hasMoved: this.props.hasMoved,- isTimelineDragging: true,- position: this.props.position,- transformX: this.props.transformX,- frontDate: this.props.frontDate,- backDate: this.props.backDate,- draggerPosition: this.props.draggerPosition,- draggerPositionB: this.props.draggerPositionB,- draggerVisible: this.props.draggerVisible,- draggerVisibleB: this.props.draggerVisibleB,- animationStartLocation: this.props.animationStartLocation,- animationEndLocation: this.props.animationEndLocation- };- this.props.updatePositioning(updatePositioningArguments);+ this.props.updateTimelineMoveAndDrag(this.props.hasMoved, true);}/**@@ -905,24 +901,20 @@ class TimelineAxis extends Component {let newDragSentinelCount = dragSentinelCount < 0? dragSentinelChangeNumber + dragSentinelCount + deltaX: dragSentinelCount + deltaX;+let updatePositioningArguments = {hasMoved: true,isTimelineDragging: true,position,- transformX: this.props.transformX,- frontDate: this.props.frontDate,- backDate: this.props.backDate,draggerPosition,draggerPositionB,- draggerVisible: this.props.draggerVisible,- draggerVisibleB: this.props.draggerVisibleB,animationStartLocation,animationEndLocation};this.setState({dragSentinelCount: newDragSentinelCount});- this.props.updatePositioning(updatePositioningArguments);+ this.props.updatePositioningOnSimpleDrag(updatePositioningArguments);}} else if (deltaX < 0) { // dragging left - exposing future datesif (dragSentinelCount + deltaX < -dragSentinelChangeNumber) {@@ -974,24 +966,20 @@ class TimelineAxis extends Component {let newDragSentinelCount = dragSentinelCount > 0? -dragSentinelChangeNumber + dragSentinelCount + deltaX: dragSentinelCount + deltaX;+let updatePositioningArguments = {hasMoved: true,isTimelineDragging: true,position,- transformX: this.props.transformX,- frontDate: this.props.frontDate,- backDate: this.props.backDate,draggerPosition,draggerPositionB,- draggerVisible: this.props.draggerVisible,- draggerVisibleB: this.props.draggerVisibleB,animationStartLocation,animationEndLocation};this.setState({dragSentinelCount: newDragSentinelCount});- this.props.updatePositioning(updatePositioningArguments);+ this.props.updatePositioningOnSimpleDrag(updatePositioningArguments);}}}@@ -1002,16 +990,16 @@ class TimelineAxis extends Component {* d.x === midpoint means an axis click and hasMoved is false* @param {Event} mouse event* @param {Object} draggable delta object+ * @param {Boolean} wheelZoom only true when using wheel gestures* @returns {void}*/- handleStopDrag = (e, d) => {+ handleStopDrag(e, d, wheelZoom) {let {midPoint,leftBound,rightBound} = this.state;let {- timeScale,position,transformX} = this.props;@@ -1019,39 +1007,31 @@ class TimelineAxis extends Component {position = position - midPoint;let hasMoved = false;// drag left OR drag right- if (d.x < midPoint || d.x > midPoint) {+ if (d.x !== midPoint) {hasMoved = true;}-+ if (!wheelZoom) {+ hasMoved = false;+ }// new left/right axis boundsleftBound = leftBound + (midPoint - d.x);rightBound = rightBound + (midPoint - d.x);- if (timeScale === 'year') {- leftBound = -midPoint * 2;- rightBound = midPoint * 2;- }transformX = transformX + position;+let updatePositioningArguments = {hasMoved,isTimelineDragging: false,position: midPoint,- transformX,- frontDate: this.props.frontDate,- backDate: this.props.backDate,- draggerPosition: this.props.draggerPosition,- draggerPositionB: this.props.draggerPositionB,- draggerVisible: this.props.draggerVisible,- draggerVisibleB: this.props.draggerVisibleB,- animationStartLocation: this.props.animationStartLocation,- animationEndLocation: this.props.animationEndLocation+ transformX};this.setState({leftBound,- rightBound+ rightBound,+ wheelZoom: !!wheelZoom});// hoverTime conditional reset necessary for touchpad horizontal scroll gesturelet hoverTime = hasMoved ? null : this.props.hoverTime;- this.props.updatePositioning(updatePositioningArguments, hoverTime);+ this.props.updatePositioningOnAxisStopDrag(updatePositioningArguments, hoverTime);}shouldComponentUpdate(nextProps, nextState) {@@ -1069,11 +1049,13 @@ class TimelineAxis extends Component {timelineEndDateLimit,transformX,frontDate,- backDate+ backDate,+ position} = this.props;let checkForPropsUpdates = (nextProps.axisWidth === axisWidth &&+ nextProps.position === position &&nextProps.dateA === dateA &&nextProps.dateB === dateB &&nextProps.draggerSelected === draggerSelected &&@@ -1198,6 +1180,9 @@ TimelineAxis.propTypes = {showHoverOn: PropTypes.func,showHoverOff: PropTypes.func,updatePositioning: PropTypes.func,+ updatePositioningOnSimpleDrag: PropTypes.func,+ updatePositioningOnAxisStopDrag: PropTypes.func,+ updateTimelineMoveAndDrag: PropTypes.func,isCompareModeActive: PropTypes.bool,draggerSelected: PropTypes.string,hasSubdailyLayers: PropTypes.bool,diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 7f7908037..e7d737f0a 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -254,9 +254,80 @@ class Timeline extends React.Component {});}+ /**+ * @desc handles dynamic positioning update based on simple drag+ * @param {Object} args+ * @param {Boolean} hasMoved+ * @param {Boolean} isTimelineDragging+ * @param {Number} position+ * @param {Number} draggerPosition+ * @param {Number} draggerPositionB+ * @param {Number} animationStartLocation+ * @param {Number} animationEndLocation+ * @returns {void}+ */+ updatePositioningOnSimpleDrag = ({+ hasMoved,+ isTimelineDragging,+ position,+ draggerPosition,+ draggerPositionB,+ animationStartLocation,+ animationEndLocation+ }) => {+ this.setState({+ hasMoved,+ isTimelineDragging,+ showHoverLine: false,+ position,+ draggerPosition,+ draggerPositionB,+ animationStartLocation,+ animationEndLocation+ });+ }++ /**+ * @desc handles dynamic positioning update based on axis drag stop event+ * @param {Object} args+ * @param {Boolean} hasMoved+ * @param {Boolean} isTimelineDragging+ * @param {Number} position+ * @param {Number} transformX+ * @returns {void}+ */+ updatePositioningOnAxisStopDrag = ({+ hasMoved,+ isTimelineDragging,+ position,+ transformX+ }, hoverTime = this.state.hoverTime) => {+ this.setState({+ hasMoved,+ isTimelineDragging,+ showHoverLine: false,+ position,+ transformX,+ hoverTime+ });+ }++ /**+ * @desc update is timeline moved (drag timeline vs. click) and if timeline is dragging+ * @param {Boolean} hasMoved+ * @param {Boolean} isTimelineDragging+ * @returns {void}+ */+ updateTimelineMoveAndDrag = (hasMoved, isTimelineDragging) => {+ this.setState({+ hasMoved,+ isTimelineDragging+ });+ }+/*** @desc handle left/right arrow decrement/increment date- * @param {Number} signconstant - used to determine if decrement(-1) or increment(1)+ * @param {Number} signconstant - used to determine if decrement (-1) or increment (1)* @returns {void}*/handleArrowDateChange(signconstant) {@@ -324,12 +395,13 @@ class Timeline extends React.Component {/*** @desc show/hide custom interval modal+ * @param {Boolean} isOpen* @returns {void}*/- toggleCustomIntervalModal = () => {- this.setState(prevState => ({- customIntervalModalOpen: !prevState.customIntervalModalOpen- }));+ toggleCustomIntervalModal = (isOpen) => {+ this.setState({+ customIntervalModalOpen: isOpen+ });};/**@@ -369,13 +441,11 @@ class Timeline extends React.Component {delta = 1;}this.props.selectInterval(delta, timeScale, customSelected);- this.setState({- customIntervalModalOpen: modalOpen- });+ this.toggleCustomIntervalModal(modalOpen);};/**- * @desc open animation wdiget+ * @desc open animation widget* @returns {void}*/clickAnimationButton = () => {@@ -513,6 +583,7 @@ class Timeline extends React.Component {draggerVisibleB});}+static getDerivedStateFromProps(props, currentState) {// Update animation Date states when animation is initiatedif (!currentState.animationEndLocationDate && !currentState.animationStartLocationDate && props.animStartLocationDate && props.animEndLocationDate) {@@ -535,6 +606,7 @@ class Timeline extends React.Component {}return null;}+componentDidUpdate(prevProps, prevState) {let prevStartLocationDate = prevProps.animStartLocationDate;let prevEndLocationDate = prevProps.animEndLocationDate;@@ -564,26 +636,36 @@ class Timeline extends React.Component {// and no custom value has been initializedif (customIntervalValue === 1 && customIntervalZoomLevel === 3) {if (!prevProps.customSelected && customSelected) {- this.setState({- customIntervalModalOpen: true- });+ this.toggleCustomIntervalModal(true);}if (prevProps.customSelected && !customSelected) {- this.setState({- customIntervalModalOpen: false- });+ this.toggleCustomIntervalModal(false);}}}// handle draggerTimeState updates if date changesif (dateA !== prevProps.dateA && dateA !== this.state.draggerTimeState) {- this.setState({- draggerTimeState: dateA- });+ this.updateDraggerTimeState(dateA, false);}if (dateB !== prevProps.dateB && dateB !== this.state.draggerTimeStateB) {+ this.updateDraggerTimeState(dateB, true);+ }+ }++ /**+ * @desc update dragger time state+ * @param {String} date+ * @param {Boolean} is dragger B selected to update+ * @returns {void}+ */+ updateDraggerTimeState = (date, isDraggerB) => {+ if (isDraggerB) {+ this.setState({+ draggerTimeStateB: date+ });+ } else {this.setState({- draggerTimeStateB: dateB+ draggerTimeState: date});}}@@ -779,6 +861,9 @@ class Timeline extends React.Component {draggerVisibleB={draggerVisibleB}transformX={transformX}updatePositioning={this.updatePositioning}+ updateTimelineMoveAndDrag={this.updateTimelineMoveAndDrag}+ updatePositioningOnSimpleDrag={this.updatePositioningOnSimpleDrag}+ updatePositioningOnAxisStopDrag={this.updatePositioningOnAxisStopDrag}position={position}animationStartLocation={animationStartLocation}animationEndLocation={animationEndLocation}@@ -1051,15 +1136,15 @@ const mapDispatchToProps = dispatch => ({toggleActiveCompareState: () => {dispatch(toggleActiveCompareState());},- // update anim startDate+ // update animation startDateonUpdateStartDate: date => {dispatch(changeStartDate(date));},- // update anim endDate+ // update animation endDateonUpdateEndDate: date => {dispatch(changeEndDate(date));},- // update anim startDate and endDate+ // update animation startDate and endDateonUpdateStartAndEndDate: (startDate, endDate) => {dispatch(changeStartAndEndDate(startDate, endDate));}@@ -1100,7 +1185,13 @@ Timeline.propTypes = {hideTimeline: PropTypes.bool,isSmallScreen: PropTypes.bool,toggleActiveCompareState: PropTypes.func,- changeDate: PropTypes.func+ changeDate: PropTypes.func,+ changeTimeScale: PropTypes.func,+ selectInterval: PropTypes.func,+ changeCustomInterval: PropTypes.func,+ closeAnimation: PropTypes.func,+ openAnimation: PropTypes.func,+ updateAppNow: PropTypes.func};// get axisWidth and parentOffset for axis, footer, and leftOffset calculations@@ -1118,7 +1209,7 @@ const getEndTime = (layers, config) => {/*** @param {Number} delta Date and direction to change* @param {Number} increment Zoom level of change- * e.g. months,minutes, years, days+ * e.g. months, minutes, years, days* @return {Object} JS Date Object*/const getNextTimeSelection = (delta, increment, prevDate) => {