Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

move range selection out of axis and into parent timeline, WIP

Edward Plato1b8d820de924
diff --git a/web/js/components/range-selection/dragger-range.js b/web/js/components/range-selection/dragger-range.js
index 1386afc58..b21824ae9 100644
--- a/web/js/components/range-selection/dragger-range.js
+++ b/web/js/components/range-selection/dragger-range.js
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Draggable from 'react-draggable';
/*
@@ -7,7 +7,7 @@ import Draggable from 'react-draggable';
*
* @class TimelineDraggerRange
*/
-class TimelineDraggerRange extends React.Component {
+class TimelineDraggerRange extends PureComponent {
/*
* @constructor
*/
@@ -68,8 +68,8 @@ class TimelineDraggerRange extends React.Component {
let deltaX = d.deltaX < -55 ? -55 : d.deltaX > 55 ? 55 : d.deltaX;
// +/- {number} - start position
let deltaStart = d.x;
- let startLocationDate = new Date(this.props.startLocationDate);
- let endLocationDate = new Date(this.props.endLocationDate);
+ let startLocationDate = this.props.startLocationDate;
+ let endLocationDate = this.props.endLocationDate;
let timelineEndDate = new Date(this.props.timelineEndDateLimit);
// used to determine and buffer large monthly/yearly ranges
let startDateToEndDifference = this.dateDifferenceInDays(
@@ -269,8 +269,8 @@ TimelineDraggerRange.propTypes = {
opacity: PropTypes.number,
startLocation: PropTypes.number,
endLocation: PropTypes.number,
- startLocationDate: PropTypes.string,
- endLocationDate: PropTypes.string,
+ startLocationDate: PropTypes.object,
+ endLocationDate: PropTypes.object,
timelineStartDateLimit: PropTypes.string,
timelineEndDateLimit: PropTypes.string,
deltaStart: PropTypes.number,
diff --git a/web/js/components/range-selection/dragger.js b/web/js/components/range-selection/dragger.js
index 4ecc9ffc1..3e8ec5032 100644
--- a/web/js/components/range-selection/dragger.js
+++ b/web/js/components/range-selection/dragger.js
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Draggable from 'react-draggable';
import lodashRound from 'lodash/round';
@@ -10,7 +10,7 @@ import lodashRound from 'lodash/round';
* @class TimelineDragger
* @extends React.Component
*/
-class TimelineDragger extends React.Component {
+class TimelineDragger extends PureComponent {
/*
* @constructor
*/
diff --git a/web/js/components/range-selection/range-selection.js b/web/js/components/range-selection/range-selection.js
index 331532771..412f8105c 100644
--- a/web/js/components/range-selection/range-selection.js
+++ b/web/js/components/range-selection/range-selection.js
@@ -4,6 +4,8 @@ import Dragger from './dragger.js';
import DraggerRange from './dragger-range.js';
import googleTagManager from 'googleTagManager';
+import moment from 'moment';
+import { timeScaleOptions } from '../../modules/date/constants';
/*
* A react component, is a draggable svg
* group. It is a parent component that
@@ -20,21 +22,10 @@ class TimelineRangeSelector extends React.Component {
this.state = {
startLocation: props.startLocation,
endLocation: props.endLocation,
- startLocationDate: props.startLocationDate,
- endLocationDate: props.endLocationDate,
max: props.max,
deltaStart: 0
};
}
- componentWillReceiveProps(props) {
- this.setState({
- startLocation: props.startLocation,
- endLocation: props.endLocation,
- startLocationDate: props.startLocationDate,
- endLocationDate: props.endLocationDate,
- max: props.max
- });
- }
/*
* When a child component is dragged,
* this function is called to determine
@@ -82,12 +73,11 @@ class TimelineRangeSelector extends React.Component {
return;
}
}
- this.props.onDrag(startX, endX, true);
-
this.setState({
startLocation: startX,
endLocation: endX
});
+ this.animationDraggerPositionUpdate(startX, endX, true);
}
/*
* Send callback with new locations on
@@ -98,7 +88,7 @@ class TimelineRangeSelector extends React.Component {
* @return {void}
*/
onDragStop() {
- this.props.onDrag(this.state.startLocation, this.state.endLocation, false);
+ this.animationDraggerPositionUpdate(this.state.startLocation, this.state.endLocation, false);
googleTagManager.pushEvent({
event: 'GIF_animation_dragger'
});
@@ -126,13 +116,219 @@ class TimelineRangeSelector extends React.Component {
* @return {void}
*/
onRangeDrag(d, deltaStart) {
+ let startLocation = this.state.startLocation + d;
+ let endLocation = this.state.endLocation + d;
this.setState({
- startLocation: this.state.startLocation + d,
- endLocation: this.state.endLocation + d,
+ startLocation: startLocation,
+ endLocation: endLocation,
deltaStart: deltaStart
});
- this.props.onDrag(this.state.startLocation, this.state.endLocation, true);
+ this.animationDraggerPositionUpdate(startLocation, endLocation, true);
+ }
+
+ // update animation dragger helper function
+ getAnimationLocateDateUpdate = (animLocationDate, animDraggerLocation, deltaX, { diffZeroValues, diffFactor, frontDate }) => {
+ if (!diffZeroValues) { // month or year
+ 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 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 = (draggerStartLocation, draggerEndLocation, isDragging) => {
+ let {
+ timelineStartDateLimit,
+ timelineEndDateLimit,
+ startLocationDate,
+ endLocationDate,
+ timeScale
+ } = this.props;
+
+ let {
+ startLocation,
+ endLocation
+ } = this.state;
+
+ // calculate new start and end positions
+ let deltaXStart = draggerStartLocation - startLocation;
+ let animationStartLocationDate = startLocationDate;
+ let deltaXEnd = draggerEndLocation - endLocation;
+ let animationEndLocationDate = endLocationDate;
+
+ let options = timeScaleOptions[timeScale].timeAxis;
+ // if start or end dragger has moved
+ 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 {
+ diffFactor = diffZeroValues / options.gridWidth; // else known diffFactor used
+ }
+
+ let sharedAnimLocationUpdateParams = {
+ diffZeroValues,
+ diffFactor,
+ frontDate
+ };
+ if (deltaXStart !== 0) { // update new start date
+ animationStartLocationDate = this.getAnimationLocateDateUpdate(
+ animationStartLocationDate,
+ startLocation,
+ deltaXStart,
+ sharedAnimLocationUpdateParams
+ );
+ }
+ if (deltaXEnd !== 0) { // update new end date
+ animationEndLocationDate = this.getAnimationLocateDateUpdate(
+ animationEndLocationDate,
+ endLocation,
+ 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) {
+ draggerEndLocation = endLocation;
+ animationEndLocationDate = startDateLimit;
+ }
+ if (startDate < startDateLimit) {
+ draggerStartLocation = startLocation;
+ animationStartLocationDate = startDateLimit;
+ }
+ // prevent draggers to be dragger AFTER end date limit
+ if (endDate > endDateLimit) {
+ draggerEndLocation = endLocation;
+ animationEndLocationDate = endDateLimit;
+ }
+ if (startDate > endDateLimit) {
+ 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, draggerStartLocation, draggerEndLocation);
+ }
+
+ // 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();
+ }
+
+ setInitialLocation = () => {
+ this.setState({
+ startLocation: this.props.startLocation,
+ endLocation: this.props.endLocation,
+ max: this.props.max
+ });
+ }
+
+ componentDidUpdate() {
+ let { startLocation, endLocation } = this.props;
+ if (startLocation !== this.state.startLocation || endLocation !== this.state.endLocation) {
+ this.setState({
+ startLocation: startLocation,
+ endLocation: endLocation
+ });
+ }
+ }
+
/*
* @method render
*/
@@ -151,8 +347,8 @@ class TimelineRangeSelector extends React.Component {
opacity={this.props.rangeOpacity}
startLocation={this.state.startLocation}
endLocation={this.state.endLocation}
- startLocationDate={this.state.startLocationDate}
- endLocationDate={this.state.endLocationDate}
+ startLocationDate={this.props.startLocationDate}
+ endLocationDate={this.props.endLocationDate}
timelineStartDateLimit={this.props.timelineStartDateLimit}
timelineEndDateLimit={this.props.timelineEndDateLimit}
deltaStart={this.state.deltaStart}
@@ -200,8 +396,8 @@ class TimelineRangeSelector extends React.Component {
TimelineRangeSelector.propTypes = {
startLocation: PropTypes.number,
endLocation: PropTypes.number,
- startLocationDate: PropTypes.string,
- endLocationDate: PropTypes.string,
+ startLocationDate: PropTypes.object,
+ endLocationDate: PropTypes.object,
timelineStartDateLimit: PropTypes.string,
timelineEndDateLimit: PropTypes.string,
max: PropTypes.object,
diff --git a/web/js/components/timeline/date-util.js b/web/js/components/timeline/date-util.js
index ef146eb5e..3e9f5e288 100644
--- a/web/js/components/timeline/date-util.js
+++ b/web/js/components/timeline/date-util.js
@@ -19,3 +19,17 @@ export const getDaysInYear = (date) => {
export const getISODateFormatted = (date) => {
return new Date(date).toISOString().split('.')[0] + 'Z';
};
+
+// timeRange extension to pop NUM times
+export const removeBackMultipleInPlace = (timeRange, num) => {
+ for (let i = 0; i < num; i++) {
+ timeRange.pop();
+ }
+};
+
+// timeRange extension to shift NUM times
+export const removeFrontMultipleInPlace = (timeRange, num) => {
+ for (let i = 0; i < num; i++) {
+ timeRange.shift();
+ }
+};
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index fe83a9474..fb14ca3d0 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -13,7 +13,12 @@ import TimelineRangeSelector from '../../range-selection/range-selection';
import { timeScaleOptions, timeScaleToNumberKey } from '../../../modules/date/constants';
import HoverLine from './hover-line';
-import { getIsBetween, getISODateFormatted } from '../date-util';
+import {
+ getIsBetween,
+ getISODateFormatted,
+ removeBackMultipleInPlace,
+ removeFrontMultipleInPlace
+} from '../date-util';
class TimelineAxis extends Component {
constructor(props) {
@@ -52,7 +57,7 @@ class TimelineAxis extends Component {
// animation draggers/range
// this.animationDraggerPositionUpdate = lodashDebounce(this.animationDraggerPositionUpdate.bind(this), 50, { leading: true, trailing: true });
- this.animationDraggerPositionUpdate = this.animationDraggerPositionUpdate.bind(this);
+ // this.animationDraggerPositionUpdate = this.animationDraggerPositionUpdate.bind(this);
// hover and times
this.toggleShowDraggerTime = this.toggleShowDraggerTime.bind(this);
@@ -187,6 +192,10 @@ class TimelineAxis extends Component {
rightBound = rightBound < position ? position : rightBound;
// leftBound = leftBound < position ? position : leftBound;
+ let transformX = -pixelsToAdd - 2;
+ let animationStartLocation = animationStartDraggerLocation + position - pixelsToAdd - 2;
+ let animationEndLocation = animationEndDraggerLocation + position - pixelsToAdd - 2;
+
this.setState({
draggerTimeState: draggerDateActual,
draggerTimeStateB: draggerDateActualB,
@@ -205,12 +214,12 @@ class TimelineAxis extends Component {
midPoint: position,
dragSentinelCount: 0,
showHoverLine: false,
- animationStartLocation: animationStartDraggerLocation + position - pixelsToAdd - 2,
- animationEndLocation: animationEndDraggerLocation + position - pixelsToAdd - 2,
+ animationStartLocation: animationStartLocation,
+ animationEndLocation: animationEndLocation,
leftBound,
rightBound,
wheelZoom: false
- });
+ }, this.props.updateDynamicPositioning(position, transformX, timeRange[0].rawDate, animationStartLocation, animationEndLocation));
}
// changes timeScale state
@@ -238,16 +247,16 @@ class TimelineAxis extends Component {
e.stopPropagation();
e.preventDefault();
let {
- animationStartLocation,
- animationEndLocation,
+ // animationStartLocation,
+ // animationEndLocation,
gridWidth,
dragSentinelChangeNumber,
dragSentinelCount,
draggerPosition,
draggerPositionB,
- position
+ // position
} = this.state;
- let { timeScale } = this.props;
+ let { timeScale, position, animationStartLocation, animationEndLocation } = this.props;
let deltaX = d.deltaX;
position = position + deltaX;
@@ -257,14 +266,15 @@ class TimelineAxis extends Component {
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;
this.setState({
draggerPosition,
draggerPositionB,
position,
dragSentinelCount: dragSentinelCount + deltaX,
- animationStartLocation,
- animationEndLocation
- });
+ // animationStartLocation,
+ // animationEndLocation
+ }, this.props.updateDynamicPositioning(position, null, frontDate, animationStartLocation, animationEndLocation));
} else {
if (deltaX > 0) { // dragging right - exposing past dates
if (dragSentinelCount + deltaX > dragSentinelChangeNumber) {
@@ -300,9 +310,9 @@ class TimelineAxis extends Component {
draggerVisibleB,
position,
showHoverLine: false,
- animationStartLocation,
- animationEndLocation
- });
+ // animationStartLocation,
+ // animationEndLocation
+ }, this.props.updateDynamicPositioning(position, transformX, currentTimeRange[0].rawDate, animationStartLocation, animationEndLocation));
} else {
// reset dragSentinelCount on direction change to remaining distance to dragSentinelChangeNumber
let newDragSentinelCount = dragSentinelCount < 0
@@ -314,9 +324,9 @@ class TimelineAxis extends Component {
position,
dragSentinelCount: newDragSentinelCount,
showHoverLine: false,
- animationStartLocation,
- animationEndLocation
- });
+ // animationStartLocation,
+ // animationEndLocation
+ }, this.props.updateDynamicPositioning(position, null, null, animationStartLocation, animationEndLocation));
}
} else if (deltaX < 0) { // dragging left - exposing future dates
if (dragSentinelCount + deltaX < -dragSentinelChangeNumber) {
@@ -352,9 +362,9 @@ class TimelineAxis extends Component {
draggerVisibleB,
position,
showHoverLine: false,
- animationStartLocation,
- animationEndLocation
- });
+ // animationStartLocation,
+ // animationEndLocation
+ }, this.props.updateDynamicPositioning(position, transformX, currentTimeRange[0].rawDate, animationStartLocation, animationEndLocation));
} else {
// reset dragSentinelCount on direction change to remaining distance to dragSentinelChangeNumber
let newDragSentinelCount = dragSentinelCount > 0
@@ -366,9 +376,9 @@ class TimelineAxis extends Component {
position,
dragSentinelCount: newDragSentinelCount,
showHoverLine: false,
- animationStartLocation,
- animationEndLocation
- });
+ // animationStartLocation,
+ // animationEndLocation
+ }, this.props.updateDynamicPositioning(position, null, null, animationStartLocation, animationEndLocation));
}
}
}
@@ -400,7 +410,7 @@ class TimelineAxis extends Component {
let firstDateInRange = currentTimeRange[0].rawDate;
timeRangeAdd = this.getTimeRangeArray(numberOfVisibleTiles + 1 + overDragGrids, -1, firstDateInRange);
- this.removeBackMultipleInPlace(currentTimeRange, numberOfVisibleTiles + 1 + overDragGrids);
+ removeBackMultipleInPlace(currentTimeRange, numberOfVisibleTiles + 1 + overDragGrids);
currentTimeRange.unshift(...timeRangeAdd);
transform = transformX - (numberOfVisibleTiles + 1 + overDragGrids) * gridWidth;
@@ -408,7 +418,7 @@ class TimelineAxis extends Component {
let lastDateInRange = currentTimeRange[currentTimeRange.length - 1].rawDate;
timeRangeAdd = this.getTimeRangeArray(-1, numberOfVisibleTiles + 1 + overDragGrids, lastDateInRange);
- this.removeFrontMultipleInPlace(currentTimeRange, numberOfVisibleTiles + 1 + overDragGrids);
+ removeFrontMultipleInPlace(currentTimeRange, numberOfVisibleTiles + 1 + overDragGrids);
currentTimeRange.push(...timeRangeAdd);
transform = transformX + (numberOfVisibleTiles + 1 + overDragGrids) * gridWidth;
@@ -482,19 +492,6 @@ class TimelineAxis extends Component {
};
}
- // timeRange extension to pop NUM times
- removeBackMultipleInPlace = (timeRange, num) => {
- for (let i = 0; i < num; i++) {
- timeRange.pop();
- }
- }
- // timeRange extension to shift NUM times
- removeFrontMultipleInPlace = (timeRange, num) => {
- for (let i = 0; i < num; i++) {
- timeRange.shift();
- }
- }
-
// check dragger visibility and return newDraggerPosition if dragger initially false and now visible
checkDraggerVisibility = (draggerTime, draggerVisible, newDraggerPosition, { frontDate, backDate, position, transform }) => {
let { gridWidth } = this.state;
@@ -689,6 +686,9 @@ class TimelineAxis extends Component {
rightBound = midPoint * 10;
}
+ let animationStartLocation = animationStartDraggerLocation + midPoint;
+ let animationEndLocation = animationEndDraggerLocation + midPoint;
+
this.setState({
draggerPosition: draggerPosition + midPoint - this.state.draggerWidth,
draggerVisible,
@@ -704,8 +704,8 @@ class TimelineAxis extends Component {
transformX: 0,
midPoint,
position: midPoint,
- animationStartLocation: animationStartDraggerLocation + midPoint,
- animationEndLocation: animationEndDraggerLocation + midPoint,
+ animationStartLocation: animationStartLocation,
+ animationEndLocation: animationEndLocation,
leftBound,
rightBound
@@ -756,6 +756,10 @@ class TimelineAxis extends Component {
}
componentDidUpdate(prevProps, prevState) {
+ // console.log(this.state.position, this.state.transformX, this.state.currentTimeRange[0].rawDate)
+ // console.log(this.props.position, this.props.transformX, this.props.frontDate)
+ // console.log(this.state.animationStartLocation, this.props.startLocation)
+ // console.log(this.state.animationEndLocation, this.props.endLocation)
let {
isDraggerDragging,
isAnimationDraggerDragging,
@@ -769,17 +773,17 @@ class TimelineAxis extends Component {
timeScale,
axisWidth,
compareModeActive,
- animStartLocationDate,
- animEndLocationDate
+ // animStartLocationDate,
+ // animEndLocationDate
} = this.props;
// update animation draggers from date selector input changes
- if (!isAnimationDraggerDragging) {
- if (animStartLocationDate !== prevProps.animStartLocationDate ||
- animEndLocationDate !== prevProps.animEndLocationDate) {
- this.animationDraggerDateUpdate(animStartLocationDate, animEndLocationDate);
- }
- }
+ // if (!isAnimationDraggerDragging) {
+ // if (animStartLocationDate !== prevProps.animStartLocationDate ||
+ // animEndLocationDate !== prevProps.animEndLocationDate) {
+ // this.animationDraggerDateUpdate(animStartLocationDate, animEndLocationDate);
+ // }
+ // }
// update timescale axis focus
if (timeScale !== prevProps.timeScale) {
@@ -894,7 +898,8 @@ class TimelineAxis extends Component {
let draggerPosition = draggerB ? this.state.draggerPositionB : this.state.draggerPosition;
newDraggerPosition = draggerPosition + pixelsToAddBasedOnFrontDate;
} else {
- newDraggerPosition = pixelsToAddToDraggerNew + this.state.position - this.state.draggerWidth + this.state.transformX;
+ // newDraggerPosition = pixelsToAddToDraggerNew + this.state.position - this.state.draggerWidth + this.state.transformX;
+ newDraggerPosition = pixelsToAddToDraggerNew + this.props.position - this.state.draggerWidth + this.state.transformX;
}
if (draggerB) {
@@ -924,12 +929,12 @@ class TimelineAxis extends Component {
handleStopDrag = (e, d) => {
let {
midPoint,
- position,
+ // position,
transformX,
leftBound,
rightBound
} = this.state;
- let { timeScale } = this.props;
+ let { timeScale, position } = this.props;
position = position - midPoint;
let moved = false;
@@ -946,14 +951,16 @@ class TimelineAxis extends Component {
rightBound = midPoint * 2;
}
+ transformX = transformX + position;
+
this.setState({
isTimelineDragging: false,
leftBound,
rightBound,
moved: moved,
position: midPoint,
- transformX: transformX + position
- });
+ transformX: transformX
+ }, this.props.updateDynamicPositioning(midPoint, transformX));
}
// handle dragger dragging
@@ -998,7 +1005,8 @@ class TimelineAxis extends Component {
// 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.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);
@@ -1180,163 +1188,176 @@ 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 } = 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);
- }
- }
+ // // 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;
- }
+ // 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));
+ // }
- this.setState({
- isAnimationDraggerDragging: isDragging,
- animationStartLocation: startLocation,
- animationEndLocation: endLocation,
- showHoverLine: false,
- showDraggerTime: false,
- moved: !isDragging
- }, this.animationUpdateWidget(startChanged, endChanged, animationStartLocationDate, animationEndLocationDate));
- }
+ // 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 = (startChanged, endChanged, animationStartLocationDate, animationEndLocationDate) => {
- if (startChanged) {
- if (endChanged) {
- this.props.changeAnimStartAndEndDate(animationStartLocationDate, animationEndLocationDate);
- } else {
- this.props.changeAnimStartDate(animationStartLocationDate);
- }
- } else {
- this.props.changeAnimEndDate(animationEndLocationDate);
- }
- }
+ // 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 } = 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
- });
- }
+ // 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) => {
@@ -1345,11 +1366,13 @@ class TimelineAxis extends Component {
e.persist();
requestAnimationFrame(() => {
let {
- position,
+ // position,
transformX,
gridWidth
} = this.state;
+ let { position } = this.props;
+
let target = e.target;
let clientX = e.clientX;
let boundingClientRect = target.getBoundingClientRect();
@@ -1377,8 +1400,100 @@ class TimelineAxis extends Component {
});
}
- exportPosition = () => {
- this.props.getPosition(this.state.position);
+ 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
+ );
+
+ 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 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
+ );
+
+ if (checkForPropsUpdates && checkForStateUpdates) {
+ return false;
+ }
+ return true;
}
render() {
@@ -1388,23 +1503,24 @@ class TimelineAxis extends Component {
axisWidth,
timeScale,
compareModeActive,
- isAnimationWidgetOpen,
- animStartLocationDate,
- animEndLocationDate,
- timelineStartDateLimit,
- timelineEndDateLimit
+ // isAnimationWidgetOpen,
+ // animStartLocationDate,
+ // animEndLocationDate,
+ // timelineStartDateLimit,
+ // timelineEndDateLimit,
+ position
} = this.props;
let {
currentTimeRange,
gridWidth,
- position,
+ // position,
leftBound,
rightBound,
leftOffset,
transformX,
- animationStartLocation,
- animationEndLocation,
+ // animationStartLocation,
+ // animationEndLocation,
draggerPosition,
draggerPositionB,
draggerTimeState,
@@ -1420,7 +1536,7 @@ class TimelineAxis extends Component {
// ! WINDOW.MOMENT FOR DEV DEBUG ONLY
window.moment = moment;
- // console.log(this.props)
+ console.log(this.props)
return (
<React.Fragment>
<div id='wv-timeline-axis'
@@ -1473,7 +1589,7 @@ class TimelineAxis extends Component {
hoverLinePosition={hoverLinePosition}
/>
- {isAnimationWidgetOpen
+ {/* {isAnimationWidgetOpen
? <TimelineRangeSelector
startLocation={animationStartLocation}
endLocation={animationEndLocation}
@@ -1495,7 +1611,7 @@ class TimelineAxis extends Component {
endColor={'#295f92'}
endTriangleColor={'#4b7aab'} />
: null
- }
+ } */}
<DraggerContainer
draggerSelected={draggerSelected}
@@ -1545,7 +1661,7 @@ TimelineAxis.propTypes = {
compareModeActive: PropTypes.bool,
draggerSelected: PropTypes.string,
hasSubdailyLayers: PropTypes.bool,
- isAnimationWidgetOpen: PropTypes.bool,
+ // isAnimationWidgetOpen: PropTypes.bool,
onChangeSelectedDragger: PropTypes.func,
parentOffset: PropTypes.number,
dateA: PropTypes.string,
diff --git a/web/js/components/timeline/timeline.css b/web/js/components/timeline/timeline.css
index 6e1d432e4..55abef73e 100644
--- a/web/js/components/timeline/timeline.css
+++ b/web/js/components/timeline/timeline.css
@@ -263,5 +263,12 @@ line {
#wv-timeline-range-selector {
position: absolute;
bottom: -75px;
- left: 320px;
+ /* left: 320px; */
+ overflow: hidden;
+ pointer-events: none;
+}
+
+#wv-timeline-range-selector * {
+ pointer-events: all;
}
+
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index 3ebbe081f..ea3f7c4f8 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -6,6 +6,7 @@ import ErrorBoundary from '../../containers/error-boundary';
import TimeScaleIntervalChange from '../../components/timeline/timeline-controls/interval-timescale-change';
import '../../components/timeline/timeline.css';
import TimelineAxis from '../../components/timeline/timeline-axis/timeline-axis';
+import TimelineRangeSelector from '../../components/range-selection/range-selection';
import CustomIntervalSelectorWidget from '../../components/timeline/interval-selector/interval-selector';
import util from '../../util/util';
import DateSelector from '../../components/date-selector/date-selector';
@@ -38,7 +39,8 @@ import {
} from '../../modules/animation/actions';
import {
timeScaleFromNumberKey,
- timeScaleToNumberKey
+ timeScaleToNumberKey,
+ timeScaleOptions
} from '../../modules/date/constants';
const ANIMATION_DELAY = 500;
@@ -56,11 +58,29 @@ class Timeline extends React.Component {
this.state = {
timelineHidden: false,
customIntervalModalOpen: false,
- animationInProcess: false
+ animationInProcess: false,
+ position: 0,
+ transformX: 0,
+ frontDate: '',
+ animationStartLocation: 0,
+ animationEndLocation: 0
};
// left/right arrows
this.animator = 0;
}
+
+ updateDynamicPositioning = (position, transformX, frontDate, animationStartLocation, animationEndLocation) => {
+ console.log(position, transformX, frontDate, animationStartLocation, animationEndLocation)
+
+ this.setState({
+ position,
+ transformX: transformX || this.state.transformX,
+ frontDate: frontDate || this.state.frontDate,
+ animationStartLocation: animationStartLocation || this.state.animationStartLocation,
+ animationEndLocation: animationEndLocation || this.state.animationEndLocation
+ });
+ }
+
/**
* Clear animateByIncrement's Timeout
*
@@ -213,6 +233,65 @@ class Timeline extends React.Component {
}
};
+
+
+
+
+ updateAnimationDateAndLocation = (animationStartLocationDate, animationEndLocationDate, animationStartLocation, animationEndLocation) => {
+ console.log(animationStartLocationDate)
+ this.setState({
+ animationStartLocation: animationStartLocation || this.state.animationStartLocation,
+ animationEndLocation: animationEndLocation || this.state.animationEndLocation
+ }, this.determineNecessaryAnimationDraggerUpdate(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);
+ }
+ }
+ }
+
+ // handle animation dragger location update and state update
+ animationDraggerDateUpdate = (animationStartLocationDate, animationEndLocationDate) => {
+ let { position, transformX } = this.state;
+ let { timeScale } = this.props;
+
+ let options = timeScaleOptions[timeScale].timeAxis;
+ let gridWidth = options.gridWidth;
+
+ 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
+ });
+ }
+
+ componentDidUpdate(prevProps) {
+ let prevStartLocationDate = prevProps.animStartLocationDate;
+ let prevEndLocationDate = prevProps.animEndLocationDate;
+
+ let { animStartLocationDate, animEndLocationDate } = this.props;
+ // handle location update triggered from animation start/end date change from animation widget
+ if (prevStartLocationDate && prevEndLocationDate) {
+ if (prevStartLocationDate !== animStartLocationDate || prevEndLocationDate !== animEndLocationDate) {
+ this.animationDraggerDateUpdate(animStartLocationDate, animEndLocationDate);
+ }
+ }
+ }
+
componentDidMount() {
document.addEventListener('keydown', this.handleKeyDown);
document.addEventListener('keyup', this.handleKeyUp);
@@ -239,8 +318,10 @@ class Timeline extends React.Component {
animEndLocationDate,
isAnimationWidgetOpen,
animationDisabled,
- hideTimeline
+ hideTimeline,
+ timeScale
} = this.props;
+ console.log(this.state.animationStartLocation)
return dateA ? (
<ErrorBoundary>
<section id="timeline" className="timeline-inner clearfix">
@@ -289,7 +370,7 @@ class Timeline extends React.Component {
>
{/* Timeline */}
<TimelineAxis
- {...this.props}
+ // {...this.props}
axisWidth={axisWidth}
dateA={dateA}
dateB={dateB}
@@ -302,15 +383,55 @@ class Timeline extends React.Component {
onChangeSelectedDragger={this.onChangeSelectedDragger}
timelineStartDateLimit={timelineStartDateLimit}
timelineEndDateLimit={timelineEndDateLimit}
- changeAnimStartAndEndDate={this.props.changeStartAndEndDate}
- changeAnimStartDate={this.props.changeStartDate}
- changeAnimEndDate={this.props.changeEndDate}
+ // changeAnimStartAndEndDate={this.props.changeStartAndEndDate}
+ // changeAnimStartAndEndDate={this.updateAnimationDateAndLocation}
+ // changeAnimStartDate={this.props.changeStartDate}
+ // changeAnimEndDate={this.props.changeEndDate}
animStartLocationDate={animStartLocationDate}
animEndLocationDate={animEndLocationDate}
isAnimationWidgetOpen={isAnimationWidgetOpen}
- getPosition={this.props.getPosition}
+
+
+ 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}
/>
+ {isAnimationWidgetOpen
+ ? <TimelineRangeSelector
+ timeScale={timeScale}
+ startLocation={this.state.animationStartLocation}
+ endLocation={this.state.animationEndLocation}
+ startLocationDate={animStartLocationDate}
+ endLocationDate={animEndLocationDate}
+ timelineStartDateLimit={timelineStartDateLimit}
+ timelineEndDateLimit={timelineEndDateLimit}
+ updateAnimationDateAndLocation={this.updateAnimationDateAndLocation}
+ animationDraggerDateUpdate={this.animationDraggerDateUpdate}
+ max={{ end: false, start: false, startOffset: -50, width: 50000 }}
+ 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'}
+ startTriangleColor={'#fff'}
+ endColor={'#295f92'}
+ endTriangleColor={'#4b7aab'} />
+ : null
+ }
+
{/* custom interval selector */}
<CustomIntervalSelectorWidget
customDelta={customIntervalValue}