Interactive interface for browsing global, full-resolution satellite imagery
fix anim date inputs, continue large refactor and clean up
Edward Plato68c832219db2
diff --git a/web/js/components/date-selector/date-selector.js b/web/js/components/date-selector/date-selector.jsindex 90a3ae3d1..cb679e4e4 100644--- a/web/js/components/date-selector/date-selector.js+++ b/web/js/components/date-selector/date-selector.js@@ -54,7 +54,6 @@ class DateSelector extends PureComponent {});}updateDate(date, type) {- console.log(date)this.props.onDateChange(date, this.props.id);}renderSubdaily() {diff --git a/web/js/components/date-selector/input.js b/web/js/components/date-selector/input.jsindex ebb1e82f0..1f242d74c 100644--- a/web/js/components/date-selector/input.js+++ b/web/js/components/date-selector/input.js@@ -33,6 +33,11 @@ class DateInputColumn extends React.Component {if (this.props.focused) {this.inputs[this.props.tabIndex].focus();}+ if (this.props.value !== prevProps.value) {+ this.setState({+ value: this.props.value+ });+ }}componentWillMount() {var size;@@ -47,8 +52,10 @@ class DateInputColumn extends React.Component {}this.size = size;}- componentWillReceiveProps(props) {- this.setState({ value: props.value });+ componentDidMount() {+ this.setState({+ value: this.props.value+ });}onKeyPress(e) {var kc = e.keyCode;diff --git a/web/js/components/range-selection/dragger-range.js b/web/js/components/range-selection/dragger-range.jsindex 9ced5e8b6..8e17c76c6 100644--- a/web/js/components/range-selection/dragger-range.js+++ b/web/js/components/range-selection/dragger-range.js@@ -19,6 +19,9 @@ class TimelineDraggerRange extends PureComponent {endLocation: this.props.endLocation,previousStartLocation: this.props.startLocation};++ this.handleDrag = this.handleDrag.bind(this);+ this.handleDraggerClick = this.handleDraggerClick.bind(this);}/** Resize timeline dragger width@@ -200,13 +203,12 @@ class TimelineDraggerRange extends PureComponent {* @return {void}*/handleDraggerClick(e) {+ e.preventDefault();// compare start locations to check if range has been dragged vs. clickedif (- this.state.startLocation.toFixed(3) ===+ this.state.startLocation.toFixed(3) !==this.state.previousStartLocation.toFixed(3)) {- this.props.onClick(e);- } else {this.setState({ previousStartLocation: this.state.startLocation });}}@@ -244,7 +246,7 @@ class TimelineDraggerRange extends PureComponent {position={null}defaultPosition={{ x: 0, y: 11 }}onStop={this.props.onStop}- onDrag={this.handleDrag.bind(this)}+ onDrag={this.handleDrag}><rectx={this.handleStartPositionRestriction()}@@ -254,11 +256,10 @@ class TimelineDraggerRange extends PureComponent {fillOpacity: this.props.opacity,cursor: 'pointer'}}- // height={this.props.height}- height={64}+ height={this.props.height}className="dragger-range"id={this.props.draggerID}- onClick={this.handleDraggerClick.bind(this)}+ onClick={this.handleDraggerClick}/></Draggable>);@@ -279,7 +280,6 @@ TimelineDraggerRange.propTypes = {width: PropTypes.number,color: PropTypes.string,draggerID: PropTypes.string,- onClick: PropTypes.func,onDrag: PropTypes.func,onStop: PropTypes.func,id: PropTypes.stringdiff --git a/web/js/components/range-selection/dragger.js b/web/js/components/range-selection/dragger.jsindex febefa48f..ff78f7ce0 100644--- a/web/js/components/range-selection/dragger.js+++ b/web/js/components/range-selection/dragger.js@@ -22,6 +22,8 @@ class TimelineDragger extends PureComponent {textColor: props.textColor,max: props.max};++ this.handleDrag = this.handleDrag.bind(this);}/*** Update state if position has changed@@ -41,7 +43,6 @@ class TimelineDragger extends PureComponent {<React.Fragment><rectwidth={this.props.width}- // height={this.props.height}height={52}style={{fill: this.props.color,@@ -168,7 +169,7 @@ class TimelineDragger extends PureComponent {var visibility = this.getVisibility();return (<Draggable- onDrag={this.handleDrag.bind(this)}+ onDrag={this.handleDrag}position={{ x: this.state.position, y: this.props.yOffset }}onStop={() => {this.props.onStop(this.props.id, this.state.position);diff --git a/web/js/components/range-selection/range-selection.js b/web/js/components/range-selection/range-selection.jsindex 6c0899622..1b20be4e1 100644--- a/web/js/components/range-selection/range-selection.js+++ b/web/js/components/range-selection/range-selection.js@@ -22,9 +22,12 @@ class TimelineRangeSelector extends React.Component {this.state = {startLocation: props.startLocation,endLocation: props.endLocation,- max: props.max,deltaStart: 0};++ this.onRangeDrag = this.onRangeDrag.bind(this);+ this.onItemDrag = this.onItemDrag.bind(this);+ this.onDragStop = this.onDragStop.bind(this);}/** When a child component is dragged,@@ -51,7 +54,7 @@ class TimelineRangeSelector extends React.Component {return;}if (startX + this.props.pinWidth >= endX) {- if (startX + this.props.pinWidth >= this.state.max.width) {+ if (startX + this.props.pinWidth >= this.props.max.width) {return;} else {endX = startX + this.props.pinWidth;@@ -60,7 +63,7 @@ class TimelineRangeSelector extends React.Component {} else if (id === 'end') {startX = this.state.startLocation;endX = deltaX + this.state.endLocation;- if (endX > this.state.max.width || startX > endX) {+ if (endX > this.props.max.width || startX > endX) {return;}if (startX + 2 * this.props.pinWidth >= endX) {@@ -69,7 +72,7 @@ class TimelineRangeSelector extends React.Component {} else {startX = deltaX + this.state.startLocation;endX = deltaX + this.state.endLocation;- if (endX >= this.state.max.width || startX < 0) {+ if (endX >= this.props.max.width || startX < 0) {return;}}@@ -93,18 +96,6 @@ class TimelineRangeSelector extends React.Component {event: 'GIF_animation_dragger'});}- /*- * Send callback with click event- *- * @method onRangeClick- *- * @param {object} d - proxy click event object- *- * @return {void}- */- onRangeClick(e) {- this.props.onRangeClick(e.nativeEvent);- }/** Update state based on distance range was dragged*@@ -127,16 +118,21 @@ class TimelineRangeSelector extends React.Component {}// update animation dragger helper function- getAnimationLocateDateUpdate = (animLocationDate, animDraggerLocation, deltaX, { diffZeroValues, diffFactor, frontDate }) => {+ getAnimationLocateDateUpdate = (animLocationDate, animDraggerLocation, deltaX, { diffZeroValues, diffFactor }) => {if (!diffZeroValues) { // month or year- let { timeScale, position, transformX } = this.props;+ let {+ timeScale,+ position,+ transformX+ } = this.props;let options = timeScaleOptions[timeScale].timeAxis;let gridWidth = options.gridWidth;let startDraggerPositionRelativeToFrontDate = animDraggerLocation - position - transformX + deltaX;let gridWidthCoef = startDraggerPositionRelativeToFrontDate / gridWidth;- let draggerDateAdded = frontDate.add((Math.floor(gridWidthCoef)), timeScale);+ let draggerDateAdded = moment.utc(this.props.frontDate).add((Math.floor(gridWidthCoef)), timeScale);+ let draggerDateAddedValue = draggerDateAdded.valueOf();let daysCount;if (timeScale === 'year') {daysCount = draggerDateAdded.isLeapYear() ? 366 : 365;@@ -145,7 +141,8 @@ class TimelineRangeSelector extends React.Component {}let gridWidthCoefRemainder = gridWidthCoef - Math.floor(gridWidthCoef);let remainderMilliseconds = daysCount * 86400000 * gridWidthCoefRemainder;- let newLocationDate = draggerDateAdded.add(remainderMilliseconds);+ let newLocationDate = draggerDateAddedValue + remainderMilliseconds;+return new Date(newLocationDate);} else {let draggerTimeStartValue = new Date(animLocationDate).getTime();@@ -180,20 +177,16 @@ class TimelineRangeSelector extends React.Component {if (deltaXStart !== 0 || deltaXEnd !== 0) {let diffZeroValues = options.scaleMs;// get startDate for diff calculation-- let frontDate;let diffFactor;- if (!diffZeroValues) { // month or year diffFactor is not static, so require more calculation based on front date- frontDate = moment.utc(this.props.frontDate);- } else {+ if (diffZeroValues) { // month or year diffFactor is not static, so require calculation based on front datediffFactor = diffZeroValues / options.gridWidth; // else known diffFactor used}let sharedAnimLocationUpdateParams = {diffZeroValues,- diffFactor,- frontDate+ diffFactor};+if (deltaXStart !== 0) { // update new start dateanimationStartLocationDate = this.getAnimationLocateDateUpdate(animationStartLocationDate,@@ -235,16 +228,6 @@ class TimelineRangeSelector extends React.Component {draggerStartLocation = startLocation;animationStartLocationDate = endDateLimit;}-- // this.setState({- // isAnimationDraggerDragging: isDragging,- // animationStartLocation: draggerStartLocation,- // animationEndLocation: draggerEndLocation,- // showHoverLine: false,- // showDraggerTime: false,- // moved: !isDragging- // }, this.animationUpdateWidget(animationStartLocationDate, animationEndLocationDate, animationStartLocation, animationEndLocation));-this.props.updateAnimationDateAndLocation(animationStartLocationDate,animationEndLocationDate,@@ -254,84 +237,21 @@ class TimelineRangeSelector extends React.Component {);}- // componentDidUpdate(prevProps) {- // let prevStartLocationDate = prevProps.startLocationDate;- // let prevEndLocationDate = prevProps.endLocationDate;-- // if (prevStartLocationDate !== this.props.startLocationDate || prevEndLocationDate !== this.props.endLocationDate) {- // this.animationDraggerDateUpdate()- // }- // }-- // // handle animation dragger location update and state update- // animationDraggerDateUpdate = (animationStartLocationDate, animationEndLocationDate) => {- // // let {- // // gridWidth,- // // // position,- // // transformX- // // } = this.state;- // let { timeScale, position, transformX } = this.props;- // let options = timeScaleOptions[timeScale].timeAxis;- // let gridWidth = options.gridWidth;-- // let frontDate = moment.utc(this.state.currentTimeRange[0].rawDate);- // let startLocation = frontDate.diff(animationStartLocationDate, timeScale, true) * gridWidth;- // let endLocation = frontDate.diff(animationEndLocationDate, timeScale, true) * gridWidth;-- // this.setState({- // animationStartLocation: position - startLocation + transformX,- // animationEndLocation: position - endLocation + transformX- // });- // }-- // shouldComponentUpdate(nextProps, nextState) {- // let nextStartLocationDate = nextProps.startLocationDate;- // let nextEndLocationDate = nextProps.endLocationDate;- // let nextStartLocation = nextProps.startLocation;- // let nextEndLocation = nextProps.endLocation;- // let nextTimelineEndDateLimit = nextProps.timelineEndDateLimit;-- // let {- // startLocationDate,- // endLocationDate,- // startLocation,- // endLocation,- // timelineEndDateLimit- // } = this.props;-- // let checkForUpdates = (- // // nextStartLocationDate === startLocationDate &&- // // nextEndLocationDate === endLocationDate &&- // nextStartLocation === this.state.startLocation &&- // nextEndLocation === this.state.endLocation &&- // nextTimelineEndDateLimit === timelineEndDateLimit- // );-- // if (checkForUpdates) {- // return false;- // }- // return true;- // }-componentDidMount() {- this.setInitialLocation();+ this.updateLocation();}- setInitialLocation = () => {+ updateLocation = () => {this.setState({startLocation: this.props.startLocation,- endLocation: this.props.endLocation,- max: this.props.max+ endLocation: this.props.endLocation});}componentDidUpdate() {let { startLocation, endLocation } = this.props;if (startLocation !== this.state.startLocation || endLocation !== this.state.endLocation) {- this.setState({- startLocation: startLocation,- endLocation: endLocation- });+ this.updateLocation();}}@@ -343,7 +263,6 @@ class TimelineRangeSelector extends React.Component {<svgid="wv-timeline-range-selector"className="wv-timeline-range-selector"- onMouseEnter={this.props.onHover}style={{width: this.props.width,left: this.props.parentOffset@@ -358,39 +277,38 @@ class TimelineRangeSelector extends React.Component {timelineStartDateLimit={this.props.timelineStartDateLimit}timelineEndDateLimit={this.props.timelineEndDateLimit}deltaStart={this.state.deltaStart}- max={this.state.max}- height={this.props.height}+ max={this.props.max}+ height={64}width={this.props.pinWidth}color={this.props.rangeColor}draggerID="range-selector-range"- onClick={this.onRangeClick.bind(this)}- onDrag={this.onRangeDrag.bind(this)}- onStop={this.onDragStop.bind(this)}+ onDrag={this.onRangeDrag}+ onStop={this.onDragStop}id="range"/><Draggerposition={this.state.startLocation}color={this.props.startColor}width={this.props.pinWidth}- height={this.props.height}- onDrag={this.onItemDrag.bind(this)}- onStop={this.onDragStop.bind(this)}- max={this.state.max.width}+ height={45}+ onDrag={this.onItemDrag}+ onStop={this.onDragStop}+ max={this.props.max.width}draggerID="range-selector-dragger-1"backgroundColor={this.props.startTriangleColor}first={true}id="start"/><Dragger- max={this.state.max.width}+ max={this.props.max.width}position={this.state.endLocation}color={this.props.endColor}width={this.props.pinWidth}- height={this.props.height}+ height={45}first={false}draggerID="range-selector-dragger-2"- onDrag={this.onItemDrag.bind(this)}- onStop={this.onDragStop.bind(this)}+ onDrag={this.onItemDrag}+ onStop={this.onDragStop}backgroundColor={this.props.endTriangleColor}id="end"/>@@ -400,6 +318,13 @@ class TimelineRangeSelector extends React.Component {}TimelineRangeSelector.propTypes = {+ updateAnimationDateAndLocation: PropTypes.func,+ width: PropTypes.number,+ parentOffset: PropTypes.number,+ timeScale: PropTypes.string,+ frontDate: PropTypes.string,+ position: PropTypes.number,+ transformX: PropTypes.number,startLocation: PropTypes.number,endLocation: PropTypes.number,startLocationDate: PropTypes.object,@@ -408,10 +333,7 @@ TimelineRangeSelector.propTypes = {timelineEndDateLimit: PropTypes.string,max: PropTypes.object,pinWidth: PropTypes.number,- height: PropTypes.number,onDrag: PropTypes.func,- onHover: PropTypes.func,- onRangeClick: PropTypes.func,rangeOpacity: PropTypes.number,rangeColor: PropTypes.string,startColor: PropTypes.string,diff --git a/web/js/components/timeline/timeline-axis/dragger-container.js b/web/js/components/timeline/timeline-axis/dragger-container.jsindex 53ee52162..823dcac9a 100644--- a/web/js/components/timeline/timeline-axis/dragger-container.js+++ b/web/js/components/timeline/timeline-axis/dragger-container.js@@ -18,8 +18,7 @@ class DraggerContainer extends PureComponent {constructor(props) {super(props);this.state = {- draggerWidth: 49,- // isDraggerDragging: false+ draggerWidth: 49};}@@ -35,11 +34,9 @@ class DraggerContainer extends PureComponent {}// move draggerTimeState to inputTime- setDraggerToTime = (previousTime, inputTime) => {+ setDraggerPosition = (inputTime) => {let frontDate = this.props.frontDate;let backDate = this.props.backDate;- // let draggerTime = draggerB ? this.props.draggerTimeStateB : this.props.draggerTimeState;- let draggerTime = previousTime;let draggerB = this.props.draggerSelected === 'selectedB';let draggerName = draggerB ? 'selectedB' : 'selected';@@ -54,75 +51,9 @@ class DraggerContainer extends PureComponent {let timeScale = this.props.timeScale;let options = timeScaleOptions[timeScale].timeAxis;let gridWidth = options.gridWidth;- console.log(draggerTime, timeScale, frontDate)let frontDateObj = moment.utc(frontDate);- let pixelsToAddToDragger = Math.abs(frontDateObj.diff(draggerTime, timeScale, true) * gridWidth);let pixelsToAddToDraggerNew = Math.abs(frontDateObj.diff(inputTime, timeScale, true) * gridWidth);- let pixelsToAddBasedOnFrontDate = pixelsToAddToDraggerNew - pixelsToAddToDragger;- console.log(pixelsToAddToDragger, pixelsToAddToDraggerNew, pixelsToAddBasedOnFrontDate)- let isVisible = draggerB ? this.props.draggerVisibleB : this.props.draggerVisible;- if (isVisible) {- let draggerPosition = draggerB ? this.props.draggerPositionB : this.props.draggerPosition;- newDraggerPosition = draggerPosition + pixelsToAddBasedOnFrontDate;- } else {- // newDraggerPosition = pixelsToAddToDraggerNew + this.state.position - this.state.draggerWidth + this.state.transformX;- newDraggerPosition = pixelsToAddToDraggerNew + this.props.position - this.state.draggerWidth + this.props.transformX;- }- console.log(inputTime, draggerName, newDraggerPosition, draggerVisible)- this.props.updateDraggerDatePosition(inputTime, draggerName, newDraggerPosition, draggerVisible);-- // if (draggerB) {- // this.setState({- // draggerPositionB: newDraggerPosition,- // draggerVisibleB: draggerVisible,- // draggerTimeStateB: inputTime- // });- // } else {- // this.setState({- // draggerPosition: newDraggerPosition,- // draggerVisible: draggerVisible,- // draggerTimeState: inputTime- // });- // }- }-- // move draggerTimeState to inputTime- setDraggerPosition = (previousTime, inputTime) => {- let frontDate = this.props.frontDate;- let backDate = this.props.backDate;- // let draggerTime = draggerB ? this.props.draggerTimeStateB : this.props.draggerTimeState;- let draggerTime = previousTime;- // let draggerName = draggerB ? 'selectedB' : 'selected';- let draggerB = this.props.draggerSelected === 'selectedB';- let draggerName = draggerB ? 'selectedB' : 'selected';-- let isBetween = getIsBetween(inputTime, frontDate, backDate);-- let draggerVisible = false;- let newDraggerPosition;- if (isBetween) {- draggerVisible = true;- }-- let timeScale = this.props.timeScale;- let options = timeScaleOptions[timeScale].timeAxis;- let gridWidth = options.gridWidth;- console.log(draggerTime, inputTime, timeScale, frontDate)- let frontDateObj = moment.utc(frontDate);- let pixelsToAddToDragger = Math.abs(frontDateObj.diff(draggerTime, timeScale, true) * gridWidth);- let pixelsToAddToDraggerNew = Math.abs(frontDateObj.diff(inputTime, timeScale, true) * gridWidth);- let pixelsToAddBasedOnFrontDate = pixelsToAddToDraggerNew - pixelsToAddToDragger;- console.log(pixelsToAddToDragger, pixelsToAddToDraggerNew, pixelsToAddBasedOnFrontDate)- let isVisible = draggerB ? this.props.draggerVisibleB : this.props.draggerVisible;- if (isVisible) {- // let draggerPosition = draggerB ? this.props.draggerPositionB : this.props.draggerPosition;- // newDraggerPosition = draggerPosition + pixelsToAddBasedOnFrontDate;- } else {- // newDraggerPosition = pixelsToAddToDraggerNew + this.state.position - this.state.draggerWidth + this.state.transformX;- // newDraggerPosition = pixelsToAddToDraggerNew + this.props.position - this.state.draggerWidth + this.props.transformX;- }- console.log(pixelsToAddToDraggerNew, this.props.position, this.state.draggerWidth , this.props.transformX)- newDraggerPosition = pixelsToAddToDraggerNew + this.props.position - this.state.draggerWidth + this.props.transformX;+ newDraggerPosition = pixelsToAddToDraggerNew + this.props.position - this.state.draggerWidth + this.props.transformX + 2;this.props.updateDraggerDatePosition(null, draggerName, newDraggerPosition, draggerVisible);}@@ -278,83 +209,39 @@ class DraggerContainer extends PureComponent {// }// } else { // handle drag within axis view- this.props.updateDraggerDatePosition(newDraggerTime, draggerName, draggerPosition, null, null, true);-- // if (draggerASelected) {- // this.setState({- // draggerPosition: draggerPosition,- // draggerTimeState: newDraggerTime,- // moved: true- // }, this.props.changeDate(new Date(newDraggerTime), 'selected'));- // } else {- // this.setState({- // draggerPositionB: draggerPosition,- // draggerTimeStateB: newDraggerTime,- // moved: true- // }, this.props.changeDate(new Date(newDraggerTime), 'selectedB'));- // }- // }- // });+ this.props.updateDraggerDatePosition(newDraggerTime, draggerName, draggerPosition, null, null, true);}componentDidUpdate(prevProps, prevState) {-console.log(this.props.draggerPosition, this.props.draggerPositionB)let { draggerTimeState, draggerTimeStateB, timeScale } = this.props;let { isDraggerDragging } = this.props;let { dateA, dateB, draggerSelected, compareModeActive } = this.props;- // handle compare mode toggle change++ // handle dragger visibility update on compare mode activate/deactivateif (compareModeActive !== prevProps.compareModeActive) {// TURN ON COMPARE MODEif (compareModeActive) {- // this.setDraggerToTime(dateA);- // this.setDraggerToTime(dateB);- // this.setDraggerPosition(prevProps.draggerTimeState, draggerTimeState);- // this.setDraggerPosition(prevProps.draggerTimeStateB, draggerTimeStateB);+ this.props.setDraggerVisibility(true, true);} else {// TURN OFF COMPARE MODEif (draggerSelected === 'selected') {this.props.setDraggerVisibility(true, false);- // this.setState({- // draggerVisibleB: false- // });} else {this.props.setDraggerVisibility(false, true);- // this.setState({- // draggerVisible: false- // });}}}- // console.log(this.props, prevProps)if (!isDraggerDragging) {// handle A dragger change-if (draggerTimeState !== prevProps.draggerTimeState) {- // check if draggerCheck will be within acceptable visible axis width- // let draggerCheck = this.checkDraggerMoveOrUpdateScale(draggerTimeState);- // if (draggerCheck.withinRange) {-- console.log(prevProps.draggerTimeState, draggerTimeState)- this.setDraggerPosition(prevProps.draggerTimeState, draggerTimeState)- // this.setDraggerToTime(prevProps.draggerTimeState, draggerTimeState);+ // this.setDraggerPosition(prevProps.draggerTimeState, draggerTimeState)+ this.setDraggerPosition(draggerTimeState)}- // } else {- // this.updateScaleWithOffset(draggerTimeState, timeScale, draggerCheck);- // }- // }-// handle B dragger changeif (draggerTimeStateB !== prevProps.draggerTimeStateB) {- // // check if draggerCheck will be within acceptable visible axis width- // let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateB, true);- // if (draggerCheck.withinRange) {- console.log(prevProps.draggerTimeStateB, draggerTimeStateB)- this.setDraggerPosition(prevProps.draggerTimeStateB, draggerTimeStateB)- // this.setDraggerToTime(dateB, true);- // } else {- // this.updateScaleWithOffset(dateB, timeScale, draggerCheck);- // }+ // this.setDraggerPosition(prevProps.draggerTimeStateB, draggerTimeStateB)+ this.setDraggerPosition(draggerTimeStateB)}}}@@ -396,84 +283,76 @@ console.log(this.props.draggerPosition, this.props.draggerPositionB)// return true;// }- // toggle dragger time on/off- // toggleShowDraggerTime = (toggleBoolean) => {- // this.setState({- // // showDraggerTime: toggleBoolean,- // // showHoverLine: false,- // isDraggerDragging: toggleBoolean- // });- // }-- render() {- let {- draggerSelected,- toggleShowDraggerTime,- width,- transformX,- compareModeActive,- draggerPosition,- draggerPositionB,- draggerVisible,- draggerVisibleB- } = this.props;-- let sharedProps = {- toggleShowDraggerTime,- transformX,- compareModeActive- };- console.log(this.props, draggerPosition, draggerPositionB)- return (- draggerSelected === 'selectedB'- ? <svg className="dragger-container" width={width}>- <Dragger- {...sharedProps}- disabled={true}- draggerName='selected'- draggerPosition={draggerPosition}- draggerVisible={draggerVisible}- handleDragDragger={this.handleDragDragger}- selectDragger={this.selectDragger}- toggleShowDraggerTime={toggleShowDraggerTime}- />-- <Dragger+ render() {+ let {+ draggerSelected,+ toggleShowDraggerTime,+ width,+ transformX,+ compareModeActive,+ draggerPosition,+ draggerPositionB,+ draggerVisible,+ draggerVisibleB+ } = this.props;++ let sharedProps = {+ toggleShowDraggerTime,+ transformX,+ compareModeActive+ };+ return (+ draggerSelected === 'selectedB'+ ? <svg className="dragger-container" width={width}>+ {compareModeActive+ ? <Dragger{...sharedProps}- disabled={false}- draggerName='selectedB'- draggerPosition={draggerPositionB}- draggerVisible={draggerVisibleB}+ disabled={true}+ draggerName='selected'+ draggerPosition={draggerPosition}+ draggerVisible={draggerVisible}handleDragDragger={this.handleDragDragger}selectDragger={this.selectDragger}toggleShowDraggerTime={toggleShowDraggerTime}/>- </svg>- : <svg className="dragger-container" width={width}>-- <Dragger- {...sharedProps}- disabled={true}- draggerName='selectedB'- draggerPosition={draggerPositionB}- draggerVisible={draggerVisibleB}- handleDragDragger={this.handleDragDragger}- selectDragger={this.selectDragger}- toggleShowDraggerTime={toggleShowDraggerTime}- />- <Dragger+ : null}+ <Dragger+ {...sharedProps}+ disabled={false}+ draggerName='selectedB'+ draggerPosition={draggerPositionB}+ draggerVisible={draggerVisibleB}+ handleDragDragger={this.handleDragDragger}+ selectDragger={this.selectDragger}+ toggleShowDraggerTime={toggleShowDraggerTime}+ />+ </svg>+ : <svg className="dragger-container" width={width}>+ {compareModeActive+ ? <Dragger{...sharedProps}- disabled={false}- draggerName='selected'- draggerPosition={draggerPosition}- draggerVisible={draggerVisible}+ disabled={true}+ draggerName='selectedB'+ draggerPosition={draggerPositionB}+ draggerVisible={draggerVisibleB}handleDragDragger={this.handleDragDragger}selectDragger={this.selectDragger}toggleShowDraggerTime={toggleShowDraggerTime}/>- </svg>- );- }+ : null}+ <Dragger+ {...sharedProps}+ disabled={false}+ draggerName='selected'+ draggerPosition={draggerPosition}+ draggerVisible={draggerVisible}+ handleDragDragger={this.handleDragDragger}+ selectDragger={this.selectDragger}+ toggleShowDraggerTime={toggleShowDraggerTime}+ />+ </svg>+ );+ }}DraggerContainer.propTypes = {diff --git a/web/js/components/timeline/timeline-axis/hover-line.js b/web/js/components/timeline/timeline-axis/hover-line.jsindex bb909c249..3d7037a1e 100644--- a/web/js/components/timeline/timeline-axis/hover-line.js+++ b/web/js/components/timeline/timeline-axis/hover-line.js@@ -16,15 +16,14 @@ class HoverLine extends PureComponent {hoverLinePosition} = this.props;return (- <svg className='hover-line-container' width={width}>- <line className='svgLine'- style={{- display: !isTimelineDragging && showHoverLine ? 'block' : 'none'- }}- stroke='blue' strokeWidth='2' strokeOpacity='0.48' x1='0' x2='0' y1='0' y2='63'- transform={`translate(${hoverLinePosition + 1}, 0)`} shapeRendering='optimizeSpeed'- />- </svg>+ !isTimelineDragging && showHoverLine+ ? <svg className='timeline-hover-line-container' width={width}>+ <line className='timeline-hover-line'+ stroke='blue' strokeWidth='2' strokeOpacity='0.48' x1='0' x2='0' y1='0' y2='63'+ transform={`translate(${hoverLinePosition + 1}, 0)`} shapeRendering='optimizeSpeed'+ />+ </svg>+ : null);}}diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.jsindex 6a2c8c6e5..dc59035c2 100644--- a/web/js/components/timeline/timeline-axis/timeline-axis.js+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js@@ -2,7 +2,6 @@ import React, { Component } from 'react';import PropTypes from 'prop-types';import Draggable from 'react-draggable';import moment from 'moment';-import lodashDebounce from 'lodash/debounce';import GridRange from './grid-range/grid-range';@@ -14,7 +13,6 @@ import {import {getIsBetween,- getISODateFormatted,removeBackMultipleInPlace,removeFrontMultipleInPlace} from '../date-util';@@ -23,16 +21,13 @@ class TimelineAxis extends Component {constructor(props) {super(props);this.state = {- init: false,+ init: true,draggerWidth: 49,- isDraggerDragging: false,- isTimelineDragging: false,- showDraggerTime: false,dragSentinelCount: 0,- moved: false,currentTimeRange: null,gridWidth: 12,- wheelZoom: false+ wheelZoom: false,+ mouseDown: false};// axisthis.handleDrag = this.handleDrag.bind(this);@@ -45,6 +40,7 @@ class TimelineAxis extends Component {}// main function to update axis scale, time range, grids tiles/text, draggerA/B positions, animation start/end draggersupdateScale = (inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff, hoverChange) => {+ console.log(inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff, hoverChange)let maxDateTimelineEndDateLimit = this.props.timelineEndDateLimit;let options = timeScaleOptions[timeScale].timeAxis;let gridWidth = options.gridWidth;@@ -52,7 +48,7 @@ class TimelineAxis extends Component {let leftOffset = leftOffsetFixedCoeff ? axisWidth * leftOffsetFixedCoeff : this.props.leftOffset;if (leftOffset === 0) {- leftOffset = axisWidth / 2;+ leftOffset = axisWidth * 0.75;}let numberOfVisibleTiles = Number((axisWidth / gridWidth).toFixed(8));@@ -67,7 +63,7 @@ class TimelineAxis extends Component {// Floating point issues need to be handled more cleanlylet midPoint = -((gridWidth * gridNumber) / 2) + ((numberOfVisibleTiles / 2) * gridWidth);- let hoverTime = moment.utc(this.state.hoverTime);+ let hoverTime = moment.utc(this.props.hoverTime);if (hoverTime.isAfter(maxDateTimelineEndDateLimit)) {hoverTime = maxDateTimelineEndDateLimit;@@ -85,6 +81,7 @@ class TimelineAxis extends Component {if (this.props.draggerSelected === 'selected') {draggerDateActual = hoverChange ? this.props.draggerTimeState : inputDate || this.props.draggerTimeState;draggerDateActualB = this.props.draggerTimeStateB;+ console.log(draggerDateActual, draggerDateActualB, this.props)} else {draggerDateActual = this.props.draggerTimeState;draggerDateActualB = hoverChange ? this.props.draggerTimeStateB : inputDate || this.props.draggerTimeStateB;@@ -117,9 +114,9 @@ class TimelineAxis extends Component {let draggerPosition = 0;let draggerVisible = false;-let isBetween = getIsBetween(draggerDateActual, frontDate, backDate);if (isBetween) {+ console.logdraggerPosition = Math.abs(frontDate.diff(draggerDateActual, timeScale, true) * gridWidth);if (this.props.compareModeActive || this.props.draggerSelected === 'selected') {draggerVisible = true;@@ -135,7 +132,7 @@ class TimelineAxis extends Component {draggerVisibleB = true;}}-+ console.log(draggerVisible, draggerVisibleB, draggerPosition, draggerDateActual, frontDate.format(), backDate)let position;// axisWidthInput conditional in place to handle resize centering of positionif (axisWidthInput) {@@ -177,151 +174,86 @@ class TimelineAxis extends Component {draggerPosition = draggerPosition - pixelsToAdd + position - this.state.draggerWidth;draggerPositionB = draggerPositionB - pixelsToAdd + position - this.state.draggerWidth;+ // let init = false;+ // if (this.state.init === true) {+ // init = false+ // }++ let updatePositioningArguments = {+ moved: false,+ isTimelineDragging: false,+ position,+ transformX,+ frontDate: timeRange[0].rawDate,+ backDate,+ draggerPosition,+ draggerPositionB,+ draggerVisible,+ draggerVisibleB,+ animationStartLocation,+ animationEndLocation+ };+this.setState({+ init: false,currentTimeRange: timeRange,gridNumber,gridWidth,numberOfVisibleTiles,- moved: false,dragSentinelChangeNumber,midPoint: position,dragSentinelCount: 0,leftBound,rightBound,wheelZoom: false- }, this.props.updateDynamicPositioning(false, position, transformX, timeRange[0].rawDate, backDate, draggerPosition, draggerPositionB, draggerVisible, draggerVisibleB, animationStartLocation, animationEndLocation));- }-- // changes timeScale state- wheelZoom = (e) => {- let { timeScale, hasSubdailyLayers, changeTimeScale } = this.props;- let timeScaleNumber = Number(timeScaleToNumberKey[timeScale]);- let maxTimeScaleNumber = hasSubdailyLayers ? 5 : 3;- if (e.deltaY > 0) { // wheel zoom out- if (timeScaleNumber > 1) {- this.setState({- wheelZoom: true- }, changeTimeScale(timeScaleNumber - 1));- }- } else {- if (timeScaleNumber < maxTimeScaleNumber) { // wheel zoom in- this.setState({- wheelZoom: true- }, changeTimeScale(timeScaleNumber + 1));- }- }+ }, this.props.updatePositioning(updatePositioningArguments));}- // drag axis - will update date range if dragged into past/future past dragSentinelChangeNumber- handleDrag = (e, d) => {- e.stopPropagation();- e.preventDefault();+ // return date array of days based on:+ // subtract - integer (negative numbers selects start date in the future)+ // add - integer (negative numbers selects end date in the past)+ getTimeRangeArray = (subtract, add, inputDate) => {let {- gridWidth,- dragSentinelChangeNumber,- dragSentinelCount- } = this.state;- let { timeScale, position, animationStartLocation, animationEndLocation, draggerPosition, draggerPositionB } = this.props;+ timelineEndDateLimit,+ timelineStartDateLimit,+ timeScale+ } = this.props;+ let dayZeroed;+ let startDate;+ let endDate;- let deltaX = d.deltaX;- position = position + deltaX;- draggerPosition = draggerPosition + deltaX;- draggerPositionB = draggerPositionB + deltaX;- animationStartLocation = animationStartLocation + deltaX;- animationEndLocation = animationEndLocation + deltaX;- // PRE/POST GRIDARRAY UPDATE NOT NECESSARY FOR YEAR SINCE ALL YEARS ARE DISPLAYEDif (timeScale === 'year') {- let frontDate = this.state.currentTimeRange[0].rawDate;- let backDate = this.state.currentTimeRange[this.state.currentTimeRange.length - 1].rawDate;- this.setState({- dragSentinelCount: dragSentinelCount + deltaX- }, this.props.updateDynamicPositioning(true, position, null, frontDate, backDate, draggerPosition, draggerPositionB, null, null, animationStartLocation, animationEndLocation));+ dayZeroed = moment.utc(inputDate).startOf('year');+ // let endLimitYear = moment.utc(timelineEndDateLimit).year() + 1;+ // let startLimitYear = moment.utc(timelineStartDateLimit).year();+ let endLimitYear = new Date(timelineEndDateLimit).getUTCFullYear() + 1;+ let startLimitYear = new Date(timelineStartDateLimit).getUTCFullYear();+ startDate = dayZeroed.year(startLimitYear);+ endDate = dayZeroed.clone().year(endLimitYear);} else {- if (deltaX > 0) { // dragging right - exposing past dates- if (dragSentinelCount + deltaX > dragSentinelChangeNumber) {- // handle over drag the necessitates multiple axis updates- let overDrag = 0;- if (dragSentinelCount + deltaX > dragSentinelChangeNumber * 2) {- overDrag = Math.abs(dragSentinelCount + deltaX - dragSentinelChangeNumber * 2);- }- let {- currentTimeRange,- transformX,- draggerVisible,- draggerVisibleB,- overDragGrids,- newDraggerPosition,- newDraggerPositionB- } = this.updatePanelDateRange(- position,- deltaX,- draggerPosition,- draggerPositionB,- overDrag- );-- let newDragSentinelCount = dragSentinelCount + deltaX - dragSentinelChangeNumber - overDragGrids * gridWidth;- let frontDate = currentTimeRange[0].rawDate;- let backDate = currentTimeRange[currentTimeRange.length - 1].rawDate;-- this.setState({- currentTimeRange,- dragSentinelCount: newDragSentinelCount- }, this.props.updateDynamicPositioning(true, position, transformX, frontDate, backDate, newDraggerPosition, newDraggerPositionB, draggerVisible, draggerVisibleB, animationStartLocation, animationEndLocation));- } else {- // reset dragSentinelCount on direction change to remaining distance to dragSentinelChangeNumber- let newDragSentinelCount = dragSentinelCount < 0- ? dragSentinelChangeNumber + dragSentinelCount + deltaX- : dragSentinelCount + deltaX;- this.setState({- dragSentinelCount: newDragSentinelCount- }, this.props.updateDynamicPositioning(true, position, null, null, null, draggerPosition, draggerPositionB, null, null, animationStartLocation, animationEndLocation));- }- } else if (deltaX < 0) { // dragging left - exposing future dates- if (dragSentinelCount + deltaX < -dragSentinelChangeNumber) {- // handle over drag the necessitates multiple axis updates- let overDrag = 0;- if (dragSentinelCount + deltaX < -dragSentinelChangeNumber * 2) {- overDrag = Math.abs(dragSentinelCount + deltaX + dragSentinelChangeNumber * 2);- }- let {- currentTimeRange,- transformX,- draggerVisible,- draggerVisibleB,- overDragGrids,- newDraggerPosition,- newDraggerPositionB- } = this.updatePanelDateRange(- position,- deltaX,- draggerPosition,- draggerPositionB,- overDrag- );-- let newDragSentinelCount = dragSentinelCount + deltaX + dragSentinelChangeNumber + overDragGrids * gridWidth;- let frontDate = currentTimeRange[0].rawDate;- let backDate = currentTimeRange[currentTimeRange.length - 1].rawDate;- this.setState({- currentTimeRange,- dragSentinelCount: newDragSentinelCount- }, this.props.updateDynamicPositioning(true, position, transformX, frontDate, backDate, newDraggerPosition, newDraggerPositionB, draggerVisible, draggerVisibleB, animationStartLocation, animationEndLocation));- } else {- // reset dragSentinelCount on direction change to remaining distance to dragSentinelChangeNumber- let newDragSentinelCount = dragSentinelCount > 0- ? -dragSentinelChangeNumber + dragSentinelCount + deltaX- : dragSentinelCount + deltaX;- this.setState({- dragSentinelCount: newDragSentinelCount- }, this.props.updateDynamicPositioning(true, position, null, null, null, draggerPosition, draggerPositionB, null, null, animationStartLocation, animationEndLocation));- }+ if (timeScale === 'month') {+ dayZeroed = moment.utc(inputDate).startOf('month');+ } else if (timeScale === 'day') {+ dayZeroed = moment.utc(inputDate).startOf('day');+ } else if (timeScale === 'hour') {+ dayZeroed = moment.utc(inputDate).startOf('hour');+ } else if (timeScale === 'minute') {+ dayZeroed = moment.utc(inputDate).startOf('minute');}+ startDate = dayZeroed.clone().subtract(subtract, timeScale);+ endDate = dayZeroed.clone().add(add, timeScale);}+ let timeRangeArray = getTimeRange(+ startDate,+ endDate,+ timeScale,+ timelineStartDateLimit,+ timelineEndDateLimit);+ return timeRangeArray;}// update dates in range based on dragging axis- updatePanelDateRange = (position, deltaX, draggerPosition, draggerPositionB, overDrag) => {+ updateTimeRangeFromDrag = (position, deltaX, draggerPosition, draggerPositionB, overDrag) => {let {gridWidth,currentTimeRange,@@ -371,8 +303,8 @@ class TimelineAxis extends Component {transform};- if (compareModeActive) {- // check if both draggers are in between for visibility/position updates+ // check selected dragger (or both if compare mode) for visibility and new position+ if (draggerSelected === 'selected' || compareModeActive) { // dragger A selectedlet draggerACheck = this.checkDraggerVisibility(draggerTimeState,draggerVisible,@@ -381,7 +313,9 @@ class TimelineAxis extends Component {);draggerVisible = draggerACheck.isVisible;newDraggerPosition = draggerACheck.newDraggerPosition;+ }+ if (draggerSelected === 'selectedB' || compareModeActive) { // dragger B selectedlet draggerBCheck = this.checkDraggerVisibility(draggerTimeStateB,draggerVisibleB,@@ -390,31 +324,10 @@ class TimelineAxis extends Component {);draggerVisibleB = draggerBCheck.isVisible;newDraggerPositionB = draggerBCheck.newDraggerPosition;- } else {- // check individual draggers based on which is currently selected- if (draggerSelected === 'selected') { // dragger A selected- let draggerACheck = this.checkDraggerVisibility(- draggerTimeState,- draggerVisible,- newDraggerPosition,- sharedDraggerVisibilityParams- );- draggerVisible = draggerACheck.isVisible;- newDraggerPosition = draggerACheck.newDraggerPosition;- } else { // dragger B selectedB- let draggerBCheck = this.checkDraggerVisibility(- draggerTimeStateB,- draggerVisibleB,- newDraggerPositionB,- sharedDraggerVisibilityParams- );- draggerVisibleB = draggerBCheck.isVisible;- newDraggerPositionB = draggerBCheck.newDraggerPosition;- }}return {- currentTimeRange: currentTimeRange,+ currentTimeRange,transformX: transform,draggerVisible,draggerVisibleB,@@ -429,199 +342,228 @@ class TimelineAxis extends Component {let { gridWidth } = this.state;let { timeScale } = this.props;let isBetween = getIsBetween(draggerTime, frontDate, backDate);- if (isBetween) { // B dragger+ if (isBetween) {if (draggerVisible === false) {let frontDateObj = moment.utc(frontDate);newDraggerPosition = Math.abs(frontDateObj.diff(draggerTime, timeScale, true) * gridWidth) + position + transform - 50;}return {- newDraggerPosition: newDraggerPosition,+ newDraggerPosition,isVisible: true};} else {return {- newDraggerPosition: newDraggerPosition,+ newDraggerPosition,isVisible: false};}}- // return date array of days based on:- // subtract - integer (negative numbers selects start date in the future)- // add - integer (negative numbers selects end date in the past)- getTimeRangeArray = (subtract, add, inputDate) => {- let dayZeroed;- let startDate;- let endDate;- let { timelineEndDateLimit, timelineStartDateLimit, timeScale } = this.props;+ componentDidMount() {+ // let axisWidth = this.props.axisWidth;+ // let timeScale = this.props.timeScale;+ // let timelineStartDateLimit = this.props.timelineStartDateLimit;+ // let timelineEndDateLimit = this.props.timelineEndDateLimit;++ // // get dateA time and relative from start/end limits+ // let time = this.props.draggerSelected === 'selected' ? this.props.dateA : this.props.dateB;+ // time = moment.utc(time);+ // let diffFromEndDateLimit = time.diff(timelineEndDateLimit, timeScale);+ // let diffFromStartDateLimit = time.diff(timelineStartDateLimit, timeScale);+ // // format to strings+ // time = time.format();++ // let draggerTimeStateB;+ // if (this.props.dateB) {+ // draggerTimeStateB = moment.utc(this.props.dateB).format();+ // }++ // // get timeScale specifics based on props+ // let options = timeScaleOptions[timeScale].timeAxis;+ // let gridWidth = options.gridWidth;++ // // calculate number of grids viewable based on axisWidth and gridWidth of timeScale+ // let numberOfVisibleTiles = Number((axisWidth / gridWidth).toFixed(8));+ // // let leftOffset = axisWidth * 0.90;+ // // let draggerPosition = tilesTillSelectedDAte * gridWidth - draggerWidth; //# CENTER DRAGGER A+ // let draggerVisible = true;+ // let draggerVisibleB = false;+ // if (this.props.compareModeActive) {+ // draggerVisibleB = true;+ // }++ // // times 1.5 is cutting it close (down to 1 grid at leading edge - will continue to test)+ // let gridNumber = Math.floor(numberOfVisibleTiles * 1.5);+ // let dragSentinelChangeNumber = gridWidth * (Math.floor(numberOfVisibleTiles * 0.25) + 1);++ // //! offset grids needed since each zoom in won't be centered+ // // let offSetGrids = Math.floor(leftOffset / gridWidth);+ // // let offSetGridsDiff = offSetGrids - Math.floor(numberOfVisibleTiles / 2);++ // // let gridsToSubtract = Math.floor(gridNumber/2) + offSetGridsDiff;+ // // let gridsToAdd = Math.floor(gridNumber/2) - offSetGridsDiff;++ // // get midPoint for position based on # of tiles and gridWidth+ // let midPoint = -((gridWidth * gridNumber) / 2) + (numberOfVisibleTiles / 2 * gridWidth);++ // let draggerTime = moment.utc(time);+ // // let draggerTimeZero = moment.utc(time).startOf(timeScale);+ // // let draggerTimeNextZero = moment.utc(draggerTime).startOf(timeScale).add(1, timeScale);++ // // let draggerTimeValue = moment.utc(draggerTime).valueOf();+ // // let draggerTimeZeroValue = moment.utc(draggerTimeZero).valueOf();+ // // let draggerTimeNextZeroValue = moment.utc(draggerTimeNextZero).valueOf();++ // // let diffZeroValues = draggerTimeNextZeroValue - draggerTimeZeroValue;+ // // let diffFactor = diffZeroValues / gridWidth;+ // // let diffStartAndZeroed = draggerTimeValue - draggerTimeZeroValue;++ // // handle date array creation+ // let timeRange = this.getTimeRangeArray(Math.floor(gridNumber / 2), Math.floor(gridNumber / 2), time);++ // let frontDate = moment.utc(timeRange[0].rawDate);+ // let draggerPosition = Math.abs(frontDate.diff(draggerTime, timeScale, true) * gridWidth);+ // let draggerPositionB = Math.abs(frontDate.diff(moment.utc(draggerTimeStateB), timeScale, true) * gridWidth);++ // // animation dragger positioning+ // let animationStartDraggerLocation;+ // let animationEndDraggerLocation;++ // if (this.props.animStartLocationDate) {+ // animationStartDraggerLocation = Math.abs(frontDate.diff(this.props.animStartLocationDate, timeScale, true) * gridWidth);+ // animationEndDraggerLocation = Math.abs(frontDate.diff(this.props.animEndLocationDate, timeScale, true) * gridWidth);+ // }++ // // get axis bounds+ // let leftBound = (diffFromEndDateLimit * gridWidth) + midPoint;+ // let rightBound = (diffFromStartDateLimit * gridWidth) + midPoint;++ // if (timeScale === 'year') {+ // leftBound = -midPoint * 10;+ // rightBound = midPoint * 10;+ // }++ // let animationStartLocation = animationStartDraggerLocation + midPoint;+ // let animationEndLocation = animationEndDraggerLocation + midPoint;++ // this.setState({+ // // init: true,+ // // numberOfVisibleTiles: numberOfVisibleTiles,+ // // dragSentinelChangeNumber: dragSentinelChangeNumber,+ // // currentTimeRange: timeRange,+ // // gridWidth,+ // // hoverTime: time,+ // // midPoint,+ // // leftBound,+ // // rightBound++ // }, function() {+ // this.updateScale(time, timeScale, this.props.axisWidth, 0.80);+ // });+ let time = this.props.draggerSelected === 'selected' ? this.props.dateA : this.props.dateB;+ this.updateScale(time, this.props.timeScale, this.props.axisWidth, 0.80);+ }- if (timeScale === 'year') {- dayZeroed = moment.utc(inputDate).startOf('year');- let endLimitYear = moment.utc(timelineEndDateLimit).year() + 1;- let startLimitYear = moment.utc(timelineStartDateLimit).year();- startDate = dayZeroed.year(startLimitYear);- endDate = dayZeroed.clone().year(endLimitYear);- } else {- if (timeScale === 'month') {- dayZeroed = moment.utc(inputDate).startOf('month');- } else if (timeScale === 'day') {- dayZeroed = moment.utc(inputDate).startOf('day');- } else if (timeScale === 'hour') {- dayZeroed = moment.utc(inputDate).startOf('hour');- } else if (timeScale === 'minute') {- dayZeroed = moment.utc(inputDate).startOf('minute');- }- startDate = dayZeroed.clone().subtract(subtract, timeScale);- endDate = dayZeroed.clone().add(add, timeScale);- }- let timeRangeArray = getTimeRange(- startDate,- endDate,+ componentDidUpdate(prevProps, prevState) {+ let {+ dateA,+ dateB,+ draggerSelected,+ isDraggerDragging,timeScale,- timelineStartDateLimit,- timelineEndDateLimit);- return timeRangeArray;- }+ axisWidth,+ compareModeActive,+ draggerTimeState,+ draggerTimeStateB,+ hasSubdailyLayers+ } = this.props;- // move dragger on axis click- setLineTime = (e) => {- e.preventDefault();- e.stopPropagation();- if (e.target.className.animVal !== 'grid') {- return;+ // update timescale axis focus+ if (timeScale !== prevProps.timeScale) {+ let draggerDate;+ let leftOffset;+ if (this.state.wheelZoom === true) {+ draggerDate = this.props.hoverTime;+ } else {+ leftOffset = 0.75;+ if (draggerSelected === 'selected') {+ draggerDate = draggerTimeState;+ } else {+ draggerDate = draggerTimeStateB;+ }+ }+ this.updateScale(draggerDate, timeScale, null, leftOffset, true);}- if (!this.state.isAnimationDraggerDragging && !this.state.moved) {- let {- currentTimeRange- } = this.state;- let {- compareModeActive,- draggerSelected,- draggerTimeState,- draggerTimeStateB,- hoverTime- } = this.props;-- // check if the other dragger visible after clicking and moving then new dragger- let draggerB = draggerSelected === 'selectedB';-- // get front and back dates- let frontDate = currentTimeRange[0].rawDate;- let backDate = currentTimeRange[currentTimeRange.length - 1].rawDate;- if (draggerB) {- // check Dragger A visibility and then update Dragger B- let draggerAVisible = compareModeActive && getIsBetween(draggerTimeState, frontDate, backDate);- this.props.updateDraggerDatePosition(hoverTime, 'selectedB', null, true, draggerAVisible, false);+ // update axis on browser width change+ if (axisWidth !== prevProps.axisWidth) {+ let draggerDate;+ if (draggerSelected === 'selected') {+ draggerDate = draggerTimeState;} else {- // check Dragger B visibility and then update Dragger A- let draggerBVisible = compareModeActive && getIsBetween(draggerTimeStateB, frontDate, backDate);- this.props.updateDraggerDatePosition(hoverTime, 'selected', null, true, draggerBVisible, false);+ draggerDate = draggerTimeStateB;}+ this.updateScale(draggerDate, timeScale, axisWidth);}- }- componentDidMount() {- let axisWidth = this.props.axisWidth;- let timeScale = this.props.timeScale;- let timelineStartDateLimit = this.props.timelineStartDateLimit;- let timelineEndDateLimit = this.props.timelineEndDateLimit;-- // get dateA time and relative from start/end limits- let time = this.props.draggerSelected === 'selected' ? this.props.dateA : this.props.dateB;- time = moment.utc(time);- let diffFromEndDateLimit = time.diff(timelineEndDateLimit, timeScale);- let diffFromStartDateLimit = time.diff(timelineStartDateLimit, timeScale);- // format to strings- time = time.format();-- let draggerTimeStateB;- if (this.props.dateB) {- draggerTimeStateB = moment.utc(this.props.dateB).format();- }-- // get timeScale specifics based on props- let options = timeScaleOptions[timeScale].timeAxis;- let gridWidth = options.gridWidth;-- // calculate number of grids viewable based on axisWidth and gridWidth of timeScale- let numberOfVisibleTiles = Number((axisWidth / gridWidth).toFixed(8));- // let leftOffset = axisWidth * 0.90;- // let draggerPosition = tilesTillSelectedDAte * gridWidth - draggerWidth; //# CENTER DRAGGER A- let draggerVisible = true;- let draggerVisibleB = false;- if (this.props.compareModeActive) {- draggerVisibleB = true;- }-- // times 1.5 is cutting it close (down to 1 grid at leading edge - will continue to test)- let gridNumber = Math.floor(numberOfVisibleTiles * 1.5);- let dragSentinelChangeNumber = gridWidth * (Math.floor(numberOfVisibleTiles * 0.25) + 1);-- //! offset grids needed since each zoom in won't be centered- // let offSetGrids = Math.floor(leftOffset / gridWidth);- // let offSetGridsDiff = offSetGrids - Math.floor(numberOfVisibleTiles / 2);-- // let gridsToSubtract = Math.floor(gridNumber/2) + offSetGridsDiff;- // let gridsToAdd = Math.floor(gridNumber/2) - offSetGridsDiff;-- // get midPoint for position based on # of tiles and gridWidth- let midPoint = -((gridWidth * gridNumber) / 2) + (numberOfVisibleTiles / 2 * gridWidth);-- let draggerTime = moment.utc(time);- // let draggerTimeZero = moment.utc(time).startOf(timeScale);- // let draggerTimeNextZero = moment.utc(draggerTime).startOf(timeScale).add(1, timeScale);-- // let draggerTimeValue = moment.utc(draggerTime).valueOf();- // let draggerTimeZeroValue = moment.utc(draggerTimeZero).valueOf();- // let draggerTimeNextZeroValue = moment.utc(draggerTimeNextZero).valueOf();-- // let diffZeroValues = draggerTimeNextZeroValue - draggerTimeZeroValue;- // let diffFactor = diffZeroValues / gridWidth;- // let diffStartAndZeroed = draggerTimeValue - draggerTimeZeroValue;+ // if (compareModeActive !== prevProps.compareModeActive) {+ // // TURN ON COMPARE MODE+ // if (compareModeActive) {+ // this.updateScale(draggerDate, timeScale, axisWidth);+ // } else {+ // // TURN OFF COMPARE MODE+ // if (draggerSelected === 'selected') {+ // this.props.setDraggerVisibility(true, false);+ // // this.setState({+ // // draggerVisibleB: false+ // // });+ // } else {+ // this.props.setDraggerVisibility(false, true);+ // // this.setState({+ // // draggerVisible: false+ // // });+ // }+ // }+ // }- // handle date array creation- let timeRange = this.getTimeRangeArray(Math.floor(gridNumber / 2), Math.floor(gridNumber / 2), time);-- let frontDate = moment.utc(timeRange[0].rawDate);- let draggerPosition = Math.abs(frontDate.diff(draggerTime, timeScale, true) * gridWidth);- let draggerPositionB = Math.abs(frontDate.diff(moment.utc(draggerTimeStateB), timeScale, true) * gridWidth);-- // animation dragger positioning- let animationStartDraggerLocation;- let animationEndDraggerLocation;-- if (this.props.animStartLocationDate) {- animationStartDraggerLocation = Math.abs(frontDate.diff(this.props.animStartLocationDate, timeScale, true) * gridWidth);- animationEndDraggerLocation = Math.abs(frontDate.diff(this.props.animEndLocationDate, timeScale, true) * gridWidth);+ // handle switching A/B dragger axis focus if switched from A/B sidebar tabs+ if (compareModeActive && (draggerSelected !== prevProps.draggerSelected)) {+ if (draggerSelected === 'selected') {+ let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateA);+ if (!draggerCheck.withinRange) {+ this.updateScaleWithOffset(dateA, timeScale, draggerCheck);+ }+ } else {+ let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateB, true);+ if (!draggerCheck.withinRange) {+ this.updateScaleWithOffset(dateB, timeScale, draggerCheck);+ }+ }}- // get axis bounds- let leftBound = (diffFromEndDateLimit * gridWidth) + midPoint;- let rightBound = (diffFromStartDateLimit * gridWidth) + midPoint;+ if (!isDraggerDragging) {+ // handle A dragger change+ if (draggerTimeState !== dateA) {+ // check if draggerCheck will be within acceptable visible axis width+ let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateA);+ if (draggerCheck.withinRange) {+ // this.setDraggerToTime(dateA);+ } else {+ this.updateScaleWithOffset(dateA, timeScale, draggerCheck);+ }+ }- if (timeScale === 'year') {- leftBound = -midPoint * 10;- rightBound = midPoint * 10;+ // handle B dragger change+ if (draggerTimeStateB !== dateB) {+ // check if draggerCheck will be within acceptable visible axis width+ let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateB, true);+ if (draggerCheck.withinRange) {+ // this.setDraggerToTime(dateB, true);+ } else {+ this.updateScaleWithOffset(dateB, timeScale, draggerCheck);+ }+ }}-- let animationStartLocation = animationStartDraggerLocation + midPoint;- let animationEndLocation = animationEndDraggerLocation + midPoint;-- this.setState({- init: true,- numberOfVisibleTiles: numberOfVisibleTiles,- dragSentinelChangeNumber: dragSentinelChangeNumber,- currentTimeRange: timeRange,- gridWidth,- hoverTime: time,- midPoint,- leftBound,- rightBound-- }, function() {- this.updateScale(time, timeScale, this.props.axisWidth, 0.80);- });}/**@@ -665,94 +607,292 @@ class TimelineAxis extends Component {};}- componentDidUpdate(prevProps, prevState) {- let {- dateA,- dateB,- draggerSelected,- isDraggerDragging,- timeScale,- axisWidth,- compareModeActive,- draggerTimeState,- draggerTimeStateB- } = this.props;+ // update scale leftOffset helper+ updateScaleWithOffset = (date, timeScale, draggerCheck) => {+ let leftOffsetFixedCoeff = draggerCheck.newDraggerDiff > 5 ? 0.5 : draggerCheck.newDateInThePast ? 0.25 : 0.75;+ this.updateScale(date, timeScale, null, leftOffsetFixedCoeff);+ }- // update timescale axis focus- if (timeScale !== prevProps.timeScale) {- let draggerDate;- let leftOffset;- if (this.state.wheelZoom === true) {- draggerDate = this.state.hoverTime;- } else {- leftOffset = 0.90;- if (draggerSelected === 'selected') {- draggerDate = draggerTimeState;- } else {- draggerDate = draggerTimeStateB;- }+ // #### Drag/mouse handlers ####+ // changes timeScale state+ wheelZoom = (e) => {+ let { timeScale, hasSubdailyLayers, changeTimeScale } = this.props;+ let timeScaleNumber = Number(timeScaleToNumberKey[timeScale]);+ let maxTimeScaleNumber = hasSubdailyLayers ? 5 : 3;+ if (e.deltaY > 0) { // wheel zoom out+ if (timeScaleNumber > 1) {+ this.setState({+ wheelZoom: true+ }, changeTimeScale(timeScaleNumber - 1));+ }+ } else {+ if (timeScaleNumber < maxTimeScaleNumber) { // wheel zoom in+ this.setState({+ wheelZoom: true+ }, changeTimeScale(timeScaleNumber + 1));}- this.updateScale(draggerDate, timeScale, null, leftOffset, true);}+ }- // update axis on browser width change- if (axisWidth !== prevProps.axisWidth) {- this.updateScale(null, timeScale, axisWidth);+ // set mouseDown to handle over dragging range-select and triggering false axis click+ handleMouseDown = () => {+ this.setState({+ mouseDown: true+ });+ }++ // move dragger on axis click+ setLineTime = (e) => {+ e.preventDefault();+ e.stopPropagation();+ if (e.target.className.animVal !== 'grid') {+ return;}+ if (!this.props.isAnimationDraggerDragging && !this.props.moved && this.state.mouseDown) {+ let {+ currentTimeRange+ } = this.state;+ let {+ compareModeActive,+ draggerSelected,+ draggerTimeState,+ draggerTimeStateB,+ hoverTime+ } = this.props;- // handle switching A/B dragger axis focus if switched from A/B sidebar tabs- if (compareModeActive && (draggerSelected !== prevProps.draggerSelected)) {+ // get front and back dates+ let frontDate = currentTimeRange[0].rawDate;+ let backDate = currentTimeRange[currentTimeRange.length - 1].rawDate;++ let otherDraggerVisible;if (draggerSelected === 'selected') {- let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateA);- if (!draggerCheck.withinRange) {- this.updateScaleWithOffset(dateA, timeScale, draggerCheck);- }+ // check Dragger B visibility and then update Dragger A+ otherDraggerVisible = compareModeActive && getIsBetween(draggerTimeStateB, frontDate, backDate);} else {- let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateB, true);- if (!draggerCheck.withinRange) {- this.updateScaleWithOffset(dateB, timeScale, draggerCheck);- }+ // check Dragger A visibility and then update Dragger B+ otherDraggerVisible = compareModeActive && getIsBetween(draggerTimeState, frontDate, backDate);}+ this.props.updateDraggerDatePosition(hoverTime, draggerSelected, null, true, otherDraggerVisible, false);+ this.setState({+ mouseDown: false+ });}+ }- if (!isDraggerDragging) {- // handle A dragger change- if (draggerTimeState !== dateA) {- // check if draggerCheck will be within acceptable visible axis width- let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateA);- if (draggerCheck.withinRange) {- // this.setDraggerToTime(dateA);+ // handle start drag of axis+ handleStartDrag = () => {+ this.setState({+ isTimelineDragging: true+ });+ }++ // drag axis - will update date range if dragged into past/future past dragSentinelChangeNumber+ handleDrag = (e, d) => {+ e.stopPropagation();+ e.preventDefault();+ let {+ gridWidth,+ dragSentinelChangeNumber,+ dragSentinelCount+ } = this.state;+ let {+ timeScale,+ position,+ animationStartLocation,+ animationEndLocation,+ draggerPosition,+ draggerPositionB+ } = this.props;++ let deltaX = d.deltaX;+ position = position + deltaX;+ draggerPosition = draggerPosition + deltaX;+ draggerPositionB = draggerPositionB + deltaX;+ animationStartLocation = animationStartLocation + deltaX;+ animationEndLocation = animationEndLocation + deltaX;+ // PRE/POST GRIDARRAY UPDATE NOT NECESSARY FOR YEAR SINCE ALL YEARS ARE DISPLAYED+ if (timeScale === 'year') {+ let frontDate = this.state.currentTimeRange[0].rawDate;+ let backDate = this.state.currentTimeRange[this.state.currentTimeRange.length - 1].rawDate;+ let updatePositioningArguments = {+ moved: true,+ isTimelineDragging: true,+ position,+ transformX: this.props.transformX,+ frontDate,+ backDate,+ draggerPosition,+ draggerPositionB,+ draggerVisible: this.props.draggerVisible,+ draggerVisibleB: this.props.draggerVisibleB,+ animationStartLocation,+ animationEndLocation+ };+ // this.setState({+ // dragSentinelCount: dragSentinelCount + deltaX+ // }, this.props.updatePositioning(updatePositioningArguments));+ this.setState({+ dragSentinelCount: dragSentinelCount + deltaX+ });+ this.props.updatePositioning(updatePositioningArguments);+ } else {+ if (deltaX > 0) { // dragging right - exposing past dates+ if (dragSentinelCount + deltaX > dragSentinelChangeNumber) {+ // handle over drag the necessitates multiple axis updates+ let overDrag = 0;+ if (dragSentinelCount + deltaX > dragSentinelChangeNumber * 2) {+ overDrag = Math.abs(dragSentinelCount + deltaX - dragSentinelChangeNumber * 2);+ }+ let {+ currentTimeRange,+ transformX,+ draggerVisible,+ draggerVisibleB,+ overDragGrids,+ newDraggerPosition,+ newDraggerPositionB+ } = this.updateTimeRangeFromDrag(+ position,+ deltaX,+ draggerPosition,+ draggerPositionB,+ overDrag+ );++ let newDragSentinelCount = dragSentinelCount + deltaX - dragSentinelChangeNumber - overDragGrids * gridWidth;+ let frontDate = currentTimeRange[0].rawDate;+ let backDate = currentTimeRange[currentTimeRange.length - 1].rawDate;+ let updatePositioningArguments = {+ moved: true,+ isTimelineDragging: true,+ position,+ transformX,+ frontDate,+ backDate,+ draggerPosition: newDraggerPosition,+ draggerPositionB: newDraggerPositionB,+ draggerVisible,+ draggerVisibleB,+ animationStartLocation,+ animationEndLocation+ };+ // this.setState({+ // currentTimeRange,+ // dragSentinelCount: newDragSentinelCount+ // }, this.props.updatePositioning(updatePositioningArguments));+ this.setState({+ currentTimeRange,+ dragSentinelCount: newDragSentinelCount+ });+ this.props.updatePositioning(updatePositioningArguments);} else {- this.updateScaleWithOffset(dateA, timeScale, draggerCheck);+ // reset dragSentinelCount on direction change to remaining distance to dragSentinelChangeNumber+ let newDragSentinelCount = dragSentinelCount < 0+ ? dragSentinelChangeNumber + dragSentinelCount + deltaX+ : dragSentinelCount + deltaX;+ let updatePositioningArguments = {+ moved: 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.setState({+ dragSentinelCount: newDragSentinelCount+ });+ this.props.updatePositioning(updatePositioningArguments);}- }+ } else if (deltaX < 0) { // dragging left - exposing future dates+ if (dragSentinelCount + deltaX < -dragSentinelChangeNumber) {+ // handle over drag the necessitates multiple axis updates+ let overDrag = 0;+ if (dragSentinelCount + deltaX < -dragSentinelChangeNumber * 2) {+ overDrag = Math.abs(dragSentinelCount + deltaX + dragSentinelChangeNumber * 2);+ }+ let {+ currentTimeRange,+ transformX,+ draggerVisible,+ draggerVisibleB,+ overDragGrids,+ newDraggerPosition,+ newDraggerPositionB+ } = this.updateTimeRangeFromDrag(+ position,+ deltaX,+ draggerPosition,+ draggerPositionB,+ overDrag+ );- // handle B dragger change- if (draggerTimeStateB !== dateB) {- // check if draggerCheck will be within acceptable visible axis width- let draggerCheck = this.checkDraggerMoveOrUpdateScale(dateB, true);- if (draggerCheck.withinRange) {- // this.setDraggerToTime(dateB, true);+ let newDragSentinelCount = dragSentinelCount + deltaX + dragSentinelChangeNumber + overDragGrids * gridWidth;+ let frontDate = currentTimeRange[0].rawDate;+ let backDate = currentTimeRange[currentTimeRange.length - 1].rawDate;+ let updatePositioningArguments = {+ moved: true,+ isTimelineDragging: true,+ position,+ transformX,+ frontDate,+ backDate,+ draggerPosition: newDraggerPosition,+ draggerPositionB: newDraggerPositionB,+ draggerVisible,+ draggerVisibleB,+ animationStartLocation,+ animationEndLocation+ };+ // this.setState({+ // currentTimeRange,+ // dragSentinelCount: newDragSentinelCount+ // }, this.props.updatePositioning(updatePositioningArguments));+ this.setState({+ currentTimeRange,+ dragSentinelCount: newDragSentinelCount+ });+ this.props.updatePositioning(updatePositioningArguments);} else {- this.updateScaleWithOffset(dateB, timeScale, draggerCheck);+ // reset dragSentinelCount on direction change to remaining distance to dragSentinelChangeNumber+ let newDragSentinelCount = dragSentinelCount > 0+ ? -dragSentinelChangeNumber + dragSentinelCount + deltaX+ : dragSentinelCount + deltaX;+ let updatePositioningArguments = {+ moved: 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.setState({+ dragSentinelCount: newDragSentinelCount+ });+ this.props.updatePositioning(updatePositioningArguments);}}}}- // update scale leftOffset helper- updateScaleWithOffset = (date, timeScale, draggerCheck) => {- let leftOffsetFixedCoeff = draggerCheck.newDraggerDiff > 5 ? 0.5 : draggerCheck.newDateInThePast ? 0.25 : 0.75;- this.updateScale(date, timeScale, null, leftOffsetFixedCoeff);- }-- // handle start drag of axis- handleStartDrag = () => {- this.setState({- isTimelineDragging: true- });- }-// handle stop drag of axis// moved === false means an axis clickhandleStopDrag = (e, d) => {@@ -783,16 +923,33 @@ class TimelineAxis extends Component {}transformX = transformX + position;-+ let updatePositioningArguments = {+ moved,+ 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+ };+ // this.setState({+ // leftBound,+ // rightBound+ // }, this.props.updatePositioning(updatePositioningArguments));this.setState({leftBound,- rightBound,- moved: moved- }, this.props.updateDynamicPositioning(false, midPoint, transformX));+ rightBound+ });+ this.props.updatePositioning(updatePositioningArguments);}shouldComponentUpdate(nextProps, nextState) {- if (this.state.init === false) {+ if (this.state.init === true) {return true;} else {let {@@ -805,7 +962,9 @@ class TimelineAxis extends Component {hasSubdailyLayers,parentOffset,timelineEndDateLimit,- transformX+ transformX,+ frontDate,+ backDate} = this.props;let checkForPropsUpdates = (@@ -818,7 +977,9 @@ class TimelineAxis extends Component {nextProps.hasSubdailyLayers === hasSubdailyLayers &&nextProps.parentOffset === parentOffset &&nextProps.timelineEndDateLimit === timelineEndDateLimit &&- nextProps.transformX === transformX+ nextProps.transformX === transformX &&+ nextProps.frontDate === frontDate &&+ nextProps.backDate === backDate);let {@@ -829,13 +990,13 @@ class TimelineAxis extends Component {gridWidth,// hoverLinePosition,// hoverTime,- isAnimationDraggerDragging,- isDraggerDragging,- isTimelineDragging,+ // isAnimationDraggerDragging,+ // isDraggerDragging,+ // isTimelineDragging,leftBound,// leftOffset,midPoint,- moved,+ // moved,numberOfVisibleTiles,rightBound,// showDraggerTime,@@ -849,22 +1010,15 @@ class TimelineAxis extends Component {dragSentinelCount === nextState.dragSentinelCount &&gridNumber === nextState.gridNumber &&gridWidth === nextState.gridWidth &&- // hoverLinePosition === nextState.hoverLinePosition &&- // hoverTime === nextState.hoverTime &&- isAnimationDraggerDragging === nextState.isAnimationDraggerDragging &&- isDraggerDragging === nextState.isDraggerDragging &&- isTimelineDragging === nextState.isTimelineDragging &&leftBound === nextState.leftBound &&- // leftOffset === nextState.leftOffset &&midPoint === nextState.midPoint &&- moved === nextState.moved &&+ // moved === nextState.moved &&numberOfVisibleTiles === nextState.numberOfVisibleTiles &&rightBound === nextState.rightBound &&- // showDraggerTime === nextState.showDraggerTime &&- // showHoverLine === nextState.showHoverLine &&wheelZoom === nextState.wheelZoom);+if (checkForPropsUpdates && checkForStateUpdates) {return false;}@@ -893,6 +1047,7 @@ class TimelineAxis extends Component {<React.Fragment><div id='wv-timeline-axis'style={{ width: `${axisWidth}px` }}+ onMouseDown={this.handleMouseDown}onMouseUp={this.setLineTime}onWheel={this.wheelZoom}onMouseOver={this.props.showHoverOn}@@ -947,7 +1102,6 @@ TimelineAxis.propTypes = {animEndLocationDate: PropTypes.object,animStartLocationDate: PropTypes.object,axisWidth: PropTypes.number,- changeDate: PropTypes.func,changeTimeScale: PropTypes.func,compareModeActive: PropTypes.bool,draggerSelected: PropTypes.string,diff --git a/web/js/components/timeline/timeline-controls/axis-timescale-change.js b/web/js/components/timeline/timeline-controls/axis-timescale-change.jsindex 9bc2a5b76..2a432029f 100644--- a/web/js/components/timeline/timeline-controls/axis-timescale-change.js+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change.js@@ -20,10 +20,12 @@ class AxisTimeScaleChange extends PureComponent {// TimeScale select tooltip ontoolTipHoverOn = () => {- this.disableMapScales(true);- this.setState({- toolTipHovered: true- });+ if (!this.props.isDraggerDragging) { // in event of dragging off axis, prevent tooltip display+ this.disableMapScales(true);+ this.setState({+ toolTipHovered: true+ });+ }}// TimeScale select tooltip off@@ -109,7 +111,9 @@ class AxisTimeScaleChange extends PureComponent {AxisTimeScaleChange.propTypes = {timeScale: PropTypes.string,changeTimeScale: PropTypes.func,- hasSubdailyLayers: PropTypes.bool+ hasSubdailyLayers: PropTypes.bool,+ isDraggerDragging: PropTypes.bool,+ timelineHidden: PropTypes.bool};export default AxisTimeScaleChange;diff --git a/web/js/components/timeline/timeline.css b/web/js/components/timeline/timeline.cssindex 200e3471e..85df3d6b7 100644--- a/web/js/components/timeline/timeline.css+++ b/web/js/components/timeline/timeline.css@@ -280,11 +280,12 @@ line {pointer-events: all;}-.hover-line-container {+.timeline-hover-line-container {position: absolute;bottom: -87px;pointer-events: none;}-.svgLine {+.timeline-hover-line {+ display: 'block';}\ No newline at end of filediff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 47ff7c755..03ba6d221 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -61,6 +61,7 @@ class Timeline extends React.Component {constructor(props) {super(props);this.state = {+ initialLoadComplete: false,timelineHidden: false,customIntervalModalOpen: false,animationInProcess: false,@@ -86,12 +87,17 @@ class Timeline extends React.Component {isDraggerDragging: false,leftOffset: 0,isAnimationDraggerDragging: false,- isTimelineDragging: false+ isTimelineDragging: false,+ rangeSelectorMax: { end: false, start: false, startOffset: -50, width: 50000 }};// left/right arrowsthis.animator = 0;this.debounceDateUpdate = lodashDebounce(this.props.changeDate, 50);- this.debounceAnimationUpdate = lodashDebounce(this.props.changeStartAndEndDate, 30);++ // animation dragger updates+ this.debounceOnUpdateStartDate = lodashDebounce(this.props.onUpdateStartDate, 30);+ this.debounceOnUpdateEndDate = lodashDebounce(this.props.onUpdateEndDate, 30);+ this.debounceOnUpdateStartAndEndDate = lodashDebounce(this.props.onUpdateStartAndEndDate, 30);}// ! HOVER TIME@@ -107,7 +113,7 @@ class Timeline extends React.Component {// show hover lineshowHoverOn = (e) => {- if (!this.state.isAnimationDraggerDragging && !this.state.showDraggerTime) {+ if (!this.state.isAnimationDraggerDragging && !this.state.showDraggerTime && !this.state.isTimelineDragging) {if (e.target.className.animVal === 'grid') {if (this.state.showHoverLine !== true) {this.setState({@@ -173,7 +179,9 @@ class Timeline extends React.Component {});}- updateDynamicPositioning = (+ // handles dynamic position changes from axis that affect dragger and range select+ updatePositioning = ({+ moved,isTimelineDragging,position,transformX,@@ -184,22 +192,28 @@ class Timeline extends React.Component {draggerVisible,draggerVisibleB,animationStartLocation,- animationEndLocation) => {+ animationEndLocation+ }) => {this.setState({+ moved,isTimelineDragging,showHoverLine: false,position,- transformX: transformX || this.state.transformX,- frontDate: frontDate || this.state.frontDate,- backDate: backDate || this.state.backDate,- draggerPosition: draggerPosition || this.state.draggerPosition,- draggerPositionB: draggerPositionB || this.state.draggerPositionB,- draggerVisible: draggerVisible || this.state.draggerVisible,- draggerVisibleB: draggerVisibleB || this.state.draggerVisibleB,- animationStartLocation: animationStartLocation || this.state.animationStartLocation,- animationEndLocation: animationEndLocation || this.state.animationEndLocation+ transformX,+ frontDate,+ backDate,+ draggerPosition,+ draggerPositionB,+ draggerVisible,+ draggerVisibleB,+ animationStartLocation,+ animationEndLocation});}+<<<<<<< HEAD+=======++>>>>>>> fix anim date inputs, continue large refactor and clean up/*** Clear animateByIncrement's Timeout*@@ -224,23 +238,15 @@ class Timeline extends React.Component {* @return {void}*/animateByIncrement = (delta, increment) => {- const { endTime, startDate, hasSubdailyLayers, changeDate } = this.props;+ const {+ endTime,+ startDate+ } = this.props;let animate = () => {- var nextTime = getNextTimeSelection(- delta,- increment,- this.props.selectedDate- );- if (hasSubdailyLayers) {- // can we remove this logic?- if (new Date(startDate) <= nextTime && nextTime <= endTime) {- changeDate(util.dateAdd(this.props.selectedDate, increment, delta));- }- } else {- if (new Date(startDate) <= nextTime && nextTime <= endTime) {- changeDate(util.dateAdd(this.props.selectedDate, increment, delta));- }+ var nextTime = getNextTimeSelection(delta, increment, this.props.selectedDate);+ if (new Date(startDate) <= nextTime && nextTime <= endTime) {+ this.changeDate(util.dateAdd(this.props.selectedDate, increment, delta));}if (this.state.animationInProcess) {this.animator = setInterval(() => animate, ANIMATION_DELAY);@@ -361,24 +367,24 @@ class Timeline extends React.Component {animationEndLocationDate: animationEndLocationDate,isAnimationDraggerDragging: isDragging});- this.debounceAnimationUpdate(animationStartLocationDate, animationEndLocationDate);+ this.determineAnimationDraggerUpdate(animationStartLocationDate, animationEndLocationDate);}- // determineNecessaryAnimationDraggerUpdate = (animationStartLocationDate, animationEndLocationDate) => {- // let startChanged = this.props.animationStartLocationDate !== animationStartLocationDate;- // let endChanged = this.props.animationEndLocationDate !== animationEndLocationDate;- // if (startChanged) {- // if (endChanged) {- // this.props.changeStartAndEndDate(animationStartLocationDate, animationEndLocationDate);- // } else {- // this.props.changeStartDate(animationStartLocationDate);- // }- // } else {- // if (endChanged) {- // this.props.changeEndDate(animationEndLocationDate);- // }- // }- // }+ determineAnimationDraggerUpdate = (animationStartLocationDate, animationEndLocationDate) => {+ let startChanged = this.props.animationStartLocationDate !== animationStartLocationDate;+ let endChanged = this.props.animationEndLocationDate !== animationEndLocationDate;+ if (startChanged) {+ if (endChanged) {+ this.debounceOnUpdateStartAndEndDate(animationStartLocationDate, animationEndLocationDate);+ } else {+ this.debounceOnUpdateStartDate(animationStartLocationDate);+ }+ } else {+ if (endChanged) {+ this.debounceOnUpdateEndDate(animationEndLocationDate);+ }+ }+ }// handle animation dragger location update and state updateanimationDraggerDateUpdate = (animationStartLocationDate, animationEndLocationDate) => {@@ -397,12 +403,11 @@ class Timeline extends React.Component {animationStartLocationDate: animationStartLocationDate,animationEndLocationDate: animationEndLocationDate});- this.debounceAnimationUpdate(animationStartLocationDate, animationEndLocationDate);+ this.debounceOnUpdateStartAndEndDate(animationStartLocationDate, animationEndLocationDate);}// ! DRAGGERupdateDraggerDatePosition = (newDraggerDate, draggerSelected, draggerPosition, draggerVisible, otherDraggerVisible, moved) => {- console.log(newDraggerDate, draggerSelected, draggerPosition, draggerVisible, otherDraggerVisible)if (draggerSelected === 'selected') {this.setState({draggerPosition: draggerPosition || this.state.draggerPosition,@@ -411,9 +416,8 @@ class Timeline extends React.Component {draggerTimeState: newDraggerDate || this.state.draggerTimeState,moved: moved || this.state.moved});- // this.props.changeDate(new Date(newDraggerDate), 'selected');if (newDraggerDate) {- this.debounceDateUpdate(new Date(newDraggerDate), 'selected');+ this.changeDate(newDraggerDate, 'selected');}} else {this.setState({@@ -423,17 +427,16 @@ class Timeline extends React.Component {draggerTimeStateB: newDraggerDate || this.state.draggerTimeStateB,moved: moved || this.state.moved});- // this.props.changeDate(new Date(newDraggerDate), 'selectedB');if (newDraggerDate) {- this.debounceDateUpdate(new Date(newDraggerDate), 'selectedB');+ this.changeDate(newDraggerDate, 'selectedB');}}}setDraggerVisibility = (draggerVisible, draggerVisibleB) => {this.setState({- draggerVisible: draggerVisible,- draggerVisibleB: draggerVisibleB+ draggerVisible,+ draggerVisibleB});}@@ -448,7 +451,8 @@ class Timeline extends React.Component {this.animationDraggerDateUpdate(animStartLocationDate, animEndLocationDate);}}- // console.log(this.props.dateA, this.state.draggerTimeState)++ // handle draggerTimeState updates if date changesif (this.props.dateA !== prevProps.dateA && this.props.dateA !== this.state.draggerTimeState) {this.setState({draggerTimeState: this.props.dateA@@ -464,27 +468,22 @@ class Timeline extends React.Component {componentDidMount() {document.addEventListener('keydown', this.handleKeyDown);document.addEventListener('keyup', this.handleKeyUp);+ this.setInitialState();+ }+ setInitialState = () => {this.setState({animationStartLocationDate: this.props.animStartLocationDate,animationEndLocationDate: this.props.animEndLocationDate,draggerTimeState: this.props.dateA,- draggerTimeStateB: this.props.dateB+ draggerTimeStateB: this.props.dateB,+ hoverTime: this.props.dateA,+ initialLoadComplete: true});}- updateStateAndChangeDate = (date) => {- if (this.state.draggerSelected === 'selected') {- // this.setState({- // draggerTimeState: date- // });- this.debounceDateUpdate(new Date(date), 'selected');- } else {- // this.setState({- // draggerTimeStateB: date- // });- this.debounceDateUpdate(new Date(date), 'selectedB');- }+ changeDate = (date, draggerSelected = this.state.draggerSelected) => {+ this.debounceDateUpdate(new Date(date), draggerSelected);}render() {@@ -511,7 +510,7 @@ class Timeline extends React.Component {hideTimeline,timeScale} = this.props;- return dateA ? (+ return this.state.initialLoadComplete ? (<ErrorBoundary><section id="timeline" className="timeline-inner clearfix"><div id="timeline-header"@@ -520,7 +519,7 @@ class Timeline extends React.Component {<div id="date-selector-main"><DateSelector// onDateChange={this.props.changeDate}- onDateChange={this.updateStateAndChangeDate}+ onDateChange={this.changeDate}// date={new Date(dateA)}date={new Date(this.state.draggerTimeState)}// dateB={new Date(dateB)}@@ -562,11 +561,16 @@ class Timeline extends React.Component {>{/* Timeline */}<TimelineAxis++ frontDate={this.state.frontDate}+ backDate={this.state.backDate}// {...this.props}+ isTimelineDragging={this.state.isTimelineDragging}+ moved={this.state.moved}axisWidth={axisWidth}dateA={dateA}dateB={dateB}- changeDate={this.props.changeDate}+ // changeDate={this.props.changeDate}hasSubdailyLayers={hasSubdailyLayers}parentOffset={parentOffset}changeTimeScale={this.changeTimeScale}@@ -582,7 +586,7 @@ class Timeline extends React.Component {animStartLocationDate={animStartLocationDate}animEndLocationDate={animEndLocationDate}isAnimationWidgetOpen={isAnimationWidgetOpen}-+ isAnimationDraggerDragging={this.state.isAnimationDraggerDragging}updateDraggerDatePosition={this.updateDraggerDatePosition}draggerTimeState={this.state.draggerTimeState}draggerTimeStateB={this.state.draggerTimeStateB}@@ -593,7 +597,7 @@ class Timeline extends React.Component {draggerVisible={this.state.draggerVisible}draggerVisibleB={this.state.draggerVisibleB}transformX={this.state.transformX}- updateDynamicPositioning={this.updateDynamicPositioning}+ updatePositioning={this.updatePositioning}position={this.state.position}animationStartLocation={this.state.animationStartLocation}animationEndLocation={this.state.animationEndLocation}@@ -619,28 +623,22 @@ class Timeline extends React.Component {{isAnimationWidgetOpen? <TimelineRangeSelector+ position={this.state.position}+ frontDate={this.state.frontDate}+ isAnimationDraggerDragging={this.state.isAnimationDraggerDragging}timeScale={timeScale}startLocation={this.state.animationStartLocation}endLocation={this.state.animationEndLocation}- // startLocationDate={animStartLocationDate}- // endLocationDate={animEndLocationDate}startLocationDate={this.state.animationStartLocationDate}endLocationDate={this.state.animationEndLocationDate}timelineStartDateLimit={timelineStartDateLimit}timelineEndDateLimit={timelineEndDateLimit}updateAnimationDateAndLocation={this.updateAnimationDateAndLocation}animationDraggerDateUpdate={this.animationDraggerDateUpdate}- max={{ end: false, start: false, startOffset: -50, width: 50000 }}+ max={this.state.rangeSelectorMax}pinWidth={5}- height={45}width={axisWidth}transformX={this.state.transformX}- // onDrag={this.animationDraggerPositionUpdate}- // onHover={this.showHoverOff}- // onDrag={() => console.log('animationDraggerPositionUpdate')}- onHover={() => console.log('showHoverOff')}- // onRangeClick={this.setLineTime}- onRangeClick={() => console.log('onRangeClick')}rangeOpacity={0.3}rangeColor={'#45bdff'}startColor={'#40a9db'}@@ -649,6 +647,10 @@ class Timeline extends React.Component {endTriangleColor={'#4b7aab'} />: null}+<<<<<<< HEAD+=======++>>>>>>> fix anim date inputs, continue large refactor and clean up{this.state.frontDate? <DraggerContainerposition={this.state.position}@@ -709,6 +711,7 @@ class Timeline extends React.Component {{/* Zoom Level Change */}<AxisTimeScaleChange+ isDraggerDragging={this.state.isDraggerDragging}timelineHidden={this.state.timelineHidden}timeScale={this.props.timeScale}changeTimeScale={this.changeTimeScale}@@ -868,16 +871,16 @@ const mapDispatchToProps = dispatch => ({dispatch(toggleActiveCompareState());},// update anim startDate- changeStartDate: date => {+ onUpdateStartDate: date => {dispatch(changeStartDate(date));},// update anim endDate- changeEndDate: date => {+ onUpdateEndDate: date => {dispatch(changeEndDate(date));},// update anim startDate and endDate- changeStartAndEndDate: (startDate, endDate) => {- dispatch(changeStartAndEndDate(startDate, endDate));+ onUpdateStartAndEndDate: (startDate, endDate) => {+ dispatch(changeStartAndEndDate(startDate, endDate))}});diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.jsindex 0cf3f7e3d..08f9e3872 100644--- a/web/js/map/layerbuilder.js+++ b/web/js/map/layerbuilder.js@@ -142,7 +142,6 @@ export function mapLayerBuilder(models, config, cache, mapUi, store) {date = util.clearTimeUTC(new Date(options.date.getTime()));} else {date = options.date;- // # possible to memoize third argument dateArray ?date = util.prevDateInDateRange(def,date,@@ -150,7 +149,6 @@ export function mapLayerBuilder(models, config, cache, mapUi, store) {);}} else {- // # mutation of models date causing overwrite issue for SUBDAILY vs NON-SUBDAILYdate = new Date(state.date[activeDateStr]);// If this not a subdaily layer, truncate the selected time to// UTC midnight@@ -178,7 +176,6 @@ export function mapLayerBuilder(models, config, cache, mapUi, store) {// Is current "rounded" previous date not in array of availableDatesif (date && !dateArray.includes(date)) {// Then, update layer object with new array of dates- // # time complexity searching through array can be improved with object lookupdef.availableDates = util.datesinDateRanges(def, date, true);date = util.prevDateInDateRange(def, date, dateArray);}@@ -267,8 +264,6 @@ export function mapLayerBuilder(models, config, cache, mapUi, store) {date = options.date || state.date[activeDateStr];if (def.period === 'subdaily') {date = self.closestDate(def, options);- // TODO: FIX +/- DATE OFFSETS TO GET UTC - SOURCE SINGLE STATE TRUTH- // date = new Date(date.getTime() - (date.getTimezoneOffset() * 60000));date = new Date(date.getTime());}if (day && (def.period !== 'subdaily')) {diff --git a/web/js/util/util.js b/web/js/util/util.jsindex 7ee66c445..0928ceaf2 100644--- a/web/js/util/util.js+++ b/web/js/util/util.js@@ -371,20 +371,13 @@ export default (function (self) {};/**- * Calculates percent of date between two other dates+ * Round input time to one minute*- * @method getDatePercent+ * @method roundTimeOneMinute* @static- * @param current {Date} current date- * @param start {Date} start date- * @param end {Date} end date- * @return {number} decimal percent+ * @param time {Date} date+ * @return {number} rounded date*/- self.getDatePercent = function (current, start, end) {- return Math.round((current - start) / (end - start));- };-- // # TODO: round vs. floor - getting next minute, but cutting off single minute coverage ex: 23:50-23:50self.roundTimeOneMinute = function (time) {var timeToReturn = new Date(time);@@ -394,15 +387,6 @@ export default (function (self) {return timeToReturn;};- self.roundTimeTenMinute = function (time) {- var timeToReturn = new Date(time);-- timeToReturn.setMilliseconds(Math.round(timeToReturn.getMilliseconds() / 1000) * 1000);- timeToReturn.setSeconds(Math.round(timeToReturn.getSeconds() / 60) * 60);- timeToReturn.setMinutes(Math.round(timeToReturn.getMinutes() / 10) * 10);- return timeToReturn;- };-/*** Sets a date to UTC midnight.*@@ -1230,7 +1214,6 @@ export default (function (self) {* @return {object} The date object with normalized timeszone.*/self.prevDateInDateRange = function (def, date, dateArray) {- // # NEED TO TRACE BACK AND USE UTC DATES ONLY? WILL REWRITE A LOT BUT WOULD BE CLEANER/MORE TESTABLEvar currentDate = new Date(date.getTime());if (!dateArray) return date;if ((def.period === 'monthly' && (isFirstDayOfMonth(currentDate) || isLastDayOfMonth(currentDate))) ||