Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

refactor timeline-axis and related, clean up constant imports

Edward Platoa0c92bdc9fd6
diff --git a/web/js/components/timeline/timeline-axis/date-calc.js b/web/js/components/timeline/timeline-axis/date-calc.js
index e888ce29d..1f1d320bd 100644
--- a/web/js/components/timeline/timeline-axis/date-calc.js
+++ b/web/js/components/timeline/timeline-axis/date-calc.js
@@ -1,87 +1,36 @@
import moment from 'moment';
-
-const timeScaleOptions = {
- 'minute': {
- timeAxis: {
- scale: 'minute',
- format: 'HH:mm'
- }
- },
- 'hour': {
- timeAxis: {
- scale: 'hour',
- // format: 'DD-HH-mm:ss',
- format: 'MMM D'
- }
- },
- 'day': {
- timeAxis: {
- scale: 'day',
- // format: 'MM-DD-HH-mm:ss-YYYY',
- format: 'MMM YYYY'
- }
- },
- 'month': {
- timeAxis: {
- scale: 'month',
- format: 'YYYY'
- }
- },
- 'year': {
- timeAxis: {
- scale: 'year',
- format: 'YYYY'
- }
- }
-};
-
-export default (function (self) {
- self.getTimeRange = (startDate, endDate, timeScale, timelineStartDateLimit, timelineEndDateLimit) => {
- // const startTime = performance.now();
- let dates = [];
- let outOfRangeFutureDateCount = 0;
- let outOfRangePastDateCount = 0;
- let { format } = timeScaleOptions[timeScale].timeAxis;
- // let currentDate = moment.utc(new Date()).add(1, timeScale);
- let startDateLimit = moment.utc(timelineStartDateLimit);
- let endDateLimit = moment.utc(timelineEndDateLimit);
-
- while (startDate <= endDate) {
- let date = startDate.format(format);
- let rawDate = startDate.format();
- let nextDate = startDate.clone().add(1, timeScale);
- let rawNextDate = nextDate.format();
-
- // # EXPENSIVE IN BETWEEN FOR LARGE NUMBERS - removing cuts function time down some, but may be neglible - main focus is smaller total request size
- let withinRange = startDate.isBetween(startDateLimit, endDateLimit, null, '[]');
- let outOfRangeFuture = startDate.isAfter(endDateLimit, timeScale);
-
- if (outOfRangeFuture) {
- outOfRangeFutureDateCount++;
- }
-
- let timeObject = {
- dateObject: startDate.toObject(),
- date: date.toUpperCase(),
- dayOfWeek: startDate.day(),
- rawDate: rawDate,
- rawNextDate: rawNextDate,
- timeScale: timeScale,
- withinRange: withinRange
- };
- dates.push(timeObject);
- startDate = nextDate;
- }
- let timeRange = {
- dates: dates,
- outOfRangeFutureDateCount: outOfRangeFutureDateCount
+import { timeScaleOptions } from '../../../modules/date/constants';
+
+export function getTimeRange(startDate, endDate, timeScale, timelineStartDateLimit, timelineEndDateLimit) {
+ let dates = [];
+ let { format } = timeScaleOptions[timeScale].timeAxis;
+ let startDateLimit = moment.utc(timelineStartDateLimit);
+ let endDateLimit = moment.utc(timelineEndDateLimit);
+
+ while (startDate <= endDate) {
+ let date = startDate.format(format);
+ let rawDate = startDate.format();
+ let nextDate = startDate.clone().add(1, timeScale);
+ let rawNextDate = nextDate.format();
+
+ let withinRange = startDate.isBetween(startDateLimit, endDateLimit, null, '[]');
+
+ let timeObject = {
+ dateObject: startDate.toObject(),
+ date: date.toUpperCase(),
+ dayOfWeek: startDate.day(),
+ rawDate: rawDate,
+ rawNextDate: rawNextDate,
+ timeScale: timeScale,
+ withinRange: withinRange
};
- // const duration = performance.now() - startTime;
- // console.log(`87 someMethodIThinkMightBeSlow took ${duration}ms`);
-
- return timeRange;
+ dates.push(timeObject);
+ startDate = nextDate;
+ }
+ let timeRange = {
+ dates: dates
};
- return self;
-})({});
+ return timeRange;
+};
diff --git a/web/js/components/timeline/timeline-axis/grid-range/grid-range.js b/web/js/components/timeline/timeline-axis/grid-range/grid-range.js
index 8b9f629a6..1a737ca11 100644
--- a/web/js/components/timeline/timeline-axis/grid-range/grid-range.js
+++ b/web/js/components/timeline/timeline-axis/grid-range/grid-range.js
@@ -35,12 +35,12 @@ const tileTextConditionOptions = {
class GridRange extends PureComponent {
render() {
- let { gridWidth, transformX, timeScale, dateArray, showHover } = this.props;
+ let { gridWidth, transformX, timeScale, timeRange, showHover } = this.props;
let tileTextCondition = tileTextConditionOptions[timeScale];
return (
<g className="gridShell" transform={`translate(${transformX}, 0)`}>
<React.Fragment>
- {dateArray.map((item, index) => {
+ {timeRange.map((item, index) => {
return (
item.withinRange
? <React.Fragment key={index}>
@@ -70,7 +70,7 @@ class GridRange extends PureComponent {
}
GridRange.propTypes = {
- dateArray: PropTypes.array,
+ timeRange: PropTypes.array,
displayDate: PropTypes.func,
gridWidth: PropTypes.number,
showHover: PropTypes.func,
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis-container.js b/web/js/components/timeline/timeline-axis/timeline-axis-container.js
deleted file mode 100644
index 9fc927422..000000000
--- a/web/js/components/timeline/timeline-axis/timeline-axis-container.js
+++ /dev/null
@@ -1,30 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import TimelineAxis from './timeline-axis';
-// import TimelineDragger from './timeline-dragger';
-
-class TimelineAxisContainer extends React.Component {
- constructor(props) {
- super(props);
- this.state = { };
- }
-
- render() {
- return (
- <React.Fragment>
- <TimelineAxis {...this.props} />
-
- {/* imported in TimelineAxis currently */}
- {/* <TimelineDragger />
- <TimelineDragger /> */}
- </React.Fragment>
- );
- };
-}
-
-TimelineAxisContainer.defaultProps = {
-};
-TimelineAxisContainer.propTypes = {
-};
-
-export default TimelineAxisContainer;
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index cca45340c..aab2951c3 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -7,66 +7,18 @@ import moment from 'moment';
import GridRange from './grid-range/grid-range';
import Dragger from './timeline-dragger';
-import dateCalc from './date-calc';
+import { getTimeRange } from './date-calc';
import TimelineRangeSelector from '../../range-selection/range-selection';
-
-const draggerWidth = 49;
-
-const timeScaleToNumberKey = {
- 'custom': 0,
- 'year': 1,
- 'month': 2,
- 'day': 3,
- 'hour': 4,
- 'minute': 5
-};
-
-const timeScaleOptions = {
- 'minute': {
- timeAxis: {
- scale: 'minute',
- gridWidth: 12,
- scaleMs: 60000
- }
- },
- 'hour': {
- timeAxis: {
- scale: 'hour',
- gridWidth: 20,
- scaleMs: 3600000
- }
- },
- 'day': {
- timeAxis: {
- scale: 'day',
- gridWidth: 12,
- scaleMs: 86400000
- }
- },
- 'month': {
- timeAxis: {
- scale: 'month',
- gridWidth: 12,
- scaleMs: null
- // scaleMs: 2678400000 - REFERENCE ONLY - 31 days
- }
- },
- 'year': {
- timeAxis: {
- scale: 'year',
- gridWidth: 12,
- scaleMs: null
- // scaleMs: 31536000000 - REFERENCE ONLY - 365 days
- }
- }
-};
+import { timeScaleOptions, timeScaleToNumberKey } from '../../../modules/date/constants';
class TimelineAxis extends React.Component {
constructor(props) {
super(props);
this.state = {
+ draggerWidth: 49,
hoverLinePosition: 0,
isDraggerDragging: false,
+ isTimelineDragging: false,
showDraggerTime: false,
dragSentinelCount: 0,
draggerPosition: 0,
@@ -81,7 +33,7 @@ class TimelineAxis extends React.Component {
draggerTimeStateB: null,
leftOffset: 0,
position: 0,
- currentDateRange: null,
+ currentTimeRange: null,
currentTransformX: 0,
gridWidth: 12,
animationStartLocation: 0,
@@ -93,7 +45,7 @@ class TimelineAxis extends React.Component {
//? how do position and transforms change between scale changes? lock into one line would be ideal
updateScale = (inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff, hoverChange) => {
// console.log(inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff, hoverChange)
- let maxDateTEMP = moment.utc(new Date());
+ let maxDateTimelineEndDateLimit = moment.utc(this.props.timelineEndDateLimit);
let options = timeScaleOptions[timeScale].timeAxis;
let gridWidth = options.gridWidth;
let axisWidth = axisWidthInput ? axisWidthInput : this.props.axisWidth;
@@ -108,14 +60,15 @@ class TimelineAxis extends React.Component {
let dragSentinelChangeNumber = gridWidth * (Math.floor(numberOfVisibleTiles * 0.25) + 1);
if (timeScale === 'year') {
gridNumber = 2020 - 1940;
+ numberOfVisibleTiles = gridNumber;
}
// Floating point issues need to be handled more cleanly
let midPoint = -((gridWidth * gridNumber) / 2) + ((numberOfVisibleTiles / 2) * gridWidth);
let hoverTime = moment.utc(this.state.hoverTime);
- if (hoverTime.isAfter(maxDateTEMP)) {
- hoverTime = maxDateTEMP;
+ if (hoverTime.isAfter(maxDateTimelineEndDateLimit)) {
+ hoverTime = maxDateTimelineEndDateLimit;
}
hoverTime = inputDate ? moment.utc(inputDate) : hoverTime;
@@ -153,12 +106,12 @@ class TimelineAxis extends React.Component {
let gridsToSubtract = Math.floor(gridNumber/2) + offSetGridsDiff;
let gridsToAdd = Math.floor(gridNumber/2) - offSetGridsDiff;
- let current = this.getDateArray(gridsToSubtract, gridsToAdd, timeScale, hoverTime);
+ let current = this.getTimeRangeArray(gridsToSubtract, gridsToAdd, timeScale, hoverTime);
let deque = new Deque(current.dates);
// get front and back dates
- let frontDate = moment.utc(deque.peekFront().rawDate);
- let backDate = moment.utc(deque.peekBack().rawDate);
+ let frontDate = moment.utc(current.dates[0].rawDate);
+ let backDate = moment.utc(current.dates[current.dates.length - 1].rawDate);
// check if dragger date is between front/back dates, null set to ignore granularity (go to ms), [] for inclusive of front/back dates
let draggerPosition = 0;
@@ -188,7 +141,7 @@ class TimelineAxis extends React.Component {
} else {
// - (offSetGridsDiff * gridWidth) to compensate off center zooming repositioning
position = +(midPoint - (axisWidth / 2 - leftOffset)).toFixed(10) - (offSetGridsDiff * gridWidth);
- if (gridNumber % 2 !== 0) {
+ if (gridNumber % 2 !== 0) { // handle odd number gridNumber grid offset
position += gridWidth/2;
}
}
@@ -215,8 +168,8 @@ class TimelineAxis extends React.Component {
let rightBound = (diffFromStartDateLimit * gridWidth) + midPoint;
if (timeScale === 'year') {
- leftBound = -position * 10;
- rightBound = position * 10;
+ leftBound = -position * 2;
+ rightBound = position * 2;
}
let currentTransformX = 0;
@@ -224,21 +177,18 @@ class TimelineAxis extends React.Component {
this.setState({
draggerTimeState: draggerDateActual.format(),
draggerTimeStateB: draggerDateActualB.format(),
- draggerPosition: draggerPosition - pixelsToAdd + position - draggerWidth,
+ draggerPosition: draggerPosition - pixelsToAdd + position - this.state.draggerWidth,
draggerVisible: draggerVisible,
- draggerPositionB: draggerPositionB - pixelsToAdd + position - draggerWidth,
+ draggerPositionB: draggerPositionB - pixelsToAdd + position - this.state.draggerWidth,
draggerVisibleB: draggerVisibleB,
deque: deque,
- currentDateRange: current.dates,
- // currentTransformX: currentTransformX,
+ currentTimeRange: current.dates,
currentTransformX: -pixelsToAdd - 2,
gridNumber: gridNumber,
gridWidth: gridWidth,
numberOfVisibleTiles: numberOfVisibleTiles,
moved: false,
dragSentinelChangeNumber: dragSentinelChangeNumber,
- // # WHY - 2 OFFSET ISSUE WITH POSITION?
- // position: position - pixelsToAdd - 2,
position: position,
midPoint: position,
dragSentinelCount: 0,
@@ -254,7 +204,7 @@ class TimelineAxis extends React.Component {
// changes timeScale state
wheelZoom = (e) => {
// e.preventDefault(); //TODO: investigate treated as passive event error/warning when on
- let timeScaleNumber = timeScaleToNumberKey[this.props.timeScale];
+ let timeScaleNumber = Number(timeScaleToNumberKey[this.props.timeScale]);
let maxTimeScaleNumber = this.props.hasSubdailyLayers ? 5 : 3;
if (e.deltaY > 0) { // wheel zoom out
if (timeScaleNumber > 1) {
@@ -301,7 +251,7 @@ class TimelineAxis extends React.Component {
if ((dragSentinelCount + deltaX) > dragSentinelChangeNumber + dragSentinelChangeNumber) {
overDrag = Math.abs((dragSentinelCount + deltaX) - dragSentinelChangeNumber - dragSentinelChangeNumber);
}
- let { currentDateRange,
+ let { currentTimeRange,
deque,
currentTransformX,
draggerVisible,
@@ -311,7 +261,7 @@ class TimelineAxis extends React.Component {
draggerPositionRevisionB } = this.updatePanelDateRange(position, timeScale, deltaX, draggerPosition, draggerPositionB, overDrag);
this.setState(() => ({
- currentDateRange: currentDateRange,
+ currentTimeRange: currentTimeRange,
deque: deque,
currentTransformX: currentTransformX,
dragSentinelCount: (dragSentinelCount + deltaX) - dragSentinelChangeNumber - (overDragGrids * gridWidth),
@@ -344,7 +294,7 @@ class TimelineAxis extends React.Component {
if ((dragSentinelCount + deltaX) < -dragSentinelChangeNumber - dragSentinelChangeNumber) {
overDrag = Math.abs((dragSentinelCount + deltaX) - -dragSentinelChangeNumber - -dragSentinelChangeNumber);
}
- let { currentDateRange,
+ let { currentTimeRange,
deque,
currentTransformX,
draggerVisible,
@@ -354,7 +304,7 @@ class TimelineAxis extends React.Component {
draggerPositionRevisionB } = this.updatePanelDateRange(position, timeScale, deltaX, draggerPosition, draggerPositionB, overDrag);
this.setState(() => ({
- currentDateRange: currentDateRange,
+ currentTimeRange: currentTimeRange,
deque: deque,
currentTransformX: currentTransformX,
dragSentinelCount: (dragSentinelCount + deltaX) - -dragSentinelChangeNumber + (overDragGrids * gridWidth),
@@ -395,38 +345,32 @@ class TimelineAxis extends React.Component {
let draggerVisibleB = this.state.draggerVisibleB;
let draggerDateActual = moment.utc(this.state.draggerTimeState);
let draggerDateActualB = this.state.draggerTimeStateB ? moment.utc(this.state.draggerTimeStateB) : null;
- let dateArrayAdd;
- let dateArray;
+ let timeRangeAdd;
+ let timeRange;
let transform;
if (deltaX > 0) { // # dragging right - exposing past dates
- let firstDateInRange = moment.utc(deque.peekFront().rawDate);
- dateArrayAdd = this.getDateArray(numberOfVisibleTiles + 1 + overDragGrids, -1, timeScale, firstDateInRange);
+ let firstDateInRange = moment.utc(this.state.currentTimeRange[0].rawDate);
+ timeRangeAdd = this.getTimeRangeArray(numberOfVisibleTiles + 1 + overDragGrids, -1, timeScale, firstDateInRange);
this.removeBackMultipleInPlace(deque, numberOfVisibleTiles + 1 + overDragGrids);
- deque.unshift(...dateArrayAdd.dates);
- dateArray = deque.toArray();
+ deque.unshift(...timeRangeAdd.dates);
+ timeRange = deque.toArray();
transform = this.state.currentTransformX - ((numberOfVisibleTiles + 1 + overDragGrids) * gridWidth);
} else { // # dragging left - exposing future dates
- let lastDateInRange = moment.utc(deque.peekBack().rawDate);
- dateArrayAdd = this.getDateArray(-1, numberOfVisibleTiles + 1 + overDragGrids, timeScale, lastDateInRange);
+ let lastDateInRange = moment.utc(this.state.currentTimeRange[this.state.currentTimeRange.length - 1].rawDate);
+ timeRangeAdd = this.getTimeRangeArray(-1, numberOfVisibleTiles + 1 + overDragGrids, timeScale, lastDateInRange);
this.removeFrontMultipleInPlace(deque, numberOfVisibleTiles + 1 + overDragGrids);
- deque.push(...dateArrayAdd.dates);
- dateArray = deque.toArray();
+ deque.push(...timeRangeAdd.dates);
+ timeRange = deque.toArray();
transform = this.state.currentTransformX + ((numberOfVisibleTiles + 1 + overDragGrids) * gridWidth);
}
// check if dragger is in between range and visible
- let frontDate = moment.utc(dateArray[0].rawDate);
- let backDate = moment.utc(dateArray[dateArray.length - 1].rawDate);
-
- let midTileDate = moment.utc(dateArray[Math.floor(dateArray.length / 2)].rawDate);
- // console.log(midTileDate)
- let timelineEndDateLimit = this.props.timelineEndDateLimit;
- let diff = midTileDate.diff(timelineEndDateLimit, timeScale);
- // console.log(diff)
+ let frontDate = moment.utc(timeRange[0].rawDate);
+ let backDate = moment.utc(timeRange[timeRange.length - 1].rawDate);
let draggerPositionRevision = draggerPosition;
let draggerPositionRevisionB = draggerPositionB;
@@ -478,7 +422,7 @@ class TimelineAxis extends React.Component {
}
return {
- currentDateRange: dateArray,
+ currentTimeRange: timeRange,
deque: deque,
currentTransformX: transform,
draggerVisible: draggerVisible,
@@ -505,11 +449,11 @@ class TimelineAxis extends React.Component {
// return date array of days based on:
// subtract - integer (negative numbers selects start date in the future)
// add - integer (negative numbers selects end date in the past)
- getDateArray = (subtract, add, timeScale, inputDate) => {
+ getTimeRangeArray = (subtract, add, timeScale, inputDate) => {
let dayZeroed;
let startDate;
let endDate;
- let dateArray;
+ let timeRangeArray;
if (timeScale ==='year') {
dayZeroed = moment.utc(inputDate).startOf('year');
@@ -528,14 +472,13 @@ class TimelineAxis extends React.Component {
startDate = dayZeroed.clone().subtract(subtract, timeScale);
endDate = dayZeroed.clone().add(add, timeScale);
}
- dateArray = dateCalc.getTimeRange(
+ timeRangeArray = getTimeRange(
startDate,
endDate,
timeScale,
this.props.timelineStartDateLimit,
this.props.timelineEndDateLimit);
- // console.log(dateArray.outOfRangeFutureDateCount)
- return dateArray;
+ return timeRangeArray;
}
// move dragger on axis click
@@ -549,7 +492,7 @@ class TimelineAxis extends React.Component {
}
if (!this.state.moved) {
let { draggerSelected } = this.props;
- let { leftOffset, hoverTime } = this.state;
+ let { leftOffset, draggerWidth, hoverTime } = this.state;
let draggerPosition = draggerSelected === 'selected' ? leftOffset - draggerWidth : this.state.draggerPosition;
let draggerPositionB = draggerSelected === 'selectedB' ? leftOffset - draggerWidth : this.state.draggerPositionB;
@@ -559,9 +502,9 @@ class TimelineAxis extends React.Component {
let draggerB = draggerSelected === 'selectedB';
//get front and back dates
- let deque = this.state.deque;
- let frontDate = moment.utc(deque.peekFront().rawDate);
- let backDate = moment.utc(deque.peekBack().rawDate);
+ let currentTimeRange = this.state.currentTimeRange;
+ let frontDate = moment.utc(currentTimeRange[0].rawDate);
+ let backDate = moment.utc(currentTimeRange[currentTimeRange.length - 1].rawDate);
if (draggerB) {
// check DRAGGER A visibility
@@ -590,7 +533,6 @@ class TimelineAxis extends React.Component {
}
componentDidMount() {
- console.log(this.props);
let axisWidth = this.props.axisWidth;
let timeScale = this.props.timeScale;
let timelineStartDateLimit = this.props.timelineStartDateLimit;
@@ -599,18 +541,8 @@ class TimelineAxis extends React.Component {
let time = moment.utc(this.props.selectedDate);
let currentDate = moment.utc(new Date());
- // let isBackDateSameOrAfterCurrentDate = time.isSameOrAfter(currentDate);
- // if (isBackDateSameOrAfterCurrentDate) {
- // let diff = time.diff(currentDate, timeScale);
- // console.log(diff)
- // }
- // console.log(timelineStartDateLimit, timelineEndDateLimit)
-
- // let diff = time.diff(timelineEndDateLimit, timeScale);
-
let diffFromEndDateLimit = time.diff(timelineEndDateLimit, timeScale);
let diffFromStartDateLimit = time.diff(timelineStartDateLimit, timeScale);
- // console.log(diff)
// format to strings
time = time.format();
@@ -648,8 +580,6 @@ class TimelineAxis extends React.Component {
let gridsToSubtract = Math.floor(gridNumber/2) + offSetGridsDiff;
let gridsToAdd = Math.floor(gridNumber/2) - offSetGridsDiff;
- // console.log(offSetGrids, offSetGridsDiff, gridsToSubtract, gridsToAdd)
-
//# get midPoint for position based on # of tiles and gridWidth
let midPoint = -((gridWidth * gridNumber) / 2) + (numberOfVisibleTiles / 2 * gridWidth);
@@ -667,7 +597,7 @@ class TimelineAxis extends React.Component {
// let pixelsToAdd = diffStartAndZeroed / diffFactor;
//# handle date array creation
- let current = this.getDateArray(Math.floor(gridNumber/2), Math.floor(gridNumber/2), timeScale, time);
+ let current = this.getTimeRangeArray(Math.floor(gridNumber/2), Math.floor(gridNumber/2), timeScale, time);
let frontDate = moment.utc(current.dates[0].rawDate);
let draggerPosition = Math.abs(frontDate.diff(draggerTime, timeScale, true) * gridWidth);
@@ -693,13 +623,13 @@ class TimelineAxis extends React.Component {
this.setState({
deque: new Deque(current.dates),
- draggerPosition: draggerPosition + midPoint - draggerWidth,
+ draggerPosition: draggerPosition + midPoint - this.state.draggerWidth,
draggerVisible: draggerVisible,
- draggerPositionB: draggerPositionB + midPoint - draggerWidth,
+ draggerPositionB: draggerPositionB + midPoint - this.state.draggerWidth,
draggerVisibleB: draggerVisibleB,
numberOfVisibleTiles: numberOfVisibleTiles,
dragSentinelChangeNumber: dragSentinelChangeNumber,
- currentDateRange: current.dates,
+ currentTimeRange: current.dates,
gridWidth: gridWidth,
draggerTimeState: time,
draggerTimeStateB: draggerTimeStateB,
@@ -760,44 +690,48 @@ class TimelineAxis extends React.Component {
}
componentDidUpdate(prevProps, prevState) {
- // console.log(prevProps.selectedDate, this.props.selectedDate, this.state.selectedDate, prevState.selectedDate)
- if (!this.state.isAnimationDraggerDragging) {
- if (this.props.animStartLocationDate !== prevProps.animStartLocationDate ||
- this.props.animEndLocationDate !== prevProps.animEndLocationDate) {
- this.animationDraggerDateUpdate(this.props.animStartLocationDate, this.props.animEndLocationDate)
- }
+ let { isDraggerDragging, isAnimationDraggerDragging, draggerTimeState, draggerTimeStateB } = this.state;
+ let { selectedDate, selectedDateB, draggerSelected, timeScale, axisWidth, compareModeActive, 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 (this.props.timeScale !== prevProps.timeScale) {
+ // update timescale axis focus
+ if (timeScale !== prevProps.timeScale) {
let draggerDate;
let leftOffset;
if (this.state.wheelZoom === true) {
draggerDate = this.state.hoverTime;
} else {
leftOffset = 0.75;
- if (this.props.draggerSelected === 'selected') {
- draggerDate = this.state.draggerTimeState;
+ if (draggerSelected === 'selected') {
+ draggerDate = draggerTimeState;
} else {
- draggerDate = this.state.draggerTimeStateB;
+ draggerDate = draggerTimeStateB;
}
}
- this.updateScale(draggerDate, this.props.timeScale, null, leftOffset, true);
+ this.updateScale(draggerDate, timeScale, null, leftOffset, true);
}
- if (this.props.axisWidth !== prevProps.axisWidth) {
- this.updateScale(null, this.props.timeScale, this.props.axisWidth);
+ // update axis on browser width change
+ if (axisWidth !== prevProps.axisWidth) {
+ this.updateScale(null, timeScale, axisWidth);
}
- if (this.props.compareModeActive !== prevProps.compareModeActive) {
+ // handle compare mode toggle change
+ if (compareModeActive !== prevProps.compareModeActive) {
// TURN ON COMPARE MODE
- // determine what dragger is selected/active at the time of turning on
- // and set date and visibility
- if (this.props.compareModeActive) {
- this.setDraggerToTime(this.props.selectedDate);
- this.setDraggerToTime(this.props.selectedDateB, true);
+ if (compareModeActive) {
+ this.setDraggerToTime(selectedDate);
+ this.setDraggerToTime(selectedDateB, true);
} else {
// TURN OFF COMPARE MODE
- let draggerSelected = this.props.draggerSelected;
+ let draggerSelected = draggerSelected;
if (draggerSelected === 'selected') {
this.setState({
draggerVisibleB: false
@@ -810,53 +744,68 @@ class TimelineAxis extends React.Component {
}
}
- if(!this.state.isDraggerDragging) {
- // # HANDLE A DRAGGER CHANGE
- // console.log(this.props.selectedDate, prevProps.selectedDate, this.state.draggerTimeState, prevState.draggerTimeState, this.props.selectedDate, prevProps.selectedDate, this.state.draggerTimeState, prevState.draggerTimeState, moment.utc(this.state.draggerTimeState).format(), moment.utc(prevState.draggerTimeState).format())
- if (this.props.selectedDate && (this.props.selectedDate !== prevProps.selectedDate ||
- this.state.draggerTimeState !== prevState.draggerTimeState ||
- moment.utc(this.state.draggerTimeState).format() !== moment.utc(prevState.draggerTimeState).format())) {
+ // handle switching A/B dragger axis focus if switched from A/B sidebar tabs
+ if (compareModeActive && (draggerSelected !== prevProps.draggerSelected)) {
+ if (draggerSelected === 'selected') {
+ let newDraggerDate = this.checkDraggerMoveOrUpdateScale(selectedDate);
+ if (!newDraggerDate.withinRange) {
+ let leftOffsetFixedCoeff = newDraggerDate.newDraggerDiff > 5 ? 0.5 : newDraggerDate.newDateInThePast ? 0.25 : 0.75;
+ this.updateScale(selectedDate, timeScale, null, leftOffsetFixedCoeff);
+ }
+ } else {
+ let newDraggerDate = this.checkDraggerMoveOrUpdateScale(selectedDateB, true);
+ if (!newDraggerDate.withinRange) {
+ let leftOffsetFixedCoeff = newDraggerDate.newDraggerDiff > 5 ? 0.5 : newDraggerDate.newDateInThePast ? 0.25 : 0.75;
+ this.updateScale(selectedDateB, timeScale, null, leftOffsetFixedCoeff);
+ }
+ }
+ }
+
+ if(!isDraggerDragging) {
+ // handle A dragger change
+ if (selectedDate && (selectedDate !== prevProps.selectedDate ||
+ draggerTimeState !== prevState.draggerTimeState ||
+ moment.utc(draggerTimeState).format() !== moment.utc(prevState.draggerTimeState).format())) {
- if (moment.utc(this.state.draggerTimeState).format() !== moment.utc(this.props.selectedDate).format()) {
+ if (moment.utc(draggerTimeState).format() !== moment.utc(selectedDate).format()) {
// check if newDraggerDate will be within acceptable visible axis width
- let newDraggerDate = this.checkDraggerMoveOrUpdateScale(this.props.selectedDate);
+ let newDraggerDate = this.checkDraggerMoveOrUpdateScale(selectedDate);
if (newDraggerDate.withinRange) {
- this.setDraggerToTime(this.props.selectedDate);
+ this.setDraggerToTime(selectedDate);
} else {
- if (this.props.draggerSelected === 'selected') {
+ if (draggerSelected === 'selected') {
let leftOffsetFixedCoeff = newDraggerDate.newDraggerDiff > 5 ? 0.5 : newDraggerDate.newDateInThePast ? 0.25 : 0.75;
- this.updateScale(this.props.selectedDate, this.props.timeScale, null, leftOffsetFixedCoeff);
+ this.updateScale(selectedDate, timeScale, null, leftOffsetFixedCoeff);
}
}
}
}
- // # HANDLE B DRAGGER CHANGE
- if (this.props.selectedDateB && (this.props.selectedDateB !== prevProps.selectedDateB ||
- this.state.draggerTimeStateB !== prevState.draggerTimeStateB ||
- moment.utc(this.state.draggerTimeStateB).format() !== moment.utc(prevState.draggerTimeStateB).format())) {
+ // handle B dragger change
+ if (selectedDateB && (selectedDateB !== prevProps.selectedDateB ||
+ draggerTimeStateB !== prevState.draggerTimeStateB ||
+ moment.utc(draggerTimeStateB).format() !== moment.utc(prevState.draggerTimeStateB).format())) {
- if (moment.utc(this.state.draggerTimeStateB).format() !== moment.utc(this.props.selectedDateB).format()) {
+ if (moment.utc(draggerTimeStateB).format() !== moment.utc(selectedDateB).format()) {
// check if newDraggerDate will be within acceptable visible axis width
- let newDraggerDate = this.checkDraggerMoveOrUpdateScale(this.props.selectedDateB, true);
+ let newDraggerDate = this.checkDraggerMoveOrUpdateScale(selectedDateB, true);
if (newDraggerDate.withinRange) {
- this.setDraggerToTime(this.props.selectedDateB, true);
+ this.setDraggerToTime(selectedDateB, true);
} else {
- if (this.props.draggerSelected === 'selectedB') {
+ if (draggerSelected === 'selectedB') {
let leftOffsetFixedCoeff = newDraggerDate.newDraggerDiff > 5 ? 0.5 : newDraggerDate.newDateInThePast ? 0.25 : 0.75;
- this.updateScale(this.props.selectedDateB, this.props.timeScale, null, leftOffsetFixedCoeff);
+ this.updateScale(selectedDateB, timeScale, null, leftOffsetFixedCoeff);
}
}
}
}
}
-
}
// move draggerTimeState to inputTime
setDraggerToTime = (inputTime, draggerB) => {
- let frontDate = moment.utc(this.state.deque.peekFront().rawDate);
- let backDate = moment.utc(this.state.deque.peekBack().rawDate);
+ let frontDate = moment.utc(this.state.currentTimeRange[0].rawDate);
+ let backDate = moment.utc(this.state.currentTimeRange[this.state.currentTimeRange.length - 1].rawDate);
let draggerTime = draggerB ? this.state.draggerTimeStateB : this.state.draggerTimeState;
let draggerTimeState = moment.utc(draggerTime, 'YYYY-MM-DDTHH:mm:ss.SSSZ');
let draggerTimeStateAdded = moment.utc(inputTime);
@@ -878,7 +827,7 @@ class TimelineAxis extends React.Component {
let draggerPosition = draggerB ? this.state.draggerPositionB : this.state.draggerPosition;
newDraggerPosition = draggerPosition + pixelsToAddBasedOnFrontDate;
} else {
- newDraggerPosition = pixelsToAddToDraggerNew + this.state.position - draggerWidth + this.state.currentTransformX;
+ newDraggerPosition = pixelsToAddToDraggerNew + this.state.position - this.state.draggerWidth + this.state.currentTransformX;
}
if (draggerB) {
@@ -896,43 +845,42 @@ class TimelineAxis extends React.Component {
}
}
- // handle stop drag of axis
+ // handle start drag of axis
+ handleStartDrag = () => {
+ this.setState({
+ isTimelineDragging: true
+ })
+ }
+
+ // handle stop drag of axis
// moved === false means an axis click
handleStopDrag = (e, d) => {
- let timeScale = this.props.timeScale;
- // let options = timeScaleOptions[timeScale].timeAxis;
- // let gridWidth = options.gridWidth;
-
- // // let time = moment.utc(this.props.selectedDate);
- // let currentDateRangeLength = this.state.deque.length;
- // let midTileDate = moment.utc(this.state.deque.get(Math.floor(currentDateRangeLength / 2)).rawDate);
- // // console.log(midTileDate)
- // let time = moment.utc(new Date());
- // let timelineEndDateLimit = this.props.timelineEndDateLimit;
- // let diff = midTileDate.diff(timelineEndDateLimit, timeScale);
-
- let midPoint = this.state.midPoint;
- let position = this.state.position - midPoint;
+ let { midPoint, position, currentTransformX, leftBound, rightBound } = this.state;
+ let { timeScale } = this.props;
+
+ position = position - midPoint;
let moved = false;
// drag left OR drag right
if (d.x < midPoint || d.x > midPoint) {
moved = true;
}
- let leftBound = this.state.leftBound + (midPoint - d.x);
- let rightBound = this.state.rightBound + (midPoint - d.x);
+ leftBound = leftBound + (midPoint - d.x);
+ rightBound = rightBound + (midPoint - d.x);
if (timeScale === 'year') {
- leftBound = -midPoint * 10;
- rightBound = midPoint * 10;
+ leftBound = -midPoint * 2;
+ rightBound = midPoint * 2;
}
this.setState({
+ showHoverLine: true,
+ isTimelineDragging: false,
leftBound: leftBound,
rightBound: rightBound,
moved: moved,
position: midPoint,
- currentTransformX: this.state.currentTransformX + position,
+ currentTransformX: currentTransformX + position,
})
}
@@ -973,9 +921,9 @@ class TimelineAxis extends React.Component {
let diffZeroValues = options.scaleMs;
if (!diffZeroValues) {
// calculate based on frontDate due to varying number of days per month and per year (leapyears)
- let frontDate = moment.utc(this.state.deque.peekFront().rawDate);
+ let frontDate = moment.utc(this.state.currentTimeRange[0].rawDate);
// ! -2 necessary from subtracting 2 from currentTransformX in updateScale ?
- let draggerPositionRelativeToFrontDate = draggerWidth - 2 + draggerPosition - this.state.position - this.state.currentTransformX;
+ let draggerPositionRelativeToFrontDate = this.state.draggerWidth - 2 + draggerPosition - this.state.position - this.state.currentTransformX;
let gridWidthCoef = draggerPositionRelativeToFrontDate/gridWidth;
let draggerDateAdded = frontDate.clone().add((Math.floor(gridWidthCoef)), timeScale);
let daysCount;
@@ -1013,7 +961,7 @@ class TimelineAxis extends React.Component {
// overDrag = Math.abs((dragSentinelCount + deltaX) - -dragSentinelChangeNumber - -dragSentinelChangeNumber);
// }
// //# NEED TO PASS NEGATIVE OF DELTAX FOR UPDATE PANEL
- // let { currentDateRange,
+ // let { currentTimeRange,
// deque,
// currentTransformX,
// draggerVisible,
@@ -1022,7 +970,7 @@ class TimelineAxis extends React.Component {
// draggerPositionRevision } = this.updatePanelDateRange(position, timeScale, -deltaX, draggerPosition, overDrag);
// this.setState({
- // currentDateRange: currentDateRange,
+ // currentTimeRange: currentTimeRange,
// deque: deque,
// currentTransformX: currentTransformX,
// draggerPosition: -48,
@@ -1052,7 +1000,7 @@ class TimelineAxis extends React.Component {
// overDrag = Math.abs((dragSentinelCount + deltaX) - dragSentinelChangeNumber - dragSentinelChangeNumber);
// }
// //# NEED TO PASS NEGATIVE OF DELTAX FOR UPDATE PANEL
- // let { currentDateRange,
+ // let { currentTimeRange,
// deque,
// currentTransformX,
// draggerVisible,
@@ -1061,7 +1009,7 @@ class TimelineAxis extends React.Component {
// draggerPositionRevision } = this.updatePanelDateRange(position, timeScale, -deltaX, draggerPosition, overDrag);
// this.setState({
- // currentDateRange: currentDateRange,
+ // currentTimeRange: currentTimeRange,
// deque: deque,
// currentTransformX: currentTransformX,
// draggerPosition: axisWidth - 50,
@@ -1153,16 +1101,41 @@ class TimelineAxis extends React.Component {
})
}
+ // update animation dragger helper function
+ getAnimationLocateDateUpdate = (diffZeroValues, diffFactor, deltaX, animationStartLocationDate, animationDraggerLocation, frontDate ) => {
+ if (!diffZeroValues) { // month or year
+ let { position, currentTransformX, gridWidth, } = this.state;
+ let { timeScale } = this.props;
+
+ let startDraggerPositionRelativeToFrontDate = animationDraggerLocation - position - currentTransformX + deltaX;
+ let gridWidthCoef = startDraggerPositionRelativeToFrontDate / gridWidth;
+ let draggerDateAdded = frontDate.clone().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;
+ return draggerDateAdded.clone().add(remainderMilliseconds).format();
+ } else {
+ let draggerTimeStartValue = moment.utc(animationStartLocationDate).valueOf();
+ return moment.utc(draggerTimeStartValue + (diffFactor * deltaX)).format();
+ }
+ }
+
// handle animation dragger drag change
animationDraggerPositionUpdate = (startLocation, endLocation, stopDragging) => {
let isDragging = stopDragging ? false : true;
- let timeScale = this.props.timeScale;
- let gridWidth = this.state.gridWidth;
+ let { animationStartLocation, animationEndLocation, gridWidth } = this.state;
+ let { timelineStartDateLimit, timelineEndDateLimit, animStartLocationDate, animEndLocationDate, timeScale } = this.props;
+
// calculate new start and end positions
- let deltaXStart = startLocation - this.state.animationStartLocation;
- let animationStartLocationDate = this.props.animStartLocationDate;
- let deltaXEnd = endLocation - this.state.animationEndLocation;
- let animationEndLocationDate = this.props.animEndLocationDate;
+ let deltaXStart = startLocation - animationStartLocation;
+ let animationStartLocationDate = animStartLocationDate;
+ let deltaXEnd = endLocation - animationEndLocation;
+ let animationEndLocationDate = animEndLocationDate;
// if start or end dragger has moved
if (deltaXStart !== 0 || deltaXEnd !== 0) {
@@ -1172,70 +1145,51 @@ class TimelineAxis extends React.Component {
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.deque.peekFront().rawDate);
+ frontDate = moment.utc(this.state.currentTimeRange[0].rawDate);
} else {
diffFactor = diffZeroValues / gridWidth; // else known diffFactor used
}
if (deltaXStart !== 0) { // update new start date
- if (!diffZeroValues) { // month or year
- let startDraggerPositionRelativeToFrontDate = this.state.animationStartLocation - this.state.position - this.state.currentTransformX + deltaXStart;
- let gridWidthCoef = startDraggerPositionRelativeToFrontDate / gridWidth;
- let draggerDateAdded = frontDate.clone().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;
- animationStartLocationDate = draggerDateAdded.clone().add(remainderMilliseconds).format();
-
- } else {
- let draggerTimeStartValue = moment.utc(animationStartLocationDate).valueOf();
- animationStartLocationDate = moment.utc(draggerTimeStartValue + (diffFactor * deltaXStart)).format();
- }
+ animationStartLocationDate = this.getAnimationLocateDateUpdate(
+ diffZeroValues,
+ diffFactor,
+ deltaXStart,
+ animationStartLocationDate,
+ animationStartLocation,
+ frontDate
+ );
}
if (deltaXEnd !== 0) { // update new end date
- if (!diffZeroValues) { // month or year
- let endDraggerPositionRelativeToFrontDate = this.state.animationEndLocation - this.state.position - this.state.currentTransformX + deltaXEnd;
- let gridWidthCoef = endDraggerPositionRelativeToFrontDate / gridWidth;
- let draggerDateAdded = frontDate.clone().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;
- animationEndLocationDate = draggerDateAdded.clone().add(remainderMilliseconds).format();
- } else {
- let draggerTimeEndValue = moment.utc(animationEndLocationDate).valueOf();
- animationEndLocationDate = moment.utc(draggerTimeEndValue + (diffFactor * deltaXEnd)).format();
- }
+ animationEndLocationDate = this.getAnimationLocateDateUpdate(
+ diffZeroValues,
+ diffFactor,
+ deltaXEnd,
+ animationEndLocationDate,
+ animationEndLocation,
+ frontDate
+ );
}
}
// ! controlled within range-selection component using max props
// prevent draggers to be dragger BEFORE start date limit
- if (moment.utc(animationEndLocationDate).isBefore(this.props.timelineStartDateLimit, timeScale)) {
- endLocation = this.state.animationEndLocation;
- animationEndLocationDate = this.props.timelineStartDateLimit;
- } else if (moment.utc(animationStartLocationDate).isBefore(this.props.timelineStartDateLimit, timeScale)) {
- startLocation = this.state.animationStartLocation;
- animationStartLocationDate = this.props.timelineStartDateLimit;
+ if (moment.utc(animationEndLocationDate).isBefore(timelineStartDateLimit, timeScale)) {
+ endLocation = animationEndLocation;
+ animationEndLocationDate = timelineStartDateLimit;
+ } else if (moment.utc(animationStartLocationDate).isBefore(timelineStartDateLimit, timeScale)) {
+ startLocation = animationStartLocation;
+ animationStartLocationDate = timelineStartDateLimit;
}
// prevent draggers to be dragger AFTER end date limit
- if (moment.utc(animationEndLocationDate).isAfter(this.props.timelineEndDateLimit, timeScale)) {
- endLocation = this.state.animationEndLocation;
- animationEndLocationDate = this.props.animEndLocationDate;
- } else if (moment.utc(animationStartLocationDate).isAfter(this.props.timelineEndDateLimit, timeScale)) {
- startLocation = this.state.animationStartLocation;
- animationStartLocationDate = this.props.timelineEndDateLimit;
+ if (moment.utc(animationEndLocationDate).isAfter(timelineEndDateLimit, timeScale)) {
+ endLocation = animationEndLocation;
+ animationEndLocationDate = animEndLocationDate;
+ } else if (moment.utc(animationStartLocationDate).isAfter(timelineEndDateLimit, timeScale)) {
+ startLocation = animationStartLocation;
+ animationStartLocationDate = timelineEndDateLimit;
}
// need props function to handle state update?!
@@ -1253,18 +1207,16 @@ class TimelineAxis extends React.Component {
// handle animation dragger location update and state update
animationDraggerDateUpdate = (animationStartLocationDate, animationEndLocationDate) => {
- let timeScale = this.props.timeScale;
- let gridWidth = this.state.gridWidth;
- let position = this.state.position;
- let frontDate = moment.utc(this.state.deque.peekFront().rawDate);
+ let { gridWidth, position, currentTransformX } = 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;
- // console.log(startLocation, endLocation)
this.setState({
- animationStartLocation: position - startLocation + this.state.currentTransformX,
- animationEndLocation: position - endLocation + this.state.currentTransformX
+ animationStartLocation: position - startLocation + currentTransformX,
+ animationEndLocation: position - endLocation + currentTransformX
})
}
@@ -1274,11 +1226,14 @@ class TimelineAxis extends React.Component {
e.stopPropagation();
e.persist();
requestAnimationFrame(() => {
+ let { position, currentTransformX } = this.state;
+ let { timeScale } = this.props;
+
let target = e.target;
let clientX = e.clientX;
let boundingClientRect = target.getBoundingClientRect();
let xHoverPositionInCurrentGrid = Math.floor(clientX) - Math.floor(boundingClientRect.left);
- let options = timeScaleOptions[this.props.timeScale].timeAxis;
+ let options = timeScaleOptions[timeScale].timeAxis;
let gridWidth = options.gridWidth;
let currentDateValue = moment.utc(itemDate).valueOf();
@@ -1288,7 +1243,7 @@ class TimelineAxis extends React.Component {
let displayDate = moment.utc(currentDateValue + (xHoverPositionInCurrentGrid * diffFactor)).format();
this.displayDate(displayDate, clientX);
this.setState({
- hoverLinePosition: index * gridWidth + xHoverPositionInCurrentGrid + this.state.currentTransformX + this.state.position
+ hoverLinePosition: index * gridWidth + xHoverPositionInCurrentGrid + currentTransformX + position
})
})
}
@@ -1310,7 +1265,7 @@ class TimelineAxis extends React.Component {
onMouseOver={(e) => this.showHoverOn(e)}
onMouseLeave={this.showHoverOff}
>
- {this.state.currentDateRange ?
+ {this.state.currentTimeRange ?
<svg className="inner"
id="timeline-footer-svg"
width={this.props.axisWidth}
@@ -1332,6 +1287,7 @@ class TimelineAxis extends React.Component {
axis="x"
onDrag={this.handleDrag.bind(this)}
position={{ x: this.state.position, y: 0 }}
+ onStart={this.handleStartDrag.bind(this)}
onStop={this.handleStopDrag.bind(this)}
bounds={{left: this.state.leftBound, top: 0, bottom: 0, right: this.state.rightBound}}
>
@@ -1341,12 +1297,12 @@ class TimelineAxis extends React.Component {
timeScale={this.props.timeScale}
displayDate={this.displayDate}
gridWidth={this.state.gridWidth}
- dateArray={this.state.currentDateRange}
+ timeRange={this.state.currentTimeRange}
transformX={this.state.currentTransformX} />
</g>
</Draggable>
- <line className="svgLine" style={{display: this.state.showHoverLine ? 'block' : 'none'}}
+ <line className="svgLine" style={{display: !this.state.isTimelineDragging && this.state.showHoverLine ? 'block' : 'none'}}
stroke="blue" strokeWidth="2" strokeOpacity="0.48" x1="0" x2="0" y1="0" y2="63"
transform={`translate(${this.state.hoverLinePosition + 1}, 0)`} shapeRendering="optimizeSpeed"/>
@@ -1432,7 +1388,7 @@ class TimelineAxis extends React.Component {
className="dateToolTip"
style={{
transform: `translate(${draggerTimeLeftOffest}px, -100px)`,
- display: this.state.showDraggerTime && this.state.draggerTimeState ? 'block' : 'none',
+ display: !this.state.isTimelineDragging && this.state.showDraggerTime && this.state.draggerTimeState ? 'block' : 'none',
// opacity: this.state.showDraggerTime && this.state.draggerTimeState ? '1' : '0',
width: this.props.hasSubdailyLayers ? '220px' : '115px'
}}
@@ -1450,7 +1406,7 @@ class TimelineAxis extends React.Component {
className="dateToolTip"
style={{
transform: `translate(${hoverTimeLeftOffset}px, -100px)`,
- display: !this.state.showDraggerTime && this.state.showHoverLine ? 'block' : 'none',
+ display: !this.state.isTimelineDragging && !this.state.showDraggerTime && this.state.showHoverLine ? 'block' : 'none',
// opacity: !this.state.showDraggerTime && this.state.showHoverLine ? '1' : '0',
width: this.props.hasSubdailyLayers ? '220px' : '115px'
}}
diff --git a/web/js/components/timeline/timeline-controls/axis-timescale-change.js b/web/js/components/timeline/timeline-controls/axis-timescale-change.js
index 3717b9783..77c190e2f 100644
--- a/web/js/components/timeline/timeline-controls/axis-timescale-change.js
+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change.js
@@ -1,15 +1,7 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import AxisTimeScaleChangeControls from './axis-timescale-change-controls';
-
-const timeScaleToNumberKey = {
- 'custom': 0,
- 'year': 1,
- 'month': 2,
- 'day': 3,
- 'hour': 4,
- 'minute': 5
-};
+import { timeScaleToNumberKey } from '../../../modules/date/constants';
/*
* Parent element for timeScale change controls and tooltip
diff --git a/web/js/components/timeline/timeline-controls/interval-timescale-change.js b/web/js/components/timeline/timeline-controls/interval-timescale-change.js
index 974a44cfb..3105be1db 100644
--- a/web/js/components/timeline/timeline-controls/interval-timescale-change.js
+++ b/web/js/components/timeline/timeline-controls/interval-timescale-change.js
@@ -125,7 +125,6 @@ class TimeScaleIntervalChange extends Component {
</div>
</div>
</div>
-
</React.Fragment>
);
}
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index 607b149f0..54cfd9b0c 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -162,6 +162,12 @@ class Timeline extends React.Component {
this.props.toggleActiveCompareState();
}
+ // update range of animation draggers
+ updateAnimationRange = (startDate, endDate) => {
+ // ! PLACE HOLDER - OLD VERSION
+ // ui.anim.rangeselect.updateRange(startDate, endDate, true);
+ };
+
render() {
const {
dateFormatted,
@@ -247,8 +253,7 @@ class Timeline extends React.Component {
onChangeSelectedDragger={this.onChangeSelectedDragger.bind(this)}
timelineStartDateLimit={timelineStartDateLimit}
timelineEndDateLimit={timelineEndDateLimit}
- updateAnimationRange={() => {
- }}
+ updateAnimationRange={this.updateAnimationRange.bind(this)}
animStartLocationDate={animStartLocationDate}
animEndLocationDate={animEndLocationDate}
isAnimationWidgetOpen={isAnimationWidgetOpen}
diff --git a/web/js/modules/date/constants.js b/web/js/modules/date/constants.js
index e1d945598..441868d22 100644
--- a/web/js/modules/date/constants.js
+++ b/web/js/modules/date/constants.js
@@ -12,7 +12,6 @@ export const timeScaleFromNumberKey = {
'4': 'hour',
'5': 'minute'
};
-
export const timeScaleToNumberKey = {
custom: '0',
year: '1',
@@ -21,3 +20,47 @@ export const timeScaleToNumberKey = {
hour: '4',
minute: '5'
};
+export const timeScaleOptions = {
+ 'minute': {
+ timeAxis: {
+ scale: 'minute',
+ format: 'HH:mm',
+ gridWidth: 12,
+ scaleMs: 60000
+ }
+ },
+ 'hour': {
+ timeAxis: {
+ scale: 'hour',
+ format: 'MMM D',
+ gridWidth: 20,
+ scaleMs: 3600000
+ }
+ },
+ 'day': {
+ timeAxis: {
+ scale: 'day',
+ format: 'MMM YYYY',
+ gridWidth: 12,
+ scaleMs: 86400000
+ }
+ },
+ 'month': {
+ timeAxis: {
+ scale: 'month',
+ format: 'YYYY',
+ gridWidth: 12,
+ scaleMs: null
+ // scaleMs: 2678400000 - REFERENCE ONLY - 31 days
+ }
+ },
+ 'year': {
+ timeAxis: {
+ scale: 'year',
+ format: 'YYYY',
+ gridWidth: 12,
+ scaleMs: null
+ // scaleMs: 31536000000 - REFERENCE ONLY - 365 days
+ }
+ }
+};