Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

revise updateScale change for wheelzoom vs selecting timescale from panel, fix animation start date based on selected interval of first opening, hide caret to double chevron, move blue line

Edward Plato4bc74b47f146
diff --git a/web/js/animation/range-select.js b/web/js/animation/range-select.js
index 72c9e1883..f966e815c 100644
--- a/web/js/animation/range-select.js
+++ b/web/js/animation/range-select.js
@@ -1,9 +1,18 @@
import React from 'react';
import ReactDOM from 'react-dom';
import RangeSelector from '../components/range-selection/range-selection';
-import d3 from 'd3';
+// import d3 from 'd3';
import util from '../util/util';
+const timeScaleFromNumberKey = {
+ '0': 'custom',
+ '1': 'year',
+ '2': 'month',
+ '3': 'day',
+ '4': 'hour',
+ '5': 'minute'
+};
+
export function animationRangeSelect(models, config, ui) {
var self = {};
var model;
@@ -77,46 +86,48 @@ export function animationRangeSelect(models, config, ui) {
// TODO: Pull in new dragger pick
// var pick = d3.select('#guitarpick');
// var pickWidth = pick.node().getBoundingClientRect().width;
- var pickWidth = 50;
+ // var pickWidth = 50;
// var animEndLocation =
// d3.transform(pick.attr('transform')).translate[0] - pickWidth / 2; // getting guitar pick location
- var animEndLocation = 300;
+ // var animEndLocation = 300;
if (model.rangeState.startDate) {
startLocation = self.getLocationFromStringDate(
model.rangeState.startDate
);
endLocation = self.getLocationFromStringDate(model.rangeState.endDate);
} else {
- startLocation = animEndLocation - 100;
- endLocation = animEndLocation;
+ // startLocation = animEndLocation - 100;
+ // endLocation = animEndLocation;
+ startLocation = 0;
+ endLocation = 0;
self.updateRange(startLocation, endLocation);
}
- options = {
- // startLocation: startLocation, // or zero
- // endLocation: endLocation,
- startLocation: -250, // or zero
- endLocation: -260,
- startLocationDate: model.rangeState.startDate,
- endLocationDate: model.rangeState.endDate,
- timelineStartDateLimit: timelineStartDateLimit,
- timelineEndDateLimit: timelineEndDateLimit,
- max: self.getMaxWidth(),
- startColor: '#40a9db',
- endColor: '#295f92',
- startTriangleColor: '#fff',
- endTriangleColor: '#4b7aab',
- rangeColor: '#45bdff',
- rangeOpacity: 0.3,
- pinWidth: 5,
- height: 45,
- onDrag: self.updateRange,
- onRangeClick: self.onRangeClick
- };
- self.reactComponent = ReactDOM.render(
- React.createElement(RangeSelector, options),
- $mountLocation[0]
- );
+ // options = {
+ // // startLocation: startLocation, // or zero
+ // // endLocation: endLocation,
+ // startLocation: -250, // or zero
+ // endLocation: -260,
+ // startLocationDate: model.rangeState.startDate,
+ // endLocationDate: model.rangeState.endDate,
+ // timelineStartDateLimit: timelineStartDateLimit,
+ // timelineEndDateLimit: timelineEndDateLimit,
+ // max: self.getMaxWidth(),
+ // startColor: '#40a9db',
+ // endColor: '#295f92',
+ // startTriangleColor: '#fff',
+ // endTriangleColor: '#4b7aab',
+ // rangeColor: '#45bdff',
+ // rangeOpacity: 0.3,
+ // pinWidth: 5,
+ // height: 45,
+ // onDrag: self.updateRange,
+ // onRangeClick: self.onRangeClick
+ // };
+ // self.reactComponent = ReactDOM.render(
+ // React.createElement(RangeSelector, options),
+ // $mountLocation[0]
+ // );
};
/*
@@ -149,7 +160,7 @@ export function animationRangeSelect(models, config, ui) {
*/
self.getLocationFromStringDate = function(date) {
// return timeline.x(util.roundTimeTenMinute(date));
- return -200;
+ // return -200;
};
/*
@@ -164,8 +175,8 @@ export function animationRangeSelect(models, config, ui) {
*/
self.update = function() {
// being called from timeline.config.js
- var props = self.updateOptions();
- self.reactComponent.setState(props);
+ // var props = self.updateOptions();
+ // self.reactComponent.setState(props);
};
/*
@@ -261,8 +272,10 @@ export function animationRangeSelect(models, config, ui) {
self.updateRange = function(startLocation, EndLocation, TEST) {
// var startDate = util.roundTimeTenMinute(timeline.x.invert(startLocation));
// var endDate = util.roundTimeTenMinute(timeline.x.invert(EndLocation));
- var startDate = new Date();
+ let selectedZoom = timeScaleFromNumberKey[models.date.selectedZoom];
+ var startDate = util.dateAdd(new Date(), selectedZoom, -7);
var endDate = new Date();
+
if (TEST) {
startDate = new Date(startLocation);
endDate = new Date(EndLocation);
diff --git a/web/js/animation/widget.js b/web/js/animation/widget.js
index 0c229afcd..e9e9b16ef 100644
--- a/web/js/animation/widget.js
+++ b/web/js/animation/widget.js
@@ -325,6 +325,10 @@ export function animationWidget(models, config, ui) {
*
*/
self.onPressPlay = function() {
+ let hasSubDaily = models.layers.hasSubDaily();
+ if (!hasSubDaily) {
+ self.setZeroDateTimes();
+ }
model.rangeState.playing = true;
model.events.trigger('play');
};
@@ -460,17 +464,16 @@ export function animationWidget(models, config, ui) {
*
*/
self.setZeroDateTimes = function() {
-// let state = model.rangeState;
-// let startDate = util.parseDateUTC(state.startDate);
-// let endDate = util.parseDateUTC(state.endDate);
-// debugger;
-// util.clearTimeUTC(startDate);
-// util.clearTimeUTC(endDate);
+ let state = model.rangeState;
+ let startDate = util.parseDateUTC(state.startDate);
+ let endDate = util.parseDateUTC(state.endDate);
+ util.clearTimeUTC(startDate);
+ util.clearTimeUTC(endDate);
-// // save changes to model
-// model.rangeState.startDate = util.toISOStringSeconds(startDate);
-// model.rangeState.endDate = util.toISOStringSeconds(endDate);
-// model.events.trigger('change');
+ // save changes to model
+ model.rangeState.startDate = util.toISOStringSeconds(startDate);
+ model.rangeState.endDate = util.toISOStringSeconds(endDate);
+ model.events.trigger('change');
};
self.init();
diff --git a/web/js/components/range-selection/dragger-range.js b/web/js/components/range-selection/dragger-range.js
index 671cc54bf..68a6d222c 100644
--- a/web/js/components/range-selection/dragger-range.js
+++ b/web/js/components/range-selection/dragger-range.js
@@ -228,7 +228,7 @@ class TimelineDraggerRange extends React.Component {
cursor: 'pointer'
}}
// height={this.props.height}
- height={30}
+ height={65}
className='dragger-range'
id={this.props.draggerID}
onClick={this.handleDraggerClick.bind(this)}
diff --git a/web/js/components/range-selection/range-selection.js b/web/js/components/range-selection/range-selection.js
index 9bf02540c..54a91d664 100644
--- a/web/js/components/range-selection/range-selection.js
+++ b/web/js/components/range-selection/range-selection.js
@@ -138,7 +138,7 @@ class TimelineRangeSelector extends React.Component {
*/
render() {
return (
- <svg id="wv-timeline-range-selector" className="wv-timeline-range-selector">
+ <svg id="wv-timeline-range-selector" className="wv-timeline-range-selector" onMouseEnter={this.props.onHover}>
<DraggerRange
opacity={this.props.rangeOpacity}
startLocation={this.state.startLocation}
@@ -197,6 +197,7 @@ TimelineRangeSelector.propTypes = {
pinWidth: PropTypes.number,
height: PropTypes.number,
onDrag: PropTypes.func,
+ onHover: PropTypes.func,
onRangeClick: PropTypes.func,
rangeOpacity: PropTypes.number,
rangeColor: PropTypes.string,
diff --git a/web/js/components/timeline/interval-selector/interval-selector.js b/web/js/components/timeline/interval-selector/interval-selector.js
index c878d2b78..4ec72f59d 100644
--- a/web/js/components/timeline/interval-selector/interval-selector.js
+++ b/web/js/components/timeline/interval-selector/interval-selector.js
@@ -73,8 +73,10 @@ class CustomIntervalSelectorWidget extends PureComponent {
id="wv-animation-widget-custom-interval"
onKeyDown={this.handleKeyPress}
className='wv-animation-widget-custom-interval'
- style={{display: this.props.customIntervalModalOpen ? 'block' : 'none',
- left: this.props.hasSubdailyLayers ? '-258px' : '-153px'}}
+ // style={{display: this.props.customIntervalModalOpen ? 'block' : 'none',
+ // left: this.props.hasSubdailyLayers ? '-258px' : '-153px'}}
+ style={{display: this.props.customIntervalModalOpen ? 'block' : 'none'}}
+ // left: this.props.hasSubdailyLayers ? '-258px' : '-153px'}}
>
<div>Custom Interval Selector</div>
diff --git a/web/js/components/timeline/timeline-axis/date-calc.js b/web/js/components/timeline/timeline-axis/date-calc.js
index fca4e1ef3..e888ce29d 100644
--- a/web/js/components/timeline/timeline-axis/date-calc.js
+++ b/web/js/components/timeline/timeline-axis/date-calc.js
@@ -40,6 +40,8 @@ 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);
@@ -53,6 +55,11 @@ export default (function (self) {
// # 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(),
@@ -67,7 +74,8 @@ export default (function (self) {
startDate = nextDate;
}
let timeRange = {
- dates: dates
+ dates: dates,
+ outOfRangeFutureDateCount: outOfRangeFutureDateCount
};
// const duration = performance.now() - startTime;
// console.log(`87 someMethodIThinkMightBeSlow took ${duration}ms`);
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 fb08cfc06..690858541 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
@@ -9,32 +9,32 @@ class GridRange extends PureComponent {
constructor(props) {
super(props);
this.state = {
- hoverLinePosition: 0
+ // hoverLinePosition: 0
}
}
- showHover = (e, itemDate, nextDate, index) => {
- e.preventDefault();
- e.stopPropagation();
- e.persist();
- requestAnimationFrame(() => {
- let target = e.target;
- let clientX = e.clientX;
- let boundingClientRect = target.getBoundingClientRect();
- let xHoverPositionInCurrentGrid = Math.floor(clientX) - Math.floor(boundingClientRect.left);
- let gridWidth = this.props.gridWidth;
+ // showHover = (e, itemDate, nextDate, index) => {
+ // e.preventDefault();
+ // e.stopPropagation();
+ // e.persist();
+ // requestAnimationFrame(() => {
+ // let target = e.target;
+ // let clientX = e.clientX;
+ // let boundingClientRect = target.getBoundingClientRect();
+ // let xHoverPositionInCurrentGrid = Math.floor(clientX) - Math.floor(boundingClientRect.left);
+ // let gridWidth = this.props.gridWidth;
- let currentDateValue = moment.utc(itemDate).valueOf();
- let nextDateValue = moment.utc(nextDate).valueOf();
- let diff = nextDateValue - currentDateValue;
- let diffFactor = diff / gridWidth; // gridWidth
- let displayDate = moment.utc(currentDateValue + (xHoverPositionInCurrentGrid * diffFactor)).format();
- this.props.displayDate(displayDate, clientX);
- this.setState({
- hoverLinePosition: index * gridWidth + xHoverPositionInCurrentGrid
- })
- })
- }
+ // let currentDateValue = moment.utc(itemDate).valueOf();
+ // let nextDateValue = moment.utc(nextDate).valueOf();
+ // let diff = nextDateValue - currentDateValue;
+ // let diffFactor = diff / gridWidth; // gridWidth
+ // let displayDate = moment.utc(currentDateValue + (xHoverPositionInCurrentGrid * diffFactor)).format();
+ // this.props.displayDate(displayDate, clientX);
+ // this.setState({
+ // hoverLinePosition: index * gridWidth + xHoverPositionInCurrentGrid
+ // })
+ // })
+ // }
componentDidUpdate(prevProps, prevState) {
}
@@ -47,11 +47,11 @@ class GridRange extends PureComponent {
timeScale={this.props.timeScale}
dateArray={this.props.dateArray}
gridWidth={gridWidth}
- showHover={this.showHover}
+ showHover={this.props.showHover}
/>
- <line className="svgLine" style={{display: this.props.showHoverLine ? 'block' : 'none'}}
- stroke="blue" strokeWidth="2" strokeOpacity="0.48" x1="0" x2="0" y1="0" y2="74"
- transform={`translate(${this.state.hoverLinePosition + 1}, 0)`} shapeRendering="optimizeSpeed"/>
+ {/* <line className="svgLine" style={{display: this.props.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"/> */}
</g>
)
}
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index 52eb95e27..e1f27418b 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -56,6 +56,7 @@ class TimelineAxis extends React.Component {
constructor(props) {
super(props);
this.state = {
+ hoverLinePosition: 0,
isDraggerDragging: false,
showDraggerTime: false,
dragSentinelCount: 0,
@@ -73,26 +74,24 @@ class TimelineAxis extends React.Component {
position: 0,
currentDateRange: null,
currentTransformX: 0,
- gridWidth: 100,
+ gridWidth: 12,
animationStartLocation: 0,
animationEndLocation: 0,
- isAnimationDraggerDragging: false
+ isAnimationDraggerDragging: false,
+ wheelZoom: false
}
}
//? how do position and transforms change between scale changes? lock into one line would be ideal
- updateScale = (inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff) => {
+ updateScale = (inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff, hoverChange) => {
// console.log(inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff)
let maxDateTEMP = moment.utc(new Date());
let options = timeScaleOptions[timeScale].timeAxis;
let gridWidth = options.gridWidth;
let axisWidth = axisWidthInput ? axisWidthInput : this.props.axisWidth;
let leftOffset = leftOffsetFixedCoeff ? axisWidth * leftOffsetFixedCoeff : this.state.leftOffset;
- // debugger;
if (leftOffset === 0) {
leftOffset = axisWidth / 2;
}
- // console.log(leftOffset,axisWidth)
- // console.log(leftOffset, this.state.draggerPosition)
let numberOfVisibleTiles = Number((axisWidth / gridWidth).toFixed(8));
let gridNumber = Math.floor(numberOfVisibleTiles * 1.5); // should get from state?
@@ -119,11 +118,11 @@ class TimelineAxis extends React.Component {
let draggerDateActual;
let draggerDateActualB;
if (this.props.draggerSelected === 'selected') {
- draggerDateActual = moment.utc(inputDate ? inputDate : this.state.draggerTimeState);
+ draggerDateActual = hoverChange ? moment.utc(this.state.draggerTimeState) : moment.utc(inputDate ? inputDate : this.state.draggerTimeState);
draggerDateActualB = moment.utc(this.state.draggerTimeStateB);
} else {
draggerDateActual = moment.utc(this.state.draggerTimeState);
- draggerDateActualB = moment.utc(inputDate ? inputDate : this.state.draggerTimeStateB);
+ draggerDateActualB = hoverChange ? moment.utc(this.state.draggerTimeStateB) : moment.utc(inputDate ? inputDate : this.state.draggerTimeStateB);
}
// value of hover time, hover time timeunit zeroed, hover time next unit timeunit zeroed
@@ -189,19 +188,24 @@ class TimelineAxis extends React.Component {
}
// update animation draggers
- let animationStartLocationDate;
let animationStartDraggerLocation;
- let animationEndLocationDate;
let animationEndDraggerLocation;
if (true || this.props.startLocationDate) {
- // animationStartLocationDate = moment.utc(this.props.startLocationDate);
- animationStartLocationDate = this.props.animStartLocationDate;
- animationStartDraggerLocation = Math.abs(frontDate.diff(animationStartLocationDate, timeScale, true) * gridWidth);
+ animationStartDraggerLocation = Math.abs(frontDate.diff(this.props.animStartLocationDate, timeScale, true) * gridWidth);
+ animationEndDraggerLocation = Math.abs(frontDate.diff(this.props.animEndLocationDate, timeScale, true) * gridWidth);
+ }
- // animationEndLocationDate = moment.utc(this.props.endLocationDate);
- animationEndLocationDate = this.props.animEndLocationDate;
- animationEndDraggerLocation = Math.abs(frontDate.diff(animationEndLocationDate, timeScale, true) * gridWidth);
+ // get axis bounds
+ let timelineStartDateLimit = this.props.timelineStartDateLimit;
+ let timelineEndDateLimit = this.props.timelineEndDateLimit;
+ let diff = hoverTime.diff(timelineEndDateLimit, timeScale);
+ let leftBound = (diff * gridWidth) + midPoint;
+ let rightBound = 5000;
+
+ if (timeScale === 'year') {
+ leftBound = position;
+ rightBound = position;
}
let currentTransformX = 0;
@@ -230,8 +234,9 @@ class TimelineAxis extends React.Component {
showHoverLine: false,
animationStartLocation: animationStartDraggerLocation + position -pixelsToAdd - 2,
animationEndLocation: animationEndDraggerLocation + position -pixelsToAdd - 2,
- // animationStartLocationDate: animationStartLocationDate,
- // animationEndLocationDate: animationEndLocationDate
+ leftBound: leftBound,
+ rightBound: rightBound,
+ wheelZoom: false
})
}
@@ -243,12 +248,17 @@ class TimelineAxis extends React.Component {
if (e.deltaY > 0) { // wheel zoom out
if (arrayIndex > 0) {
let nextGreaterTimeScale = timeScales[arrayIndex - 1];
- this.props.changeTimescale(nextGreaterTimeScale);
+ this.setState({
+ wheelZoom: true
+ }, this.props.changeTimescale(nextGreaterTimeScale))
}
} else {
if (arrayIndex < maxIndex) { // wheel zoom in
let nextSmallerTimeScale = timeScales[arrayIndex + 1];
- this.props.changeTimescale(nextSmallerTimeScale);
+ // this.props.changeTimescale(nextSmallerTimeScale);
+ this.setState({
+ wheelZoom: true
+ }, this.props.changeTimescale(nextSmallerTimeScale))
}
}
}
@@ -404,6 +414,12 @@ class TimelineAxis extends React.Component {
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 draggerPositionRevision = draggerPosition;
let draggerPositionRevisionB = draggerPositionB;
@@ -510,11 +526,13 @@ class TimelineAxis extends React.Component {
timeScale,
this.props.timelineStartDateLimit,
this.props.timelineEndDateLimit);
+ console.log(dateArray.outOfRangeFutureDateCount)
return dateArray;
}
// move dragger on axis click
setLineTime = (e) => {
+ console.log(e, this.state.hoverTime)
e.preventDefault();
e.stopPropagation();
//TODO: handle stop bubbling up to parent wv-timeline-axis to prevent invoking on clicking draggers
@@ -563,6 +581,9 @@ class TimelineAxis extends React.Component {
componentDidMount() {
let axisWidth = this.props.axisWidth;
let timeScale = this.props.timeScale;
+ let timelineStartDateLimit = this.props.timelineStartDateLimit;
+ let timelineEndDateLimit = this.props.timelineEndDateLimit;
+
let time = moment.utc(this.props.selectedDate);
let currentDate = moment.utc(new Date());
@@ -571,6 +592,10 @@ class TimelineAxis extends React.Component {
// let diff = time.diff(currentDate, timeScale);
// console.log(diff)
// }
+ console.log(timelineStartDateLimit, timelineEndDateLimit)
+
+ let diff = time.diff(timelineEndDateLimit, timeScale);
+ console.log(diff)
// format to strings
time = time.format();
@@ -587,7 +612,7 @@ class TimelineAxis extends React.Component {
//# calculate number of grids viewable based on axisWidth and gridWidth of timeScale
let numberOfVisibleTiles = Number((axisWidth / gridWidth).toFixed(8));
-
+ let leftOffset = axisWidth * 0.90;
// let draggerPosition = tilesTillSelectedDAte * gridWidth - draggerWidth; //# CENTER DRAGGER A
let draggerVisible = true;
@@ -601,6 +626,15 @@ class TimelineAxis extends React.Component {
let gridNumber = Math.floor(numberOfVisibleTiles * 1.5);
let dragSentinelChangeNumber = gridWidth * (Math.floor(numberOfVisibleTiles * 0.25) + 1);
+ //! offset grids needed since each zoom in won't be centered
+ let offSetGrids = Math.floor(leftOffset / gridWidth);
+ let offSetGridsDiff = offSetGrids - Math.floor(numberOfVisibleTiles / 2);
+
+ let gridsToSubtract = Math.floor(gridNumber/2) + offSetGridsDiff;
+ let gridsToAdd = Math.floor(gridNumber/2) - offSetGridsDiff;
+
+ console.log(offSetGrids, offSetGridsDiff, gridsToSubtract, gridsToAdd)
+
//# get midPoint for position based on # of tiles and gridWidth
let midPoint = -((gridWidth * gridNumber) / 2) + (numberOfVisibleTiles / 2 * gridWidth);
@@ -625,19 +659,21 @@ class TimelineAxis extends React.Component {
let draggerPositionB = Math.abs(frontDate.diff(moment.utc(draggerTimeStateB), timeScale, true) * gridWidth);
// animation dragger positioning
- let animationStartLocationDate;
let animationStartDraggerLocation;
- let animationEndLocationDate;
let animationEndDraggerLocation;
if (true || this.props.startLocationDate) {
- animationStartLocationDate = this.props.animStartLocationDate;
- // animationStartLocationDate = '2019-04-26T18:00:00Z';
- animationStartDraggerLocation = Math.abs(frontDate.diff(animationStartLocationDate, timeScale, true) * gridWidth);
+ animationStartDraggerLocation = Math.abs(frontDate.diff(this.props.animStartLocationDate, timeScale, true) * gridWidth);
+ animationEndDraggerLocation = Math.abs(frontDate.diff(this.props.animEndLocationDate, timeScale, true) * gridWidth);
+ }
+
+ // get axis bounds
+ let leftBound = (diff * gridWidth) + midPoint;
+ let rightBound = 5000;
- animationEndLocationDate = this.props.animEndLocationDate;
- // animationEndLocationDate = '2019-05-02T00:00:00Z';
- animationEndDraggerLocation = Math.abs(frontDate.diff(animationEndLocationDate, timeScale, true) * gridWidth);
+ if (timeScale === 'year') {
+ leftBound = 0;
+ rightBound = 0;
}
this.setState({
@@ -658,12 +694,12 @@ class TimelineAxis extends React.Component {
position: midPoint,
animationStartLocation: animationStartDraggerLocation + midPoint,
animationEndLocation: animationEndDraggerLocation + midPoint,
- // animationStartLocationDate: animationStartLocationDate,
- // animationEndLocationDate: animationEndLocationDate
+ leftBound: leftBound,
+ rightBound: rightBound
+
+ }, function() {
+ this.updateScale(time, timeScale, this.props.axisWidth, 0.90)
})
- // }, function() {
- // this.updateScale(time, timeScale, this.props.axisWidth, 0.90)
- // })
}
shouldComponentUpdate(nextProps, nextState) {
@@ -718,7 +754,19 @@ class TimelineAxis extends React.Component {
}
if (this.props.timeScale !== prevProps.timeScale) {
- this.updateScale(null, this.props.timeScale);
+ let draggerDate;
+ let leftOffset;
+ if (this.state.wheelZoom === true) {
+ draggerDate = this.state.hoverTime;
+ } else {
+ leftOffset = 0.5;
+ if (this.props.draggerSelected === 'selected') {
+ draggerDate = this.state.draggerTimeState;
+ } else {
+ draggerDate = this.state.draggerTimeStateB;
+ }
+ }
+ this.updateScale(draggerDate, this.props.timeScale, null, leftOffset, true);
}
if (this.props.axisWidth !== prevProps.axisWidth) {
@@ -749,6 +797,7 @@ 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())) {
@@ -760,6 +809,7 @@ class TimelineAxis extends React.Component {
this.setDraggerToTime(this.props.selectedDate);
} else {
if (this.props.draggerSelected === 'selected') {
+ debugger;
let leftOffsetFixedCoeff = newDraggerDate.newDraggerDiff > 5 ? 0.5 : newDraggerDate.newDateInThePast ? 0.25 : 0.75;
this.updateScale(this.props.selectedDate, this.props.timeScale, null, leftOffsetFixedCoeff);
}
@@ -835,6 +885,19 @@ class TimelineAxis extends React.Component {
// 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 moved = false;
@@ -842,7 +905,16 @@ class TimelineAxis extends React.Component {
if (d.x < midPoint || d.x > midPoint) {
moved = true;
}
+
+ let leftBound = (diff * gridWidth)
+ if (Math.abs(diff) < Math.floor(currentDateRangeLength / 2)) {
+ console.log('hit')
+ leftBound = midPoint
+ }
+
+ console.log(diff, leftBound, Math.floor(currentDateRangeLength / 2), ((diff * gridWidth)))
this.setState({
+ leftBound: leftBound,
moved: moved,
position: midPoint,
currentTransformX: this.state.currentTransformX + position,
@@ -891,7 +963,14 @@ class TimelineAxis extends React.Component {
diffZeroValues = draggerTimeNextZeroValue - draggerTimeZeroValue;
}
let diffFactor = diffZeroValues / gridWidth;
- let newDraggerTime = moment.utc(draggerTimeValue + (diffFactor * deltaX)).format();
+ let newDraggerTime = moment.utc(draggerTimeValue + (diffFactor * deltaX));
+
+ if (newDraggerTime.isAfter(this.props.timelineEndDateLimit, timeScale) ||
+ newDraggerTime.isBefore(this.props.timelineStartDateLimit, timeScale)) {
+ return false;
+ } else {
+ newDraggerTime = newDraggerTime.format();
+ }
// handle drag timeline
// // TODO: fix drag off current view - doesn't drag/update date of hover properly
@@ -1021,8 +1100,9 @@ class TimelineAxis extends React.Component {
}
// show hover line
- showHoverOn = () => {
- if (!this.state.showDraggerTime) {
+ showHoverOn = (e) => {
+ // console.log(e.target, e.target.className.animVal)
+ if (e.target.className.animVal === 'grid' && !this.state.showDraggerTime) {
this.setState({
showHoverLine: true
});
@@ -1046,13 +1126,13 @@ class TimelineAxis extends React.Component {
}
//TODO: dynamic bounds to stop axis from dragging too far
- // getLeftAxisBound = () => {
- // return -200;
- // }
+ getLeftAxisBound = () => {
+ return -200;
+ }
- // getRightAxisBound = () => {
- // return 200;
- // }
+ getRightAxisBound = () => {
+ return 200;
+ }
// handle animation dragger drag change
animationDraggerPositionUpdate = (startLocation, endLocation, stopDragging) => {
@@ -1097,7 +1177,10 @@ class TimelineAxis extends React.Component {
this.setState({
isAnimationDraggerDragging: isDragging,
animationStartLocation: startLocation,
- animationEndLocation: endLocation
+ animationEndLocation: endLocation,
+ showHoverLine: false,
+ showDraggerTime: false
+
}, function() {
this.props.updateAnimationRange(animationStartLocationDate, animationEndLocationDate)
})
@@ -1120,18 +1203,43 @@ class TimelineAxis extends React.Component {
})
}
+ // handle svg blue line hover
+ showHover = (e, itemDate, nextDate, index) => {
+ e.preventDefault();
+ e.stopPropagation();
+ e.persist();
+ requestAnimationFrame(() => {
+ 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 gridWidth = options.gridWidth;
+
+ let currentDateValue = moment.utc(itemDate).valueOf();
+ let nextDateValue = moment.utc(nextDate).valueOf();
+ let diff = nextDateValue - currentDateValue;
+ let diffFactor = diff / gridWidth;
+ let displayDate = moment.utc(currentDateValue + (xHoverPositionInCurrentGrid * diffFactor)).format();
+ this.displayDate(displayDate, clientX);
+ this.setState({
+ hoverLinePosition: index * gridWidth + xHoverPositionInCurrentGrid + this.state.currentTransformX + this.state.position
+ })
+ })
+ }
+
render() {
let draggerTimeLeftOffest = this.props.draggerSelected === 'selected'
- ? this.state.draggerPosition - (this.props.hasSubdailyLayers ? 33 : 3)
- : this.state.draggerPositionB - (this.props.hasSubdailyLayers ? 33 : 3);
- let hoverTimeLeftOffset = this.props.hasSubdailyLayers ? this.state.leftOffset - 82 : this.state.leftOffset - 52;
+ ? this.state.draggerPosition - (this.props.hasSubdailyLayers ? 44 : 8)
+ : this.state.draggerPositionB - (this.props.hasSubdailyLayers ? 44 : 8);
+ let hoverTimeLeftOffset = this.props.hasSubdailyLayers ? this.state.leftOffset - 93 : this.state.leftOffset - 57;
return (
<React.Fragment>
<div id="wv-timeline-axis"
style={{width: `${this.props.axisWidth}px`}}
onMouseUp={(e) => this.setLineTime(e)}
onWheel={(e) => this.wheelZoom(e)}
- onMouseOver={this.showHoverOn}
+ onMouseOver={(e) => this.showHoverOn(e)}
onMouseLeave={this.showHoverOff}
>
{this.state.currentDateRange ?
@@ -1159,11 +1267,13 @@ class TimelineAxis extends React.Component {
position={{ x: this.state.position, y: 0 }}
onStop={this.handleStopDrag.bind(this)}
// bounds={{ left: this.getLeftAxisBound(), top: 0, bottom: 0, right: this.getRightAxisBound() }}
- // bounds={{left: -200, top: 0, bottom: 0, right: 200}}
+ // bounds={{left: -400, top: 0, bottom: 0, right: 0}}
+ // bounds={{left: this.state.leftBound, top: 0, bottom: 0, right: this.state.rightBound}}
>
<g>
<GridRange
- showHoverLine={this.state.showHoverLine}
+ // showHoverLine={this.state.showHoverLine}
+ showHover={this.showHover}
timeScale={this.props.timeScale}
displayDate={this.displayDate}
gridWidth={this.state.gridWidth}
@@ -1172,7 +1282,10 @@ class TimelineAxis extends React.Component {
</g>
</Draggable>
- {/* //? INSERT RANGE SELECTION HERE */}
+ <line className="svgLine" style={{display: 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"/>
+
{this.props.isAnimationWidgetOpen ?
<TimelineRangeSelector
startLocation={this.state.animationStartLocation}
@@ -1181,12 +1294,12 @@ class TimelineAxis extends React.Component {
endLocationDate={this.props.animEndLocationDate}
timelineStartDateLimit={this.props.timelineStartDateLimit}
timelineEndDateLimit={this.props.timelineEndDateLimit}
- max={{end: false, start: false, startOffset: -50, width: this.props.axisWidth}}
+ max={{end: false, start: false, startOffset: -50, width: 50000}}
pinWidth={5}
height={45}
- // onDrag={(sx, ex) => console.log('onDrag', sx, ex)}
onDrag={this.animationDraggerPositionUpdate.bind(this)}
- onRangeClick={() => console.log('onRangeClick')}
+ onHover={this.showHoverOff}
+ onRangeClick={this.setLineTime.bind(this)}
rangeOpacity={0.3}
rangeColor={"#45bdff"}
startColor={"#40a9db"}
@@ -1256,13 +1369,14 @@ class TimelineAxis extends React.Component {
style={{
transform: `translate(${draggerTimeLeftOffest}px, -100px)`,
display: this.state.showDraggerTime && this.state.draggerTimeState ? 'block' : 'none',
- width: this.props.hasSubdailyLayers ? '170px' : '110px'
+ // opacity: this.state.showDraggerTime && this.state.draggerTimeState ? '1' : '0',
+ width: this.props.hasSubdailyLayers ? '185px' : '115px'
}}
>
{ this.state.showDraggerTime && this.state.draggerTimeState
? this.props.draggerSelected === 'selected'
- ? this.props.hasSubdailyLayers ? this.state.draggerTimeState : this.state.draggerTimeState.split('T')[0]
- : this.props.hasSubdailyLayers ? this.state.draggerTimeStateB : this.state.draggerTimeStateB.split('T')[0]
+ ? this.props.hasSubdailyLayers ? this.state.draggerTimeState.split('T').join(' ') : this.state.draggerTimeState.split('T')[0]
+ : this.props.hasSubdailyLayers ? this.state.draggerTimeStateB.split('T').join(' ') : this.state.draggerTimeStateB.split('T')[0]
: null
}
</div>
@@ -1273,11 +1387,12 @@ class TimelineAxis extends React.Component {
style={{
transform: `translate(${hoverTimeLeftOffset}px, -100px)`,
display: !this.state.showDraggerTime && this.state.showHoverLine ? 'block' : 'none',
- width: this.props.hasSubdailyLayers ? '170px' : '110px'
+ // opacity: !this.state.showDraggerTime && this.state.showHoverLine ? '1' : '0',
+ width: this.props.hasSubdailyLayers ? '185px' : '115px'
}}
>
{ !this.state.showDraggerTime && this.state.hoverTime
- ? this.props.hasSubdailyLayers ? this.state.hoverTime : this.state.hoverTime.split('T')[0]
+ ? this.props.hasSubdailyLayers ? this.state.hoverTime.split('T').join(' ') : this.state.hoverTime.split('T')[0]
: null
}
</div>
diff --git a/web/js/components/timeline/timeline.css b/web/js/components/timeline/timeline.css
index 388fea1eb..53419b9c8 100644
--- a/web/js/components/timeline/timeline.css
+++ b/web/js/components/timeline/timeline.css
@@ -14,6 +14,7 @@ html, body {
#wv-timeline-axis {
height: 70px;
+ border-top: 1.5px solid white;
}
.inner {
@@ -22,21 +23,23 @@ html, body {
display: flex;
flex-direction: row;
align-items: center;
- border-top: 1.5px solid white;
+ /* border-top: 1.5px solid white; */
/* -webkit-clip-path: url('#timelineBoundary');
clip-path: url('#timelineBoundary'); */
}
.dateToolTip {
- background: rgb(233, 233, 233);
- border: thin solid #555;
- font-size: 16px;
+ background: #212121;
+ color: #fff;
+ border: thin solid #666;
+ font-size: 18px;
text-align: center;
border-radius: 5px;
- width: 110px;
+ width: 115px;
height: 25px;
line-height: 25px;
white-space: nowrap;
+ /* transition: opacity 0.2s ease-in; */
}
.gridShell {
@@ -201,21 +204,46 @@ form select {
color: #7890cd !important;
}
-.wv-timeline-hide-arrow {
- vertical-align: middle;
+.wv-timeline-hide {
+ /* vertical-align: middle; */
display: block;
- margin: 26px 0 0 7px;
+ /* margin: 26px 0 0 7px; */
+ top: 18px;
+ right: -5px;
color: white;
cursor: pointer;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
user-select: none;
+ height: 30px;
+ width: 30px;
}
+.wv-timeline-hide-double-chevron-left {
+ position: absolute;
+ background: url(../../../images/icon-sprite.svg) -206px -3px no-repeat;
+ border-radius: 0;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ border-right: 0;
+ transform: rotate(90deg);
+}
+
+.wv-timeline-hide-double-chevron-right {
+ position: absolute;
+ background: url(../../../images/icon-sprite.svg) -206px -3px no-repeat;
+ border-radius: 0;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ border-right: 0;
+ transform: rotate(270deg);
+}
-#timeline-hide:hover .wv-timeline-hide-arrow {
- color: #1a1a1a;
- background: white;
+#timeline-hide:hover .wv-timeline-hide-double-chevron-left,
+#timeline-hide:hover .wv-timeline-hide-double-chevron-right,
+.wv-timeline-hide-double-chevron-left:hover,
+.wv-timeline-hide-double-chevron-right:hover {
+ background-position: -206px -63px;
}
.timeline-hamburger-date {
@@ -241,8 +269,8 @@ form select {
border-top-right-radius: 8px;
background: #212121;
position: absolute;
- top: -113px;
- left: -153px;
+ top: -111px;
+ left: 0;
display: none;
color: #fff;
border-bottom: 2px solid #444;
diff --git a/web/js/components/timeline/timeline.js b/web/js/components/timeline/timeline.js
index 45f939538..f703305b1 100644
--- a/web/js/components/timeline/timeline.js
+++ b/web/js/components/timeline/timeline.js
@@ -167,16 +167,6 @@ class Timeline extends React.Component {
timeScaleChangeUnit={this.state.timeScaleChangeUnit}
/>
- {/* custom interval selector */}
- <CustomIntervalSelectorWidget
- customIntervalValue={this.state.customIntervalValue}
- customIntervalZoomLevel={this.state.customIntervalZoomLevel}
- toggleCustomIntervalModal={this.toggleCustomIntervalModal}
- customIntervalModalOpen={this.state.customIntervalModalOpen}
- setIntervalChangeUnit={this.setIntervalChangeUnit}
- hasSubdailyLayers={this.state.hasSubdailyLayers}
- />
-
<DateChangeArrows
leftArrowDown={() => this.incrementDate(-1)}
leftArrowUp={this.props.stopper}
@@ -212,6 +202,16 @@ class Timeline extends React.Component {
animEndLocationDate={this.state.animEndLocationDate}
isAnimationWidgetOpen={this.state.isAnimationWidgetOpen}
/>
+
+ {/* custom interval selector */}
+ <CustomIntervalSelectorWidget
+ customIntervalValue={this.state.customIntervalValue}
+ customIntervalZoomLevel={this.state.customIntervalZoomLevel}
+ toggleCustomIntervalModal={this.toggleCustomIntervalModal}
+ customIntervalModalOpen={this.state.customIntervalModalOpen}
+ setIntervalChangeUnit={this.setIntervalChangeUnit}
+ hasSubdailyLayers={this.state.hasSubdailyLayers}
+ />
</div>
{/* Zoom Level Change */}
@@ -226,9 +226,9 @@ class Timeline extends React.Component {
{/* 🍔 Open/Close Chevron 🍔 */}
<div id="timeline-hide" onClick={this.toggleHideTimeline}>
{this.state.timelineHidden ?
- <i className="fas fa-chevron-right wv-timeline-hide-arrow"></i>
+ <div className="wv-timeline-hide wv-timeline-hide-double-chevron-left"></div>
:
- <i className="fas fa-chevron-left wv-timeline-hide-arrow"></i>
+ <div className="wv-timeline-hide wv-timeline-hide-double-chevron-right"></div>
}
</div>
</React.Fragment>
diff --git a/web/js/date/timeline.js b/web/js/date/timeline.js
index 4f8f73a65..0414a5a6b 100644
--- a/web/js/date/timeline.js
+++ b/web/js/date/timeline.js
@@ -485,7 +485,7 @@ export function timeline(models, config, ui) {
let animStartLocationDate = models.anim.rangeState.startDate;
let animEndLocationDate = models.anim.rangeState.endDate;
let isAnimationWidgetOpen = models.anim.rangeState.state === 'on';
- // console.log(animStartLocationDate, animEndLocationDate)
+ console.log(animStartLocationDate, animEndLocationDate)
console.log(models.anim.rangeState.state)
@@ -658,9 +658,14 @@ export function timeline(models, config, ui) {
};
var onAnimationWidgetToggle = () => {
+ let animationStartLocationDate = models.anim.rangeState.startDate;
+ let animationEndLocationDate = models.anim.rangeState.endDate;
let isAnimationWidgetOpen = models.anim.rangeState.state === 'on';
+
self.reactComponent.setState({
- isAnimationWidgetOpen: isAnimationWidgetOpen
+ isAnimationWidgetOpen: isAnimationWidgetOpen,
+ animStartLocationDate: animationStartLocationDate,
+ animEndLocationDate: animationEndLocationDate
});
};
@@ -700,7 +705,6 @@ export function timeline(models, config, ui) {
);
}
- // self.x = d3.time.scale.utc();
self.resize();
if (util.browser.localStorage) {
@@ -733,7 +737,7 @@ export function timeline(models, config, ui) {
models.layers.events.on('change', onLayerUpdate);
- models.anim.events.on('datechange', onAnimationDateChange);
+ models.anim.events.on('change', onAnimationDateChange);
models.anim.events.on('toggle-widget', onAnimationWidgetToggle);
// Determine maximum end date and move tl pick there if selected date is