Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

move dragger container out of axis into parent timeline component, WIP

Edward Plato42273ad75cea
diff --git a/web/js/components/range-selection/dragger-range.js b/web/js/components/range-selection/dragger-range.js
index b21824ae9..9ced5e8b6 100644
--- a/web/js/components/range-selection/dragger-range.js
+++ b/web/js/components/range-selection/dragger-range.js
@@ -242,7 +242,7 @@ class TimelineDraggerRange extends PureComponent {
handle=".dragger-range"
axis="x"
position={null}
- defaultPosition={{ x: 0, y: 0 }}
+ defaultPosition={{ x: 0, y: 11 }}
onStop={this.props.onStop}
onDrag={this.handleDrag.bind(this)}
>
@@ -255,7 +255,7 @@ class TimelineDraggerRange extends PureComponent {
cursor: 'pointer'
}}
// height={this.props.height}
- height={63}
+ height={64}
className="dragger-range"
id={this.props.draggerID}
onClick={this.handleDraggerClick.bind(this)}
diff --git a/web/js/components/range-selection/dragger.js b/web/js/components/range-selection/dragger.js
index 3e8ec5032..febefa48f 100644
--- a/web/js/components/range-selection/dragger.js
+++ b/web/js/components/range-selection/dragger.js
@@ -42,7 +42,7 @@ class TimelineDragger extends PureComponent {
<rect
width={this.props.width}
// height={this.props.height}
- height={40}
+ height={52}
style={{
fill: this.props.color,
visibility: visibility
diff --git a/web/js/components/timeline/timeline-axis/dragger-container.js b/web/js/components/timeline/timeline-axis/dragger-container.js
index 96879d673..32c63e10b 100644
--- a/web/js/components/timeline/timeline-axis/dragger-container.js
+++ b/web/js/components/timeline/timeline-axis/dragger-container.js
@@ -2,6 +2,11 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Dragger from './timeline-dragger';
+import moment from 'moment';
+
+import { getISODateFormatted, getIsBetween } from '../date-util';
+import { timeScaleOptions } from '../../../modules/date/constants';
+
/*
* Dragger container used to conditionally render based on selected dragger
* this is necessary for svg dragger z-index (ex: allow B to drag over A if B being dragged)
@@ -10,13 +15,308 @@ import Dragger from './timeline-dragger';
* @extends PureComponent
*/
class DraggerContainer extends PureComponent {
+ constructor(props) {
+ super(props);
+ this.state = {
+ draggerWidth: 49
+ };
+ }
+
+ // select dragger 'selected' or 'selectedB'
+ selectDragger = (draggerName, e) => {
+ if (e) {
+ e.stopPropagation();
+ e.preventDefault();
+ }
+ if (draggerName !== this.props.draggerSelected) {
+ this.props.onChangeSelectedDragger(draggerName);
+ }
+ }
+
+ // move draggerTimeState to inputTime
+ setDraggerToTime = (inputTime, draggerB) => {
+ let frontDate = this.props.frontDate;
+ let backDate = this.props.backDate;
+ let draggerTime = draggerB ? this.props.draggerTimeStateB : this.props.draggerTimeState;
+ 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;
+
+ 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;
+
+ 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;
+ }
+
+ 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
+ // });
+ // }
+ }
+
+ // handle dragger dragging
+ handleDragDragger = (draggerName, e, d) => {
+ if (e) {
+ e.stopPropagation();
+ e.preventDefault();
+ }
+
+ requestAnimationFrame(() => {
+ var deltaX = d.deltaX;
+ if (deltaX === 0) {
+ return false;
+ }
+ let timeScale = this.props.timeScale;
+
+ let options = timeScaleOptions[timeScale].timeAxis;
+ let gridWidth = options.gridWidth;
+
+ // let axisWidth = this.props.axisWidth;
+ // let dragSentinelChangeNumber = this.state.dragSentinelChangeNumber;
+ // let dragSentinelCount = this.state.dragSentinelCount;
+
+ let time;
+ let draggerPosition;
+ let draggerASelected = draggerName === 'selected';
+ if (draggerASelected) { // 'selected is 'A' dragger
+ draggerPosition = this.props.draggerPosition + deltaX;
+ time = this.props.draggerTimeState;
+ } else { // 'selectedB' is 'B' dragger
+ draggerPosition = this.props.draggerPositionB + deltaX;
+ time = this.props.draggerTimeStateB;
+ }
+
+ // update draggerTime based on deltaX from state draggerTime
+ let draggerTimeValue = new Date(time).getTime();
+
+ // only need to calculate difference in time unit for varying timescales - month and year
+ let newDraggerTime;
+ let diffZeroValues = options.scaleMs;
+ if (!diffZeroValues) {
+ // calculate based on frontDate due to varying number of days per month and per year (leapyears)
+ let frontDate = this.props.frontDate;
+ // ! -2 necessary from subtracting 2 from transformX in updateScale ?
+ // let draggerPositionRelativeToFrontDate = this.state.draggerWidth - 2 + draggerPosition - this.state.position - this.state.transformX;
+ let draggerPositionRelativeToFrontDate = this.state.draggerWidth - 2 + draggerPosition - this.props.position - this.props.transformX;
+ let gridWidthCoef = draggerPositionRelativeToFrontDate / gridWidth;
+ let draggerDateAdded = moment.utc(frontDate).add((Math.floor(gridWidthCoef)), timeScale);
+
+ let daysCount;
+ if (timeScale === 'year') {
+ daysCount = draggerDateAdded.isLeapYear() ? 366 : 365;
+ } else if (timeScale === 'month') {
+ daysCount = draggerDateAdded.daysInMonth();
+ }
+ let gridWidthCoefRemainder = gridWidthCoef - Math.floor(gridWidthCoef);
+ let remainderMilliseconds = daysCount * 86400000 * gridWidthCoefRemainder;
+ newDraggerTime = draggerDateAdded.add(remainderMilliseconds);
+ } else {
+ let diffFactor = diffZeroValues / gridWidth;
+ newDraggerTime = draggerTimeValue + (diffFactor * deltaX);
+ }
+
+ // check if new dragger date is within valid date range
+ let isBetweenValidTimeline = getIsBetween(newDraggerTime, this.props.timelineStartDateLimit, this.props.timelineEndDateLimit);
+ if (isBetweenValidTimeline) {
+ newDraggerTime = getISODateFormatted(newDraggerTime);
+ } else {
+ return false;
+ }
+
+ // handle drag timeline
+ // // TODO: fix drag off current view - doesn't drag/update date of hover properly
+ // if (draggerPosition < -draggerWidth) { // # handle drag timeline towards PAST
+ // // console.log('drag off view past', deltaX, (dragSentinelCount + deltaX), -dragSentinelChangeNumber)
+ // let position = this.state.position - deltaX;
+
+ // if ((dragSentinelCount + deltaX) < -dragSentinelChangeNumber) {
+ // // console.log('drag off view past UNSHIFT TILES')
+ // let overDrag = 0;
+ // if ((dragSentinelCount + deltaX) < -dragSentinelChangeNumber - dragSentinelChangeNumber) {
+ // overDrag = Math.abs((dragSentinelCount + deltaX) - -dragSentinelChangeNumber - -dragSentinelChangeNumber);
+ // }
+ // //# NEED TO PASS NEGATIVE OF DELTAX FOR UPDATE PANEL
+ // let { currentTimeRange,
+ // deque,
+ // transformX,
+ // draggerVisible,
+ // draggerVisibleB,
+ // overDragGrids,
+ // draggerPositionRevision } = this.updatePanelDateRange(position, timeScale, -deltaX, draggerPosition, overDrag);
+
+ // this.setState({
+ // currentTimeRange: currentTimeRange,
+ // deque: deque,
+ // transformX: transformX,
+ // draggerPosition: -48,
+ // moved: true,
+ // position: position,
+ // dragSentinelCount: (dragSentinelCount + deltaX) - -dragSentinelChangeNumber + (overDragGrids * gridWidth),
+ // })
+ // } else {
+ // let newDragSentinelCount = dragSentinelCount > 0 ? (-dragSentinelChangeNumber + dragSentinelCount + deltaX) : dragSentinelCount + deltaX;
+
+ // // NEGATIVE DELTAX
+ // this.setState({
+ // draggerPosition: -48,
+ // moved: true,
+ // position: position,
+ // dragSentinelCount: newDragSentinelCount
+ // })
+ // }
+ // } else if (draggerPosition > axisWidth - draggerWidth) { // handle drag timeline towards FUTURE
+ // // console.log('drag off view future', deltaX)
+ // let position = this.state.position - deltaX;
+
+ // if ((dragSentinelCount + deltaX) > dragSentinelChangeNumber) {
+
+ // let overDrag = 0;
+ // if ((dragSentinelCount + deltaX) > dragSentinelChangeNumber + dragSentinelChangeNumber) {
+ // overDrag = Math.abs((dragSentinelCount + deltaX) - dragSentinelChangeNumber - dragSentinelChangeNumber);
+ // }
+ // //# NEED TO PASS NEGATIVE OF DELTAX FOR UPDATE PANEL
+ // let { currentTimeRange,
+ // deque,
+ // transformX,
+ // draggerVisible,
+ // draggerVisibleB,
+ // overDragGrids,
+ // draggerPositionRevision } = this.updatePanelDateRange(position, timeScale, -deltaX, draggerPosition, overDrag);
+
+ // this.setState({
+ // currentTimeRange: currentTimeRange,
+ // deque: deque,
+ // transformX: transformX,
+ // draggerPosition: axisWidth - 50,
+ // moved: true,
+ // position: position,
+ // dragSentinelCount: (dragSentinelCount + deltaX) - dragSentinelChangeNumber - (overDragGrids * gridWidth),
+ // })
+
+ // } else {
+ // let newDragSentinelCount = dragSentinelCount < 0 ? (dragSentinelChangeNumber + dragSentinelCount + deltaX) : dragSentinelCount + deltaX;
+
+ // // POSITIVE DELTAX
+ // this.setState({
+ // draggerPosition: axisWidth - 50,
+ // moved: true,
+ // position: position,
+ // dragSentinelCount: newDragSentinelCount
+ // })
+ // }
+ // } 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'));
+ // }
+ // }
+ });
+ }
+
+ componentDidUpdate(prevProps, prevState) {
+ let { dateA, dateB, draggerSelected, compareModeActive } = this.props;
+ // handle compare mode toggle change
+ if (compareModeActive !== prevProps.compareModeActive) {
+ // TURN ON COMPARE MODE
+ if (compareModeActive) {
+ this.setDraggerToTime(dateA);
+ this.setDraggerToTime(dateB, true);
+ } 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
+ // });
+ }
+ }
+ }
+ }
+
+ shouldComponentUpdate(nextProps) {
+ let {
+ dateA,
+ dateB,
+ draggerSelected,
+ width,
+ transformX,
+ compareModeActive,
+ draggerPosition,
+ draggerPositionB,
+ draggerVisible,
+ draggerVisibleB
+ } = this.props;
+
+ let checkForPropsUpdates = (
+ nextProps.dateA === dateA &&
+ nextProps.dateB === dateB &&
+ nextProps.draggerSelected === draggerSelected &&
+ nextProps.width === width &&
+ nextProps.transformX === transformX &&
+ nextProps.compareModeActive === compareModeActive &&
+ nextProps.draggerPosition === draggerPosition &&
+ nextProps.draggerPositionB === draggerPositionB &&
+ nextProps.draggerVisible === draggerVisible &&
+ nextProps.draggerVisibleB === draggerVisibleB
+ );
+
+ if (checkForPropsUpdates) {
+ return false;
+ }
+ return true;
+ }
+
render() {
let {
draggerSelected,
toggleShowDraggerTime,
+ width,
transformX,
- handleDragDragger,
- selectDragger,
compareModeActive,
draggerPosition,
draggerPositionB,
@@ -27,20 +327,20 @@ class DraggerContainer extends PureComponent {
let sharedProps = {
toggleShowDraggerTime,
transformX,
- handleDragDragger,
- selectDragger,
compareModeActive
};
-
+ console.log(this.props)
return (
draggerSelected === 'selectedB'
- ? <React.Fragment>
+ ? <svg className="dragger-container" width={width}>
<Dragger
{...sharedProps}
disabled={true}
draggerName='selected'
draggerPosition={draggerPosition}
draggerVisible={draggerVisible}
+ handleDragDragger={this.handleDragDragger}
+ selectDragger={this.selectDragger}
/>
<Dragger
{...sharedProps}
@@ -48,15 +348,19 @@ class DraggerContainer extends PureComponent {
draggerName='selectedB'
draggerPosition={draggerPositionB}
draggerVisible={draggerVisibleB}
+ handleDragDragger={this.handleDragDragger}
+ selectDragger={this.selectDragger}
/>
- </React.Fragment>
- : <React.Fragment>
+ </svg>
+ : <svg className="dragger-container" width={this.props.width}>
<Dragger
{...sharedProps}
disabled={true}
draggerName='selectedB'
draggerPosition={draggerPositionB}
draggerVisible={draggerVisibleB}
+ handleDragDragger={this.handleDragDragger}
+ selectDragger={this.selectDragger}
/>
<Dragger
{...sharedProps}
@@ -64,8 +368,10 @@ class DraggerContainer extends PureComponent {
draggerName='selected'
draggerPosition={draggerPosition}
draggerVisible={draggerVisible}
+ handleDragDragger={this.handleDragDragger}
+ selectDragger={this.selectDragger}
/>
- </React.Fragment>
+ </svg>
);
}
}
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index fb14ca3d0..f5bdd2387 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -6,10 +6,10 @@ import lodashDebounce from 'lodash/debounce';
import GridRange from './grid-range/grid-range';
import DateToolTip from './date-tooltips';
-import DraggerContainer from './dragger-container';
+// import DraggerContainer from './dragger-container';
import { getTimeRange } from './date-calc';
-import TimelineRangeSelector from '../../range-selection/range-selection';
+// import TimelineRangeSelector from '../../range-selection/range-selection';
import { timeScaleOptions, timeScaleToNumberKey } from '../../../modules/date/constants';
import HoverLine from './hover-line';
@@ -24,28 +24,29 @@ class TimelineAxis extends Component {
constructor(props) {
super(props);
this.state = {
+ init: false,
draggerWidth: 49,
hoverLinePosition: 0,
isDraggerDragging: false,
isTimelineDragging: false,
showDraggerTime: false,
dragSentinelCount: 0,
- draggerPosition: 0,
- draggerVisible: true,
- draggerPositionB: 0,
- draggerVisibleB: true,
+ // draggerPosition: 0,
+ // draggerVisible: true,
+ // draggerPositionB: 0,
+ // draggerVisibleB: true,
moved: false,
hoverTime: null,
showHoverLine: false,
- draggerTimeState: null,
- draggerTimeStateB: null,
+ // draggerTimeState: null,
+ // draggerTimeStateB: null,
leftOffset: 0,
position: 0,
currentTimeRange: null,
transformX: 0,
gridWidth: 12,
- animationStartLocation: 0,
- animationEndLocation: 0,
+ // animationStartLocation: 0,
+ // animationEndLocation: 0,
isAnimationDraggerDragging: false,
wheelZoom: false
};
@@ -106,11 +107,11 @@ class TimelineAxis extends Component {
let draggerDateActual;
let draggerDateActualB;
if (this.props.draggerSelected === 'selected') {
- draggerDateActual = hoverChange ? this.state.draggerTimeState : inputDate || this.state.draggerTimeState;
- draggerDateActualB = this.state.draggerTimeStateB;
+ draggerDateActual = hoverChange ? this.props.draggerTimeState : inputDate || this.props.draggerTimeState;
+ draggerDateActualB = this.props.draggerTimeStateB;
} else {
- draggerDateActual = this.state.draggerTimeState;
- draggerDateActualB = hoverChange ? this.state.draggerTimeStateB : inputDate || this.state.draggerTimeStateB;
+ draggerDateActual = this.props.draggerTimeState;
+ draggerDateActualB = hoverChange ? this.props.draggerTimeStateB : inputDate || this.props.draggerTimeStateB;
}
// value of hover time, hover time timeunit zeroed, hover time next unit timeunit zeroed
@@ -196,30 +197,35 @@ class TimelineAxis extends Component {
let animationStartLocation = animationStartDraggerLocation + position - pixelsToAdd - 2;
let animationEndLocation = animationEndDraggerLocation + position - pixelsToAdd - 2;
+ console.log(animationStartLocation)
+
+ draggerPosition = draggerPosition - pixelsToAdd + position - this.state.draggerWidth;
+ draggerPositionB = draggerPositionB - pixelsToAdd + position - this.state.draggerWidth;
+
this.setState({
- draggerTimeState: draggerDateActual,
- draggerTimeStateB: draggerDateActualB,
- draggerPosition: draggerPosition - pixelsToAdd + position - this.state.draggerWidth,
- draggerVisible,
- draggerPositionB: draggerPositionB - pixelsToAdd + position - this.state.draggerWidth,
- draggerVisibleB,
+ // draggerTimeState: draggerDateActual,
+ // draggerTimeStateB: draggerDateActualB,
+ // draggerPosition: draggerPosition - pixelsToAdd + position - this.state.draggerWidth,
+ // draggerVisible,
+ // draggerPositionB: draggerPositionB - pixelsToAdd + position - this.state.draggerWidth,
+ // draggerVisibleB,
currentTimeRange: timeRange,
- transformX: -pixelsToAdd - 2,
+ // transformX: -pixelsToAdd - 2,
gridNumber,
gridWidth,
numberOfVisibleTiles,
moved: false,
dragSentinelChangeNumber,
- position,
+ // position,
midPoint: position,
dragSentinelCount: 0,
showHoverLine: false,
- animationStartLocation: animationStartLocation,
- animationEndLocation: animationEndLocation,
+ // animationStartLocation: animationStartLocation,
+ // animationEndLocation: animationEndLocation,
leftBound,
rightBound,
wheelZoom: false
- }, this.props.updateDynamicPositioning(position, transformX, timeRange[0].rawDate, animationStartLocation, animationEndLocation));
+ }, this.props.updateDynamicPositioning(position, transformX, timeRange[0].rawDate, backDate, draggerPosition, draggerPositionB, draggerVisible, draggerVisibleB, animationStartLocation, animationEndLocation));
}
// changes timeScale state
@@ -252,11 +258,11 @@ class TimelineAxis extends Component {
gridWidth,
dragSentinelChangeNumber,
dragSentinelCount,
- draggerPosition,
- draggerPositionB,
+ // draggerPosition,
+ // draggerPositionB,
// position
} = this.state;
- let { timeScale, position, animationStartLocation, animationEndLocation } = this.props;
+ let { timeScale, position, animationStartLocation, animationEndLocation, draggerPosition, draggerPositionB } = this.props;
let deltaX = d.deltaX;
position = position + deltaX;
@@ -267,14 +273,15 @@ class TimelineAxis extends Component {
// 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;
this.setState({
- draggerPosition,
- draggerPositionB,
- position,
+ // draggerPosition,
+ // draggerPositionB,
+ // position,
dragSentinelCount: dragSentinelCount + deltaX,
// animationStartLocation,
// animationEndLocation
- }, this.props.updateDynamicPositioning(position, null, frontDate, animationStartLocation, animationEndLocation));
+ }, this.props.updateDynamicPositioning(position, null, frontDate, backDate, draggerPosition, draggerPositionB, null, null, animationStartLocation, animationEndLocation));
} else {
if (deltaX > 0) { // dragging right - exposing past dates
if (dragSentinelCount + deltaX > dragSentinelChangeNumber) {
@@ -300,33 +307,36 @@ class TimelineAxis extends Component {
);
let newDragSentinelCount = dragSentinelCount + deltaX - dragSentinelChangeNumber - overDragGrids * gridWidth;
+ let frontDate = currentTimeRange[0].rawDate;
+ let backDate = currentTimeRange[currentTimeRange.length - 1].rawDate;
+
this.setState({
currentTimeRange,
- transformX,
+ // transformX,
dragSentinelCount: newDragSentinelCount,
- draggerPosition: newDraggerPosition,
- draggerVisible,
- draggerPositionB: newDraggerPositionB,
- draggerVisibleB,
- position,
+ // draggerPosition: newDraggerPosition,
+ // draggerVisible,
+ // draggerPositionB: newDraggerPositionB,
+ // draggerVisibleB,
+ // position,
showHoverLine: false,
// animationStartLocation,
// animationEndLocation
- }, this.props.updateDynamicPositioning(position, transformX, currentTimeRange[0].rawDate, animationStartLocation, animationEndLocation));
+ }, this.props.updateDynamicPositioning(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({
- draggerPosition,
- draggerPositionB,
- position,
+ // draggerPosition,
+ // draggerPositionB,
+ // position,
dragSentinelCount: newDragSentinelCount,
showHoverLine: false,
// animationStartLocation,
// animationEndLocation
- }, this.props.updateDynamicPositioning(position, null, null, animationStartLocation, animationEndLocation));
+ }, this.props.updateDynamicPositioning(position, null, null, null, draggerPosition, draggerPositionB, null, null, animationStartLocation, animationEndLocation));
}
} else if (deltaX < 0) { // dragging left - exposing future dates
if (dragSentinelCount + deltaX < -dragSentinelChangeNumber) {
@@ -352,33 +362,35 @@ class TimelineAxis extends Component {
);
let newDragSentinelCount = dragSentinelCount + deltaX + dragSentinelChangeNumber + overDragGrids * gridWidth;
+ let frontDate = currentTimeRange[0].rawDate;
+ let backDate = currentTimeRange[currentTimeRange.length - 1].rawDate;
this.setState({
currentTimeRange,
- transformX,
+ // transformX,
dragSentinelCount: newDragSentinelCount,
- draggerPosition: newDraggerPosition,
- draggerVisible,
- draggerPositionB: newDraggerPositionB,
- draggerVisibleB,
- position,
+ // draggerPosition: newDraggerPosition,
+ // draggerVisible,
+ // draggerPositionB: newDraggerPositionB,
+ // draggerVisibleB,
+ // position,
showHoverLine: false,
// animationStartLocation,
// animationEndLocation
- }, this.props.updateDynamicPositioning(position, transformX, currentTimeRange[0].rawDate, animationStartLocation, animationEndLocation));
+ }, this.props.updateDynamicPositioning(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({
- draggerPosition,
- draggerPositionB,
- position,
+ // draggerPosition,
+ // draggerPositionB,
+ // position,
dragSentinelCount: newDragSentinelCount,
showHoverLine: false,
// animationStartLocation,
// animationEndLocation
- }, this.props.updateDynamicPositioning(position, null, null, animationStartLocation, animationEndLocation));
+ }, this.props.updateDynamicPositioning(position, null, null, null, draggerPosition, draggerPositionB, null, null, animationStartLocation, animationEndLocation));
}
}
}
@@ -387,17 +399,22 @@ class TimelineAxis extends Component {
// update dates in range based on dragging axis
updatePanelDateRange = (position, deltaX, draggerPosition, draggerPositionB, overDrag) => {
let {
- transformX,
+ // transformX,
gridWidth,
currentTimeRange,
numberOfVisibleTiles,
- draggerVisible,
- draggerVisibleB,
- draggerTimeState,
- draggerTimeStateB
+ // draggerVisible,
+ // draggerVisibleB,
+ // draggerTimeState,
+ // draggerTimeStateB
} = this.state;
let {
+ transformX,
+ draggerVisible,
+ draggerVisibleB,
+ draggerTimeState,
+ draggerTimeStateB,
compareModeActive,
draggerSelected
} = this.props;
@@ -566,8 +583,8 @@ class TimelineAxis extends Component {
} = this.state;
let { draggerSelected } = this.props;
- let draggerPosition = draggerSelected === 'selected' ? leftOffset - draggerWidth : this.state.draggerPosition;
- let draggerPositionB = draggerSelected === 'selectedB' ? leftOffset - draggerWidth : this.state.draggerPositionB;
+ let draggerPosition = draggerSelected === 'selected' ? leftOffset - draggerWidth : this.props.draggerPosition;
+ let draggerPositionB = draggerSelected === 'selectedB' ? leftOffset - draggerWidth : this.props.draggerPositionB;
// check if the other dragger visible after clicking and moving then new dragger
let isCompareModeActive = this.props.compareModeActive;
@@ -580,25 +597,29 @@ class TimelineAxis extends Component {
if (draggerB) {
// check DRAGGER A visibility
- let draggerAVisible = isCompareModeActive && getIsBetween(this.state.draggerTimeState, frontDate, backDate);
+ let draggerAVisible = isCompareModeActive && getIsBetween(this.props.draggerTimeState, frontDate, backDate);
- this.setState({
- draggerPositionB,
- draggerVisible: draggerAVisible,
- draggerVisibleB: true,
- draggerTimeStateB: hoverTime,
- moved: false
- }, this.props.changeDate(new Date(hoverTime), 'selectedB'));
+ // this.setState({
+ // draggerPositionB,
+ // draggerVisible: draggerAVisible,
+ // draggerVisibleB: true,
+ // draggerTimeStateB: hoverTime,
+ // moved: false
+ // }, this.props.changeDate(new Date(hoverTime), 'selectedB'));
+
+ this.props.updateDraggerDatePosition(hoverTime, 'selectedB', draggerPositionB, true, draggerAVisible, false);
} else {
// check DRAGGER B visibility
- let draggerBVisible = isCompareModeActive && getIsBetween(this.state.draggerTimeStateB, frontDate, backDate);
- this.setState({
- draggerPosition,
- draggerVisible: true,
- draggerVisibleB: draggerBVisible,
- draggerTimeState: hoverTime,
- moved: false
- }, this.props.changeDate(new Date(hoverTime), 'selected'));
+ let draggerBVisible = isCompareModeActive && getIsBetween(this.props.draggerTimeStateB, frontDate, backDate);
+ // this.setState({
+ // draggerPosition,
+ // draggerVisible: true,
+ // draggerVisibleB: draggerBVisible,
+ // draggerTimeState: hoverTime,
+ // moved: false
+ // }, this.props.changeDate(new Date(hoverTime), 'selected'));
+
+ this.props.updateDraggerDatePosition(hoverTime, 'selected', draggerPosition, true, draggerBVisible, false);
}
}
}
@@ -690,22 +711,23 @@ class TimelineAxis extends Component {
let animationEndLocation = animationEndDraggerLocation + midPoint;
this.setState({
- draggerPosition: draggerPosition + midPoint - this.state.draggerWidth,
- draggerVisible,
- draggerPositionB: draggerPositionB + midPoint - this.state.draggerWidth,
- draggerVisibleB,
+ init: true,
+ // draggerPosition: draggerPosition + midPoint - this.state.draggerWidth,
+ // draggerVisible,
+ // draggerPositionB: draggerPositionB + midPoint - this.state.draggerWidth,
+ // draggerVisibleB,
numberOfVisibleTiles: numberOfVisibleTiles,
dragSentinelChangeNumber: dragSentinelChangeNumber,
currentTimeRange: timeRange,
gridWidth,
- draggerTimeState: time,
- draggerTimeStateB: draggerTimeStateB,
+ // draggerTimeState: time,
+ // draggerTimeStateB: draggerTimeStateB,
hoverTime: time,
- transformX: 0,
+ // transformX: 0,
midPoint,
- position: midPoint,
- animationStartLocation: animationStartLocation,
- animationEndLocation: animationEndLocation,
+ // position: midPoint,
+ // animationStartLocation: animationStartLocation,
+ // animationEndLocation: animationEndLocation,
leftBound,
rightBound
@@ -729,11 +751,11 @@ class TimelineAxis extends Component {
let draggerPosition;
if (draggerB) {
- draggerTimeState = this.state.draggerTimeStateB;
- draggerPosition = this.state.draggerPositionB;
+ draggerTimeState = this.props.draggerTimeStateB;
+ draggerPosition = this.props.draggerPositionB;
} else {
- draggerTimeState = this.state.draggerTimeState;
- draggerPosition = this.state.draggerPosition;
+ draggerTimeState = this.props.draggerTimeState;
+ draggerPosition = this.props.draggerPosition;
}
let timeScale = this.props.timeScale;
@@ -763,8 +785,8 @@ class TimelineAxis extends Component {
let {
isDraggerDragging,
isAnimationDraggerDragging,
- draggerTimeState,
- draggerTimeStateB
+ // draggerTimeState,
+ // draggerTimeStateB
} = this.state;
let {
dateA,
@@ -773,6 +795,8 @@ class TimelineAxis extends Component {
timeScale,
axisWidth,
compareModeActive,
+ draggerTimeState,
+ draggerTimeStateB
// animStartLocationDate,
// animEndLocationDate
} = this.props;
@@ -877,7 +901,7 @@ class TimelineAxis extends Component {
setDraggerToTime = (inputTime, draggerB) => {
let frontDate = this.state.currentTimeRange[0].rawDate;
let backDate = this.state.currentTimeRange[this.state.currentTimeRange.length - 1].rawDate;
- let draggerTime = draggerB ? this.state.draggerTimeStateB : this.state.draggerTimeState;
+ let draggerTime = draggerB ? this.props.draggerTimeStateB : this.props.draggerTimeState;
let isBetween = getIsBetween(inputTime, frontDate, backDate);
@@ -893,13 +917,12 @@ class TimelineAxis extends Component {
let pixelsToAddToDraggerNew = Math.abs(frontDateObj.diff(inputTime, timeScale, true) * gridWidth);
let pixelsToAddBasedOnFrontDate = pixelsToAddToDraggerNew - pixelsToAddToDragger;
- let isVisible = draggerB ? this.state.draggerVisibleB : this.state.draggerVisible;
+ let isVisible = draggerB ? this.props.draggerVisibleB : this.props.draggerVisible;
if (isVisible) {
- let draggerPosition = draggerB ? this.state.draggerPositionB : this.state.draggerPosition;
+ 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.state.transformX;
+ newDraggerPosition = pixelsToAddToDraggerNew + this.props.position - this.state.draggerWidth + this.props.transformX;
}
if (draggerB) {
@@ -930,11 +953,11 @@ class TimelineAxis extends Component {
let {
midPoint,
// position,
- transformX,
+ // transformX,
leftBound,
rightBound
} = this.state;
- let { timeScale, position } = this.props;
+ let { timeScale, position, transformX } = this.props;
position = position - midPoint;
let moved = false;
@@ -958,195 +981,11 @@ class TimelineAxis extends Component {
leftBound,
rightBound,
moved: moved,
- position: midPoint,
- transformX: transformX
+ // position: midPoint,
+ // transformX: transformX
}, this.props.updateDynamicPositioning(midPoint, transformX));
}
- // handle dragger dragging
- handleDragDragger = (draggerName, e, d) => {
- if (e) {
- e.stopPropagation();
- e.preventDefault();
- }
-
- requestAnimationFrame(() => {
- var deltaX = d.deltaX;
- if (deltaX === 0) {
- return false;
- }
- let timeScale = this.props.timeScale;
-
- let options = timeScaleOptions[timeScale].timeAxis;
- let gridWidth = this.state.gridWidth;
-
- let axisWidth = this.props.axisWidth;
- let dragSentinelChangeNumber = this.state.dragSentinelChangeNumber;
- let dragSentinelCount = this.state.dragSentinelCount;
-
- let time;
- let draggerPosition;
- let draggerASelected = draggerName === 'selected';
- if (draggerASelected) { // 'selected is 'A' dragger
- draggerPosition = this.state.draggerPosition + deltaX;
- time = this.state.draggerTimeState;
- } else { // 'selectedB' is 'B' dragger
- draggerPosition = this.state.draggerPositionB + deltaX;
- time = this.state.draggerTimeStateB;
- }
-
- // update draggerTime based on deltaX from state draggerTime
- let draggerTimeValue = new Date(time).getTime();
-
- // only need to calculate difference in time unit for varying timescales - month and year
- let newDraggerTime;
- let diffZeroValues = options.scaleMs;
- if (!diffZeroValues) {
- // calculate based on frontDate due to varying number of days per month and per year (leapyears)
- let frontDate = this.state.currentTimeRange[0].rawDate;
- // ! -2 necessary from subtracting 2 from transformX in updateScale ?
- // let draggerPositionRelativeToFrontDate = this.state.draggerWidth - 2 + draggerPosition - this.state.position - this.state.transformX;
- let draggerPositionRelativeToFrontDate = this.state.draggerWidth - 2 + draggerPosition - this.props.position - this.state.transformX;
- let gridWidthCoef = draggerPositionRelativeToFrontDate / gridWidth;
- let draggerDateAdded = moment.utc(frontDate).add((Math.floor(gridWidthCoef)), timeScale);
-
- let daysCount;
- if (timeScale === 'year') {
- daysCount = draggerDateAdded.isLeapYear() ? 366 : 365;
- } else if (timeScale === 'month') {
- daysCount = draggerDateAdded.daysInMonth();
- }
- let gridWidthCoefRemainder = gridWidthCoef - Math.floor(gridWidthCoef);
- let remainderMilliseconds = daysCount * 86400000 * gridWidthCoefRemainder;
- newDraggerTime = draggerDateAdded.add(remainderMilliseconds);
- } else {
- let diffFactor = diffZeroValues / gridWidth;
- newDraggerTime = draggerTimeValue + (diffFactor * deltaX);
- }
-
- // check if new dragger date is within valid date range
- let isBetweenValidTimeline = getIsBetween(newDraggerTime, this.props.timelineStartDateLimit, this.props.timelineEndDateLimit);
- if (isBetweenValidTimeline) {
- newDraggerTime = getISODateFormatted(newDraggerTime);
- } else {
- return false;
- }
-
- // handle drag timeline
- // // TODO: fix drag off current view - doesn't drag/update date of hover properly
- // if (draggerPosition < -draggerWidth) { // # handle drag timeline towards PAST
- // // console.log('drag off view past', deltaX, (dragSentinelCount + deltaX), -dragSentinelChangeNumber)
- // let position = this.state.position - deltaX;
-
- // if ((dragSentinelCount + deltaX) < -dragSentinelChangeNumber) {
- // // console.log('drag off view past UNSHIFT TILES')
- // let overDrag = 0;
- // if ((dragSentinelCount + deltaX) < -dragSentinelChangeNumber - dragSentinelChangeNumber) {
- // overDrag = Math.abs((dragSentinelCount + deltaX) - -dragSentinelChangeNumber - -dragSentinelChangeNumber);
- // }
- // //# NEED TO PASS NEGATIVE OF DELTAX FOR UPDATE PANEL
- // let { currentTimeRange,
- // deque,
- // transformX,
- // draggerVisible,
- // draggerVisibleB,
- // overDragGrids,
- // draggerPositionRevision } = this.updatePanelDateRange(position, timeScale, -deltaX, draggerPosition, overDrag);
-
- // this.setState({
- // currentTimeRange: currentTimeRange,
- // deque: deque,
- // transformX: transformX,
- // draggerPosition: -48,
- // moved: true,
- // position: position,
- // dragSentinelCount: (dragSentinelCount + deltaX) - -dragSentinelChangeNumber + (overDragGrids * gridWidth),
- // })
- // } else {
- // let newDragSentinelCount = dragSentinelCount > 0 ? (-dragSentinelChangeNumber + dragSentinelCount + deltaX) : dragSentinelCount + deltaX;
-
- // // NEGATIVE DELTAX
- // this.setState({
- // draggerPosition: -48,
- // moved: true,
- // position: position,
- // dragSentinelCount: newDragSentinelCount
- // })
- // }
- // } else if (draggerPosition > axisWidth - draggerWidth) { // handle drag timeline towards FUTURE
- // // console.log('drag off view future', deltaX)
- // let position = this.state.position - deltaX;
-
- // if ((dragSentinelCount + deltaX) > dragSentinelChangeNumber) {
-
- // let overDrag = 0;
- // if ((dragSentinelCount + deltaX) > dragSentinelChangeNumber + dragSentinelChangeNumber) {
- // overDrag = Math.abs((dragSentinelCount + deltaX) - dragSentinelChangeNumber - dragSentinelChangeNumber);
- // }
- // //# NEED TO PASS NEGATIVE OF DELTAX FOR UPDATE PANEL
- // let { currentTimeRange,
- // deque,
- // transformX,
- // draggerVisible,
- // draggerVisibleB,
- // overDragGrids,
- // draggerPositionRevision } = this.updatePanelDateRange(position, timeScale, -deltaX, draggerPosition, overDrag);
-
- // this.setState({
- // currentTimeRange: currentTimeRange,
- // deque: deque,
- // transformX: transformX,
- // draggerPosition: axisWidth - 50,
- // moved: true,
- // position: position,
- // dragSentinelCount: (dragSentinelCount + deltaX) - dragSentinelChangeNumber - (overDragGrids * gridWidth),
- // })
-
- // } else {
- // let newDragSentinelCount = dragSentinelCount < 0 ? (dragSentinelChangeNumber + dragSentinelCount + deltaX) : dragSentinelCount + deltaX;
-
- // // POSITIVE DELTAX
- // this.setState({
- // draggerPosition: axisWidth - 50,
- // moved: true,
- // position: position,
- // dragSentinelCount: newDragSentinelCount
- // })
- // }
- // } else { // handle drag within axis view
-
- 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'));
- }
- // }
- });
- }
-
- changeDate = (time, draggerSelected) => {
- this.props.changeDate(time, draggerSelected);
- }
-
- // select dragger 'selected' or 'selectedB'
- selectDragger = (draggerName, e) => {
- if (e) {
- e.stopPropagation();
- e.preventDefault();
- }
- if (draggerName !== this.props.draggerSelected) {
- this.props.onChangeSelectedDragger(draggerName);
- }
- }
-
// display date based on hover grid tile
displayDate = (date, leftOffset) => {
requestAnimationFrame(() => {
@@ -1188,177 +1027,6 @@ class TimelineAxis extends Component {
});
}
- // // update animation dragger helper function
- // getAnimationLocateDateUpdate = (animLocationDate, animDraggerLocation, deltaX, { diffZeroValues, diffFactor, frontDate }) => {
- // if (!diffZeroValues) { // month or year
- // let {
- // // position,
- // transformX,
- // gridWidth
- // } = this.state;
- // let { timeScale, position } = this.props;
-
- // let startDraggerPositionRelativeToFrontDate = animDraggerLocation - position - transformX + deltaX;
- // let gridWidthCoef = startDraggerPositionRelativeToFrontDate / gridWidth;
- // let draggerDateAdded = frontDate.add((Math.floor(gridWidthCoef)), timeScale);
- // let daysCount;
- // if (timeScale === 'year') {
- // daysCount = draggerDateAdded.isLeapYear() ? 366 : 365;
- // } else if (timeScale === 'month') {
- // daysCount = draggerDateAdded.daysInMonth();
- // }
- // let gridWidthCoefRemainder = gridWidthCoef - Math.floor(gridWidthCoef);
- // let remainderMilliseconds = daysCount * 86400000 * gridWidthCoefRemainder;
- // let newLocationDate = draggerDateAdded.add(remainderMilliseconds);
- // return new Date(newLocationDate);
- // } else {
- // let draggerTimeStartValue = new Date(animLocationDate).getTime();
- // let newLocationDate = draggerTimeStartValue + (diffFactor * deltaX);
- // return new Date(newLocationDate);
- // }
- // }
-
- // handle animation dragger drag change
- // animationDraggerPositionUpdate = (startLocation, endLocation, isDragging) => {
- // let {
- // animationStartLocation,
- // animationEndLocation,
- // gridWidth
- // } = this.state;
- // let {
- // timelineStartDateLimit,
- // timelineEndDateLimit,
- // animStartLocationDate,
- // animEndLocationDate,
- // timeScale
- // } = this.props;
-
- // // calculate new start and end positions
- // let deltaXStart = startLocation - animationStartLocation;
- // let animationStartLocationDate = animStartLocationDate;
- // let deltaXEnd = endLocation - animationEndLocation;
- // let animationEndLocationDate = animEndLocationDate;
-
- // let startChanged = false;
- // let endChanged = false;
-
- // // if start or end dragger has moved
- // if (deltaXStart !== 0 || deltaXEnd !== 0) {
- // let diffZeroValues = timeScaleOptions[timeScale].timeAxis.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.state.currentTimeRange[0].rawDate);
- // } else {
- // diffFactor = diffZeroValues / gridWidth; // else known diffFactor used
- // }
-
- // let sharedAnimLocationUpdateParams = {
- // diffZeroValues,
- // diffFactor,
- // frontDate
- // };
- // if (deltaXStart !== 0) { // update new start date
- // startChanged = true;
- // animationStartLocationDate = this.getAnimationLocateDateUpdate(
- // animationStartLocationDate,
- // animationStartLocation,
- // deltaXStart,
- // sharedAnimLocationUpdateParams
- // );
- // }
- // if (deltaXEnd !== 0) { // update new end date
- // endChanged = true;
- // animationEndLocationDate = this.getAnimationLocateDateUpdate(
- // animationEndLocationDate,
- // animationEndLocation,
- // deltaXEnd,
- // sharedAnimLocationUpdateParams
- // );
- // }
- // }
-
- // let startDateLimit = new Date(timelineStartDateLimit);
- // let endDateLimit = new Date(timelineEndDateLimit);
- // let startDate = new Date(animationStartLocationDate);
- // let endDate = new Date(animationEndLocationDate);
-
- // // prevent draggers to be dragger BEFORE start date limit
- // if (endDate < startDateLimit) {
- // endLocation = animationEndLocation;
- // animationEndLocationDate = startDateLimit;
- // }
- // if (startDate < startDateLimit) {
- // startLocation = animationStartLocation;
- // animationStartLocationDate = startDateLimit;
- // }
- // // prevent draggers to be dragger AFTER end date limit
- // if (endDate > endDateLimit) {
- // endLocation = animationEndLocation;
- // animationEndLocationDate = endDateLimit;
- // }
- // if (startDate > endDateLimit) {
- // startLocation = animationStartLocation;
- // animationStartLocationDate = endDateLimit;
- // }
-
- // this.setState({
- // isAnimationDraggerDragging: isDragging,
- // animationStartLocation: startLocation,
- // animationEndLocation: endLocation,
- // showHoverLine: false,
- // showDraggerTime: false,
- // moved: !isDragging
- // }, this.animationUpdateWidget(animationStartLocationDate, animationEndLocationDate, animationStartLocation, animationEndLocation));
- // }
-
- // handles conditional functions for animation dragger updates
- // animationUpdateWidget = (startChanged, endChanged, animationStartLocationDate, animationEndLocationDate) => {
- // if (startChanged) {
- // if (endChanged) {
- // this.props.changeAnimStartAndEndDate(animationStartLocationDate, animationEndLocationDate);
- // } else {
- // this.props.changeAnimStartDate(animationStartLocationDate);
- // }
- // } else {
- // this.props.changeAnimEndDate(animationEndLocationDate);
- // }
- // }
-
- // handles conditional functions for animation dragger updates
- // animationUpdateWidget = (animationStartLocationDate, animationEndLocationDate, animationStartLocation, animationEndLocation) => {
- // // if (startChanged) {
- // // if (endChanged) {
- // this.props.changeAnimStartAndEndDate(animationStartLocationDate, animationEndLocationDate, animationStartLocation, animationEndLocation);
- // // } else {
- // // this.props.changeAnimStartDate(animationStartLocationDate);
- // // }
- // // } else {
- // // this.props.changeAnimEndDate(animationEndLocationDate);
- // // }
- // }
-
- // handle animation dragger location update and state update
- // animationDraggerDateUpdate = (animationStartLocationDate, animationEndLocationDate) => {
- // let {
- // gridWidth,
- // // position,
- // transformX
- // } = this.state;
- // let { timeScale, position } = this.props;
-
- // 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
- // });
- // }
-
// handle svg blue line hover
showHover = (e, itemDate, nextDate, index) => {
e.preventDefault();
@@ -1367,11 +1035,11 @@ class TimelineAxis extends Component {
requestAnimationFrame(() => {
let {
// position,
- transformX,
+ // transformX,
gridWidth
} = this.state;
- let { position } = this.props;
+ let { position, transformX } = this.props;
let target = e.target;
let clientX = e.clientX;
@@ -1401,97 +1069,82 @@ class TimelineAxis extends Component {
}
shouldComponentUpdate(nextProps, nextState) {
- let nextDateA = nextProps.dateA;
- let nextDateB = nextProps.dateB;
- let nextDraggerSelected = nextProps.draggerSelected;
- let nextTimeScale = nextProps.timeScale;
- let nextCompareModeActive = nextProps.compareModeActive;
- let nextHasSubdailyLayers = nextProps.hasSubdailyLayers;
- let nextParentOffset = nextProps.parentOffset;
- let nextTimelineEndDateLimit = nextProps.timelineEndDateLimit;
-
- let {
- dateA,
- dateB,
- draggerSelected,
- timeScale,
- compareModeActive,
- hasSubdailyLayers,
- parentOffset,
- timelineEndDateLimit
- } = this.props;
-
- let checkForPropsUpdates = (
- nextDateA === dateA &&
- nextDateB === dateB &&
- nextDraggerSelected === draggerSelected &&
- nextTimeScale === timeScale &&
- nextCompareModeActive === compareModeActive &&
- nextHasSubdailyLayers === hasSubdailyLayers &&
- nextParentOffset === parentOffset &&
- nextTimelineEndDateLimit === timelineEndDateLimit
- );
+ if (this.state.init === false) {
+ return true;
+ } else {
+ let {
+ axisWidth,
+ dateA,
+ dateB,
+ draggerSelected,
+ timeScale,
+ compareModeActive,
+ hasSubdailyLayers,
+ parentOffset,
+ timelineEndDateLimit,
+ transformX
+ } = this.props;
+
+ let checkForPropsUpdates = (
+ nextProps.axisWidth === axisWidth &&
+ nextProps.dateA === dateA &&
+ nextProps.dateB === dateB &&
+ nextProps.draggerSelected === draggerSelected &&
+ nextProps.timeScale === timeScale &&
+ nextProps.compareModeActive === compareModeActive &&
+ nextProps.hasSubdailyLayers === hasSubdailyLayers &&
+ nextProps.parentOffset === parentOffset &&
+ nextProps.timelineEndDateLimit === timelineEndDateLimit &&
+ nextProps.transformX === transformX
+ );
- let {
- currentTimeRange,
- dragSentinelChangeNumber,
- dragSentinelCount,
- draggerPosition,
- draggerPositionB,
- draggerTimeState,
- draggerTimeStateB,
- draggerVisible,
- draggerVisibleB,
- gridNumber,
- gridWidth,
- hoverLinePosition,
- hoverTime,
- isAnimationDraggerDragging,
- isDraggerDragging,
- isTimelineDragging,
- leftBound,
- leftOffset,
- midPoint,
- moved,
- numberOfVisibleTiles,
- rightBound,
- showDraggerTime,
- showHoverLine,
- transformX,
- wheelZoom
- } = this.state;
+ let {
+ // currentTimeRange,
+ dragSentinelChangeNumber,
+ dragSentinelCount,
+ gridNumber,
+ gridWidth,
+ hoverLinePosition,
+ hoverTime,
+ isAnimationDraggerDragging,
+ isDraggerDragging,
+ isTimelineDragging,
+ leftBound,
+ leftOffset,
+ midPoint,
+ moved,
+ numberOfVisibleTiles,
+ rightBound,
+ showDraggerTime,
+ showHoverLine,
+ wheelZoom
+ } = this.state;
- let checkForStateUpdates = (
- // currentTimeRange[0].rawDate === nextState.currentTimeRange[0].rawDate &&
- dragSentinelChangeNumber === nextState.dragSentinelChangeNumber &&
- dragSentinelCount === nextState.dragSentinelCount &&
- draggerPosition === nextState.draggerPosition &&
- draggerPositionB === nextState.draggerPositionB &&
- draggerTimeState === nextState.draggerTimeState &&
- draggerTimeStateB === nextState.draggerTimeStateB &&
- draggerVisible === nextState.draggerVisible &&
- draggerVisibleB === nextState.draggerVisibleB &&
- 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 &&
- numberOfVisibleTiles === nextState.numberOfVisibleTiles &&
- rightBound === nextState.rightBound &&
- showDraggerTime === nextState.showDraggerTime &&
- showHoverLine === nextState.showHoverLine &&
- transformX === nextState.transformX &&
- wheelZoom === nextState.wheelZoom
- );
+ let checkForStateUpdates = (
+ // currentTimeRange[0].rawDate === nextState.currentTimeRange[0].rawDate &&
+ dragSentinelChangeNumber === nextState.dragSentinelChangeNumber &&
+ 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 &&
+ numberOfVisibleTiles === nextState.numberOfVisibleTiles &&
+ rightBound === nextState.rightBound &&
+ showDraggerTime === nextState.showDraggerTime &&
+ showHoverLine === nextState.showHoverLine &&
+ wheelZoom === nextState.wheelZoom
+ );
- if (checkForPropsUpdates && checkForStateUpdates) {
- return false;
+ if (checkForPropsUpdates && checkForStateUpdates) {
+ return false;
+ }
}
return true;
}
@@ -1502,31 +1155,20 @@ class TimelineAxis extends Component {
draggerSelected,
axisWidth,
timeScale,
- compareModeActive,
- // isAnimationWidgetOpen,
- // animStartLocationDate,
- // animEndLocationDate,
- // timelineStartDateLimit,
- // timelineEndDateLimit,
- position
+ position,
+ transformX,
+ draggerPosition,
+ draggerPositionB,
+ draggerTimeState,
+ draggerTimeStateB
} = this.props;
let {
currentTimeRange,
gridWidth,
- // position,
leftBound,
rightBound,
leftOffset,
- transformX,
- // animationStartLocation,
- // animationEndLocation,
- draggerPosition,
- draggerPositionB,
- draggerTimeState,
- draggerTimeStateB,
- draggerVisible,
- draggerVisibleB,
isTimelineDragging,
showDraggerTime,
showHoverLine,
@@ -1536,7 +1178,6 @@ class TimelineAxis extends Component {
// ! WINDOW.MOMENT FOR DEV DEBUG ONLY
window.moment = moment;
- console.log(this.props)
return (
<React.Fragment>
<div id='wv-timeline-axis'
@@ -1588,43 +1229,6 @@ class TimelineAxis extends Component {
showHoverLine={showHoverLine}
hoverLinePosition={hoverLinePosition}
/>
-
- {/* {isAnimationWidgetOpen
- ? <TimelineRangeSelector
- startLocation={animationStartLocation}
- endLocation={animationEndLocation}
- startLocationDate={animStartLocationDate}
- endLocationDate={animEndLocationDate}
- timelineStartDateLimit={timelineStartDateLimit}
- timelineEndDateLimit={timelineEndDateLimit}
- max={{ end: false, start: false, startOffset: -50, width: 50000 }}
- pinWidth={5}
- height={45}
- onDrag={this.animationDraggerPositionUpdate}
- onHover={this.showHoverOff}
- // onRangeClick={this.setLineTime}
- onRangeClick={() => console.log('onRangeClick')}
- rangeOpacity={0.3}
- rangeColor={'#45bdff'}
- startColor={'#40a9db'}
- startTriangleColor={'#fff'}
- endColor={'#295f92'}
- endTriangleColor={'#4b7aab'} />
- : null
- } */}
-
- <DraggerContainer
- draggerSelected={draggerSelected}
- transformX={transformX}
- toggleShowDraggerTime={this.toggleShowDraggerTime}
- handleDragDragger={this.handleDragDragger}
- selectDragger={this.selectDragger}
- compareModeActive={compareModeActive}
- draggerPosition={draggerPosition}
- draggerPositionB={draggerPositionB}
- draggerVisible={draggerVisible}
- draggerVisibleB={draggerVisibleB}
- />
</svg>
: null }
diff --git a/web/js/components/timeline/timeline.css b/web/js/components/timeline/timeline.css
index 55abef73e..c9bf16ad3 100644
--- a/web/js/components/timeline/timeline.css
+++ b/web/js/components/timeline/timeline.css
@@ -226,7 +226,7 @@ line {
#wv-animation-widget {
/* position: absolute; */
- top: 60%;
+ top: 70%;
left: 50%;
}
@@ -272,3 +272,12 @@ line {
pointer-events: all;
}
+.dragger-container {
+ pointer-events: none;
+ position: absolute;
+ bottom: -87px;
+}
+
+.dragger * {
+ pointer-events: all;
+}
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index ea3f7c4f8..0d389d05e 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -7,6 +7,7 @@ import TimeScaleIntervalChange from '../../components/timeline/timeline-controls
import '../../components/timeline/timeline.css';
import TimelineAxis from '../../components/timeline/timeline-axis/timeline-axis';
import TimelineRangeSelector from '../../components/range-selection/range-selection';
+import DraggerContainer from '../../components/timeline/timeline-axis/dragger-container';
import CustomIntervalSelectorWidget from '../../components/timeline/interval-selector/interval-selector';
import util from '../../util/util';
import DateSelector from '../../components/date-selector/date-selector';
@@ -62,20 +63,41 @@ class Timeline extends React.Component {
position: 0,
transformX: 0,
frontDate: '',
+ backDate: '',
animationStartLocation: 0,
- animationEndLocation: 0
+ animationEndLocation: 0,
+ draggerTimeState: '',
+ draggerTimeStateB: '',
+ draggerPosition: 0,
+ draggerPositionB: 0,
+ draggerVisible: true,
+ draggerVisibleB: false,
+ moved: false
};
// left/right arrows
this.animator = 0;
}
- updateDynamicPositioning = (position, transformX, frontDate, animationStartLocation, animationEndLocation) => {
- console.log(position, transformX, frontDate, animationStartLocation, animationEndLocation)
-
+ updateDynamicPositioning = (
+ position,
+ transformX,
+ frontDate,
+ backDate,
+ draggerPosition,
+ draggerPoisitionB,
+ draggerVisible,
+ draggerVisibleB,
+ animationStartLocation,
+ animationEndLocation) => {
this.setState({
position,
transformX: transformX || this.state.transformX,
frontDate: frontDate || this.state.frontDate,
+ backDate: backDate || this.state.backDate,
+ draggerPosition: draggerPosition || this.state.draggerPosition,
+ draggerPoisitionB: draggerPoisitionB || this.state.draggerPoisitionB,
+ draggerVisible: draggerVisible || this.state.draggerVisible,
+ draggerVisibleB: draggerVisibleB || this.state.draggerVisibleB,
animationStartLocation: animationStartLocation || this.state.animationStartLocation,
animationEndLocation: animationEndLocation || this.state.animationEndLocation
});
@@ -233,12 +255,8 @@ class Timeline extends React.Component {
}
};
-
-
-
-
+ // handle animation date updates
updateAnimationDateAndLocation = (animationStartLocationDate, animationEndLocationDate, animationStartLocation, animationEndLocation) => {
- console.log(animationStartLocationDate)
this.setState({
animationStartLocation: animationStartLocation || this.state.animationStartLocation,
animationEndLocation: animationEndLocation || this.state.animationEndLocation
@@ -272,13 +290,43 @@ class Timeline extends React.Component {
let frontDate = moment.utc(this.state.frontDate);
let startLocation = frontDate.diff(animationStartLocationDate, timeScale, true) * gridWidth;
let endLocation = frontDate.diff(animationEndLocationDate, timeScale, true) * gridWidth;
- console.log(endLocation)
this.setState({
animationStartLocation: position - startLocation + transformX,
animationEndLocation: position - endLocation + transformX
});
}
+ // ! DRAGGER
+ updateDraggerDatePosition = (newDraggerDate, draggerSelected, draggerPosition, draggerVisible, otherDraggerVisible, moved) => {
+ console.log(newDraggerDate, draggerSelected, draggerPosition, draggerVisible, otherDraggerVisible)
+ if (draggerSelected === 'selected') {
+ this.setState({
+ draggerPosition: draggerPosition,
+ draggerVisible: draggerVisible || this.state.draggerVisible,
+ draggerVisibleB: otherDraggerVisible || this.state.draggerVisibleB,
+ draggerTimeState: newDraggerDate,
+ moved: moved
+ });
+ this.props.changeDate(new Date(newDraggerDate), 'selected');
+ } else {
+ this.setState({
+ draggerPositionB: draggerPosition,
+ draggerVisible: otherDraggerVisible || this.state.draggerVisible,
+ draggerVisibleB: draggerVisible || this.state.draggerVisibleB,
+ draggerTimeStateB: newDraggerDate,
+ moved: moved
+ });
+ this.props.changeDate(new Date(newDraggerDate), 'selectedB');
+ }
+ }
+
+ setDraggerVisibility = (draggerVisible, draggerVisibleB) => {
+ this.setState({
+ draggerVisible: draggerVisible,
+ draggerVisibleB: draggerVisibleB
+ });
+ }
+
componentDidUpdate(prevProps) {
let prevStartLocationDate = prevProps.animStartLocationDate;
let prevEndLocationDate = prevProps.animEndLocationDate;
@@ -321,7 +369,6 @@ class Timeline extends React.Component {
hideTimeline,
timeScale
} = this.props;
- console.log(this.state.animationStartLocation)
return dateA ? (
<ErrorBoundary>
<section id="timeline" className="timeline-inner clearfix">
@@ -391,11 +438,16 @@ class Timeline extends React.Component {
animEndLocationDate={animEndLocationDate}
isAnimationWidgetOpen={isAnimationWidgetOpen}
-
+ updateDraggerDatePosition={this.updateDraggerDatePosition}
+ draggerTimeState={dateA}
+ draggerTimeStateB={dateB}
+ draggerPosition={this.state.draggerPosition}
+ draggerPositionB={this.state.draggerPositionB}
+ draggerVisible={this.state.draggerVisible}
+ draggerVisibleB={this.state.draggerVisibleB}
+transformX={this.state.transformX}
updateDynamicPositioning={this.updateDynamicPositioning}
position={this.state.position}
- transformX={this.state.transformX}
- frontDate={this.state.frontDate}
animationStartLocation={this.state.animationStartLocation}
animationEndLocation={this.state.animationEndLocation}
timeScale={timeScale}
@@ -419,7 +471,7 @@ class Timeline extends React.Component {
transformX={this.state.transformX}
// onDrag={this.animationDraggerPositionUpdate}
// onHover={this.showHoverOff}
- onDrag={() => console.log('animationDraggerPositionUpdate')}
+ // onDrag={() => console.log('animationDraggerPositionUpdate')}
onHover={() => console.log('showHoverOff')}
// onRangeClick={this.setLineTime}
onRangeClick={() => console.log('onRangeClick')}
@@ -432,6 +484,31 @@ class Timeline extends React.Component {
: null
}
+ <DraggerContainer
+ timelineStartDateLimit={timelineStartDateLimit}
+ timelineEndDateLimit={timelineEndDateLimit}
+ timeScale={timeScale}
+ frontDate={this.state.frontDate}
+ backDate={this.state.backDate}
+ draggerSelected={draggerSelected}
+ transformX={this.state.transformX}
+ width={axisWidth}
+ setDraggerVisibility={this.setDraggerVisibility}
+ // toggleShowDraggerTime={this.toggleShowDraggerTime}
+ // handleDragDragger={this.handleDragDragger}
+ // selectDragger={this.selectDragger}
+ toggleShowDraggerTime={() => console.log('toggleShowDraggerTime')}
+ onChangeSelectedDragger={this.onChangeSelectedDragger}
+ updateDraggerDatePosition={this.updateDraggerDatePosition}
+ compareModeActive={compareModeActive}
+ draggerTimeState={dateA}
+ draggerTimeStateB={dateB}
+ draggerPosition={this.state.draggerPosition}
+ draggerPositionB={this.state.draggerPositionB}
+ draggerVisible={this.state.draggerVisible}
+ draggerVisibleB={this.state.draggerVisibleB}
+ />
+
{/* custom interval selector */}
<CustomIntervalSelectorWidget
customDelta={customIntervalValue}