Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

save customSelected as boolean, major lint fixes, refactor arrow function in component render level to more performant bindings, clean up components for clarity

Edward Platod8179cd58af1
diff --git a/web/js/components/timeline/interval-selector/interval-selector.js b/web/js/components/timeline/interval-selector/interval-selector.js
index 80928ecaa..7168af3d1 100644
--- a/web/js/components/timeline/interval-selector/interval-selector.js
+++ b/web/js/components/timeline/interval-selector/interval-selector.js
@@ -63,7 +63,7 @@ class CustomIntervalSelectorWidget extends PureComponent {
ref={(customIntervalWidget) => { this.customIntervalWidget = customIntervalWidget; }}
>
<div>Custom Interval Selector</div>
- <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', height: '25px' }}>
+ <div style={{ height: '25px' }}>
<div style={{ display: 'flex', flexDirection: 'row' }}>
<IntervalInput
intervalValue={customDelta}
diff --git a/web/js/components/timeline/interval-selector/timescale-select.js b/web/js/components/timeline/interval-selector/timescale-select.js
index c4669a985..474531628 100644
--- a/web/js/components/timeline/interval-selector/timescale-select.js
+++ b/web/js/components/timeline/interval-selector/timescale-select.js
@@ -18,11 +18,21 @@ class TimeScaleSelect extends PureComponent {
}
render() {
- let { zoomLevel, hasSubdailyLayers } = this.props;
+ let {
+ zoomLevel,
+ hasSubdailyLayers
+ } = this.props;
return (
- <form className="interval-timescale-select" onSubmit={this.handleSubmit}>
+ <form
+ className="interval-timescale-select-form-container"
+ onSubmit={this.handleSubmit}
+ >
<label>
- <select value={zoomLevel} onChange={this.handleChangeZoomLevel}>
+ <select
+ className="interval-timescale-select"
+ value={zoomLevel}
+ onChange={this.handleChangeZoomLevel}
+ >
<option value="year">year</option>
<option value="month">month</option>
<option value="day">day</option>
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 1a737ca11..b669e1e0e 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,7 +35,13 @@ const tileTextConditionOptions = {
class GridRange extends PureComponent {
render() {
- let { gridWidth, transformX, timeScale, timeRange, showHover } = this.props;
+ let {
+ gridWidth,
+ transformX,
+ timeScale,
+ timeRange,
+ showHover
+ } = this.props;
let tileTextCondition = tileTextConditionOptions[timeScale];
return (
<g className="gridShell" transform={`translate(${transformX}, 0)`}>
diff --git a/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js b/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js
index 3fefaf78f..9b409dab5 100644
--- a/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js
+++ b/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js
@@ -57,18 +57,42 @@ const tileRectTimeScaleOptions = {
};
class TileRect extends PureComponent {
+ constructor(props) {
+ super(props);
+ this.showHover = this.showHover.bind(this);
+ }
+
+ showHover = (e) => {
+ let { item, index } = this.props;
+ this.props.showHover(e, item.rawDate, item.rawNextDate, index);
+ }
+
render() {
- let { item, gridWidth, index, showHover, timeScale } = this.props;
+ let { item, gridWidth, index, timeScale } = this.props;
let tileOptions = tileRectTimeScaleOptions[timeScale]();
let lineLengthY = tileOptions.lineLengthY(item);
let whiteLineStrokeWidth = lineLengthY !== 10 ? 2 : 1;
return (
<React.Fragment>
- <g onMouseMove={(e) => showHover(e, item.rawDate, item.rawNextDate, index)}>
- <rect className="grid" width={gridWidth} height={100} transform={`translate(${index * gridWidth}, 0)`} fill={item.withinRange ? 'rgba(0,0,0,0)' : 'black'} shapeRendering="optimizeSpeed"></rect>
- <line stroke="black" strokeLinecap="round" strokeWidth="0.2" x1="0" x2="0" y1="0" y2={lineLengthY} transform={`translate(${index * gridWidth + 2.2}, 0)`} />
- <line stroke="#555" strokeWidth={1} x1="0" x2={gridWidth} y1="46" y2="46" transform={`translate(${index * gridWidth + 1}, 0)`} shapeRendering="optimizeSpeed" />
- <line stroke="white" strokeLinecap="round" strokeWidth={whiteLineStrokeWidth} x1="0" x2="0" y1="0" y2={lineLengthY} transform={`translate(${index * gridWidth + 1}, 0)`} />
+ <g onMouseMove={this.showHover}>
+ <rect className="grid" width={gridWidth} height={100}
+ transform={`translate(${index * gridWidth}, 0)`}
+ fill={item.withinRange ? 'rgba(0,0,0,0)' : 'black'}
+ shapeRendering="optimizeSpeed">
+ </rect>
+ <line stroke="black" strokeLinecap="round"
+ strokeWidth="0.2" x1="0" x2="0" y1="0" y2={lineLengthY}
+ transform={`translate(${index * gridWidth + 2.2}, 0)`}
+ />
+ <line stroke="#555" strokeWidth={1} x1="0" x2={gridWidth}
+ y1="46" y2="46"
+ transform={`translate(${index * gridWidth + 1}, 0)`}
+ shapeRendering="optimizeSpeed"
+ />
+ <line stroke="white" strokeLinecap="round"
+ strokeWidth={whiteLineStrokeWidth} x1="0" x2="0" y1="0" y2={lineLengthY}
+ transform={`translate(${index * gridWidth + 1}, 0)`}
+ />
</g>
</React.Fragment>
);
diff --git a/web/js/components/timeline/timeline-axis/grid-range/tile-text.js b/web/js/components/timeline/timeline-axis/grid-range/tile-text.js
index a86d47f01..d77cb1f01 100644
--- a/web/js/components/timeline/timeline-axis/grid-range/tile-text.js
+++ b/web/js/components/timeline/timeline-axis/grid-range/tile-text.js
@@ -65,7 +65,11 @@ const axisScaleTextElementWrapper = (gridWidth, index, item) => {
let dateText = item.date;
if (item.timeScale === 'hour') {
let timeScaleUnit = item.dateObject.hours;
- dateText = timeScaleUnit === 12 || timeScaleUnit === 6 || timeScaleUnit === 18 ? `${timeScaleUnit}:00` : item.date;
+ dateText = timeScaleUnit === 12 ||
+ timeScaleUnit === 6 ||
+ timeScaleUnit === 18
+ ? `${timeScaleUnit}:00`
+ : item.date;
}
let xOffsetAdded = 8;
if (item.timeScale === 'month' || item.timeScale === 'year') {
@@ -74,7 +78,13 @@ const axisScaleTextElementWrapper = (gridWidth, index, item) => {
return (
<React.Fragment>
<g>
- <text className="gridText" x="0" y="42" fill={item.withinRange ? 'white' : ''} transform={`translate(${(index * gridWidth) + xOffsetAdded}, 20)`} textRendering="optimizeLegibility" clipPath="url(#textDisplay)">{dateText}</text>
+ <text className="gridText" x="0" y="42"
+ fill={item.withinRange ? 'white' : ''}
+ transform={`translate(${(index * gridWidth) + xOffsetAdded}, 20)`}
+ textRendering="optimizeLegibility" clipPath="url(#textDisplay)"
+ >
+ {dateText}
+ </text>
</g>
</React.Fragment>
);
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index 8129274ce..e64c33b28 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -34,13 +34,29 @@ class TimelineAxis extends React.Component {
leftOffset: 0,
position: 0,
currentTimeRange: null,
- currentTransformX: 0,
+ transformX: 0,
gridWidth: 12,
animationStartLocation: 0,
animationEndLocation: 0,
isAnimationDraggerDragging: false,
wheelZoom: false
};
+ // axis
+ this.handleDrag = this.handleDrag.bind(this);
+ this.handleStartDrag = this.handleStartDrag.bind(this);
+ this.handleStopDrag = this.handleStopDrag.bind(this);
+ this.wheelZoom = this.wheelZoom.bind(this);
+
+ // animation draggers/range
+ this.animationDraggerPositionUpdate = this.animationDraggerPositionUpdate.bind(this);
+
+ // hover and times
+ this.toggleShowDraggerTime = this.toggleShowDraggerTime.bind(this);
+ this.displayDate = this.displayDate.bind(this);
+ // this.showHover = this.showHover.bind(this);
+ this.showHoverOn = this.showHoverOn.bind(this);
+ this.showHoverOff = this.showHoverOff.bind(this);
+ this.setLineTime = this.setLineTime.bind(this);
}
// ? how do position and transforms change between scale changes? lock into one line would be ideal
updateScale = (inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff, hoverChange) => {
@@ -181,7 +197,7 @@ class TimelineAxis extends React.Component {
draggerVisibleB: draggerVisibleB,
deque: deque,
currentTimeRange: current.dates,
- currentTransformX: -pixelsToAdd - 2,
+ transformX: -pixelsToAdd - 2,
gridNumber: gridNumber,
gridWidth: gridWidth,
numberOfVisibleTiles: numberOfVisibleTiles,
@@ -201,7 +217,6 @@ class TimelineAxis extends React.Component {
// changes timeScale state
wheelZoom = (e) => {
- // e.preventDefault(); //TODO: investigate treated as passive event error/warning when on
let timeScaleNumber = Number(timeScaleToNumberKey[this.props.timeScale]);
let maxTimeScaleNumber = this.props.hasSubdailyLayers ? 5 : 3;
if (e.deltaY > 0) { // wheel zoom out
@@ -251,7 +266,7 @@ class TimelineAxis extends React.Component {
}
let { currentTimeRange,
deque,
- currentTransformX,
+ transformX,
draggerVisible,
draggerVisibleB,
overDragGrids,
@@ -268,7 +283,7 @@ class TimelineAxis extends React.Component {
this.setState(() => ({
currentTimeRange: currentTimeRange,
deque: deque,
- currentTransformX: currentTransformX,
+ transformX: transformX,
dragSentinelCount: (dragSentinelCount + deltaX) - dragSentinelChangeNumber - (overDragGrids * gridWidth),
draggerPosition: draggerPositionRevision,
draggerVisible: draggerVisible,
@@ -301,7 +316,7 @@ class TimelineAxis extends React.Component {
}
let { currentTimeRange,
deque,
- currentTransformX,
+ transformX,
draggerVisible,
draggerVisibleB,
overDragGrids,
@@ -318,7 +333,7 @@ class TimelineAxis extends React.Component {
this.setState(() => ({
currentTimeRange: currentTimeRange,
deque: deque,
- currentTransformX: currentTransformX,
+ transformX: transformX,
dragSentinelCount: (dragSentinelCount + deltaX) - -dragSentinelChangeNumber + (overDragGrids * gridWidth),
draggerPosition: draggerPositionRevision,
draggerVisible: draggerVisible,
@@ -368,7 +383,7 @@ class TimelineAxis extends React.Component {
deque.unshift(...timeRangeAdd.dates);
timeRange = deque.toArray();
- transform = this.state.currentTransformX - ((numberOfVisibleTiles + 1 + overDragGrids) * gridWidth);
+ transform = this.state.transformX - ((numberOfVisibleTiles + 1 + overDragGrids) * gridWidth);
} else { // # dragging left - exposing future dates
let lastDateInRange = moment.utc(this.state.currentTimeRange[this.state.currentTimeRange.length - 1].rawDate);
timeRangeAdd = this.getTimeRangeArray(-1, numberOfVisibleTiles + 1 + overDragGrids, timeScale, lastDateInRange);
@@ -377,7 +392,7 @@ class TimelineAxis extends React.Component {
deque.push(...timeRangeAdd.dates);
timeRange = deque.toArray();
- transform = this.state.currentTransformX + ((numberOfVisibleTiles + 1 + overDragGrids) * gridWidth);
+ transform = this.state.transformX + ((numberOfVisibleTiles + 1 + overDragGrids) * gridWidth);
}
// check if dragger is in between range and visible
@@ -436,7 +451,7 @@ class TimelineAxis extends React.Component {
return {
currentTimeRange: timeRange,
deque: deque,
- currentTransformX: transform,
+ transformX: transform,
draggerVisible: draggerVisible,
draggerVisibleB: draggerVisibleB,
overDragGrids: overDragGrids,
@@ -500,11 +515,15 @@ class TimelineAxis extends React.Component {
e.stopPropagation();
// TODO: handle stop bubbling up to parent wv-timeline-axis to prevent invoking on clicking draggers
if (e.target.className.animVal !== 'grid') {
- return
+ return;
}
if (!this.state.moved) {
+ let {
+ leftOffset,
+ draggerWidth,
+ hoverTime
+ } = this.state;
let { draggerSelected } = this.props;
- let { leftOffset, draggerWidth, hoverTime } = this.state;
let draggerPosition = draggerSelected === 'selected' ? leftOffset - draggerWidth : this.state.draggerPosition;
let draggerPositionB = draggerSelected === 'selectedB' ? leftOffset - draggerWidth : this.state.draggerPositionB;
@@ -640,7 +659,7 @@ class TimelineAxis extends React.Component {
draggerTimeState: time,
draggerTimeStateB: draggerTimeStateB,
hoverTime: time,
- currentTransformX: 0,
+ transformX: 0,
midPoint: midPoint,
position: midPoint,
animationStartLocation: animationStartDraggerLocation + midPoint,
@@ -653,10 +672,6 @@ class TimelineAxis extends React.Component {
});
}
- shouldComponentUpdate(nextProps, nextState) {
- return true;
- }
-
/**
* check if selectedDate will be within acceptable visible axis width
*
@@ -696,8 +711,22 @@ class TimelineAxis extends React.Component {
}
componentDidUpdate(prevProps, prevState) {
- let { isDraggerDragging, isAnimationDraggerDragging, draggerTimeState, draggerTimeStateB } = this.state;
- let { selectedDate, selectedDateB, draggerSelected, timeScale, axisWidth, compareModeActive, animStartLocationDate, animEndLocationDate } = this.props;
+ 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) {
@@ -830,7 +859,7 @@ class TimelineAxis extends React.Component {
let draggerPosition = draggerB ? this.state.draggerPositionB : this.state.draggerPosition;
newDraggerPosition = draggerPosition + pixelsToAddBasedOnFrontDate;
} else {
- newDraggerPosition = pixelsToAddToDraggerNew + this.state.position - this.state.draggerWidth + this.state.currentTransformX;
+ newDraggerPosition = pixelsToAddToDraggerNew + this.state.position - this.state.draggerWidth + this.state.transformX;
}
if (draggerB) {
@@ -858,7 +887,13 @@ class TimelineAxis extends React.Component {
// handle stop drag of axis
// moved === false means an axis click
handleStopDrag = (e, d) => {
- let { midPoint, position, currentTransformX, leftBound, rightBound } = this.state;
+ let {
+ midPoint,
+ position,
+ transformX,
+ leftBound,
+ rightBound
+ } = this.state;
let { timeScale } = this.props;
position = position - midPoint;
@@ -883,7 +918,7 @@ class TimelineAxis extends React.Component {
rightBound: rightBound,
moved: moved,
position: midPoint,
- currentTransformX: currentTransformX + position
+ transformX: transformX + position
});
}
@@ -925,8 +960,8 @@ class TimelineAxis extends React.Component {
if (!diffZeroValues) {
// calculate based on frontDate due to varying number of days per month and per year (leapyears)
let frontDate = moment.utc(this.state.currentTimeRange[0].rawDate);
- // ! -2 necessary from subtracting 2 from currentTransformX in updateScale ?
- let draggerPositionRelativeToFrontDate = this.state.draggerWidth - 2 + draggerPosition - this.state.position - this.state.currentTransformX;
+ // ! -2 necessary from subtracting 2 from transformX in updateScale ?
+ let draggerPositionRelativeToFrontDate = this.state.draggerWidth - 2 + draggerPosition - this.state.position - this.state.transformX;
let gridWidthCoef = draggerPositionRelativeToFrontDate / gridWidth;
let draggerDateAdded = frontDate.clone().add((Math.floor(gridWidthCoef)), timeScale);
let daysCount;
@@ -965,7 +1000,7 @@ class TimelineAxis extends React.Component {
// //# NEED TO PASS NEGATIVE OF DELTAX FOR UPDATE PANEL
// let { currentTimeRange,
// deque,
- // currentTransformX,
+ // transformX,
// draggerVisible,
// draggerVisibleB,
// overDragGrids,
@@ -974,7 +1009,7 @@ class TimelineAxis extends React.Component {
// this.setState({
// currentTimeRange: currentTimeRange,
// deque: deque,
- // currentTransformX: currentTransformX,
+ // transformX: transformX,
// draggerPosition: -48,
// moved: true,
// position: position,
@@ -1004,7 +1039,7 @@ class TimelineAxis extends React.Component {
// //# NEED TO PASS NEGATIVE OF DELTAX FOR UPDATE PANEL
// let { currentTimeRange,
// deque,
- // currentTransformX,
+ // transformX,
// draggerVisible,
// draggerVisibleB,
// overDragGrids,
@@ -1013,7 +1048,7 @@ class TimelineAxis extends React.Component {
// this.setState({
// currentTimeRange: currentTimeRange,
// deque: deque,
- // currentTransformX: currentTransformX,
+ // transformX: transformX,
// draggerPosition: axisWidth - 50,
// moved: true,
// position: position,
@@ -1106,10 +1141,14 @@ 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 {
+ position,
+ transformX,
+ gridWidth
+ } = this.state;
let { timeScale } = this.props;
- let startDraggerPositionRelativeToFrontDate = animationDraggerLocation - position - currentTransformX + deltaX;
+ let startDraggerPositionRelativeToFrontDate = animationDraggerLocation - position - transformX + deltaX;
let gridWidthCoef = startDraggerPositionRelativeToFrontDate / gridWidth;
let draggerDateAdded = frontDate.clone().add((Math.floor(gridWidthCoef)), timeScale);
let daysCount;
@@ -1129,9 +1168,19 @@ class TimelineAxis extends React.Component {
// handle animation dragger drag change
animationDraggerPositionUpdate = (startLocation, endLocation, stopDragging) => {
- let isDragging = stopDragging ? false : true;
- let { animationStartLocation, animationEndLocation, gridWidth } = this.state;
- let { timelineStartDateLimit, timelineEndDateLimit, animStartLocationDate, animEndLocationDate, timeScale } = this.props;
+ let isDragging = !stopDragging;
+ let {
+ animationStartLocation,
+ animationEndLocation,
+ gridWidth
+ } = this.state;
+ let {
+ timelineStartDateLimit,
+ timelineEndDateLimit,
+ animStartLocationDate,
+ animEndLocationDate,
+ timeScale
+ } = this.props;
// calculate new start and end positions
let deltaXStart = startLocation - animationStartLocation;
@@ -1209,7 +1258,11 @@ class TimelineAxis extends React.Component {
// handle animation dragger location update and state update
animationDraggerDateUpdate = (animationStartLocationDate, animationEndLocationDate) => {
- let { gridWidth, position, currentTransformX } = this.state;
+ let {
+ gridWidth,
+ position,
+ transformX
+ } = this.state;
let { timeScale } = this.props;
let frontDate = moment.utc(this.state.currentTimeRange[0].rawDate);
@@ -1217,8 +1270,8 @@ class TimelineAxis extends React.Component {
let endLocation = frontDate.diff(animationEndLocationDate, timeScale, true) * gridWidth;
this.setState({
- animationStartLocation: position - startLocation + currentTransformX,
- animationEndLocation: position - endLocation + currentTransformX
+ animationStartLocation: position - startLocation + transformX,
+ animationEndLocation: position - endLocation + transformX
});
}
@@ -1228,7 +1281,10 @@ class TimelineAxis extends React.Component {
e.stopPropagation();
e.persist();
requestAnimationFrame(() => {
- let { position, currentTransformX } = this.state;
+ let {
+ position,
+ transformX
+ } = this.state;
let { timeScale } = this.props;
let target = e.target;
@@ -1245,83 +1301,123 @@ class TimelineAxis extends React.Component {
let displayDate = moment.utc(currentDateValue + (xHoverPositionInCurrentGrid * diffFactor)).format();
this.displayDate(displayDate, clientX);
this.setState({
- hoverLinePosition: index * gridWidth + xHoverPositionInCurrentGrid + currentTransformX + position
+ hoverLinePosition: index * gridWidth + xHoverPositionInCurrentGrid + transformX + position
});
});
}
render() {
- let draggerTimeLeftOffest = this.props.draggerSelected === 'selected'
- ? this.state.draggerPosition - (this.props.hasSubdailyLayers ? 64 : 8)
- : this.state.draggerPositionB - (this.props.hasSubdailyLayers ? 64 : 8);
- let hoverTimeLeftOffset = this.props.hasSubdailyLayers ? this.state.leftOffset - 113 : this.state.leftOffset - 57;
+ let {
+ hasSubdailyLayers,
+ draggerSelected,
+ axisWidth,
+ timeScale,
+ compareModeActive,
+ isAnimationWidgetOpen,
+ animStartLocationDate,
+ animEndLocationDate,
+ timelineStartDateLimit,
+ timelineEndDateLimit
+ } = this.props;
+
+ let {
+ currentTimeRange,
+ gridWidth,
+ position,
+ leftBound,
+ rightBound,
+ leftOffset,
+ transformX,
+ animationStartLocation,
+ animationEndLocation,
+ draggerPosition,
+ draggerPositionB,
+ draggerTimeState,
+ draggerTimeStateB,
+ draggerVisible,
+ draggerVisibleB,
+ isTimelineDragging,
+ showDraggerTime,
+ showHoverLine,
+ hoverLinePosition,
+ hoverTime
+ } = this.state;
+
+ let draggerTimeLeftOffest = draggerSelected === 'selected'
+ ? draggerPosition - (hasSubdailyLayers ? 64 : 8)
+ : draggerPositionB - (hasSubdailyLayers ? 64 : 8);
+ let hoverTimeLeftOffset = hasSubdailyLayers ? leftOffset - 113 : leftOffset - 57;
// ! WINDOW.MOMENT FOR DEV DEBUG ONLY
window.moment = moment;
-
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={(e) => this.showHoverOn(e)}
+ <div id='wv-timeline-axis'
+ style={{ width: `${axisWidth}px` }}
+ onMouseUp={this.setLineTime}
+ onWheel={this.wheelZoom}
+ onMouseOver={this.showHoverOn}
onMouseLeave={this.showHoverOff}
>
- {this.state.currentTimeRange
- ? <svg className="inner"
- id="timeline-footer-svg"
- width={this.props.axisWidth}
+ {currentTimeRange
+ ? <svg className='inner'
+ id='timeline-footer-svg'
+ width={axisWidth}
height={70}
- viewBox={`0 0 ${this.props.axisWidth} 75`}
- preserveAspectRatio="xMinYMin slice">
+ viewBox={`0 0 ${axisWidth} 75`}
+ preserveAspectRatio='xMinYMin slice'>
<defs>
{/* clip axis grid text */}
- <clipPath id="textDisplay">
- <rect width="200" height="70" />
+ <clipPath id='textDisplay'>
+ <rect width='200' height='70' />
</clipPath>
{/* clip axis grid overflow */}
- <clipPath id="timelineBoundary">
- <rect width={this.props.axisWidth} height={70}></rect>
+ <clipPath id='timelineBoundary'>
+ <rect width={axisWidth} height={70}></rect>
</clipPath>
</defs>
- <g id="wv-rangeselector-case"></g>
+ <g id='wv-rangeselector-case'></g>
<Draggable
- 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 }}
+ axis='x'
+ onDrag={this.handleDrag}
+ position={{ x: position, y: 0 }}
+ onStart={this.handleStartDrag}
+ onStop={this.handleStopDrag}
+ bounds={{ left: leftBound, top: 0, bottom: 0, right: rightBound }}
>
<g>
<GridRange
showHover={this.showHover}
- timeScale={this.props.timeScale}
+ timeScale={timeScale}
displayDate={this.displayDate}
- gridWidth={this.state.gridWidth}
- timeRange={this.state.currentTimeRange}
- transformX={this.state.currentTransformX} />
+ gridWidth={gridWidth}
+ timeRange={currentTimeRange}
+ transformX={transformX}
+ />
</g>
</Draggable>
- <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"/>
+ <line className='svgLine'
+ style={{
+ display: !isTimelineDragging && showHoverLine ? 'block' : 'none'
+ }}
+ stroke='blue' strokeWidth='2' strokeOpacity='0.48' x1='0' x2='0' y1='0' y2='63'
+ transform={`translate(${hoverLinePosition + 1}, 0)`} shapeRendering='optimizeSpeed'
+ />
- {this.props.isAnimationWidgetOpen
+ {isAnimationWidgetOpen
? <TimelineRangeSelector
- startLocation={this.state.animationStartLocation}
- endLocation={this.state.animationEndLocation}
- startLocationDate={moment.utc(this.props.animStartLocationDate).format()}
- endLocationDate={moment.utc(this.props.animEndLocationDate).format()}
- timelineStartDateLimit={moment.utc(this.props.timelineStartDateLimit).format()}
- timelineEndDateLimit={moment.utc(this.props.timelineEndDateLimit).format()}
+ startLocation={animationStartLocation}
+ endLocation={animationEndLocation}
+ startLocationDate={moment.utc(animStartLocationDate).format()}
+ endLocationDate={moment.utc(animEndLocationDate).format()}
+ timelineStartDateLimit={moment.utc(timelineStartDateLimit).format()}
+ timelineEndDateLimit={moment.utc(timelineEndDateLimit).format()}
max={{ end: false, start: false, startOffset: -50, width: 50000 }}
pinWidth={5}
height={45}
- onDrag={this.animationDraggerPositionUpdate.bind(this)}
+ onDrag={this.animationDraggerPositionUpdate}
onHover={this.showHoverOff}
- onRangeClick={this.setLineTime.bind(this)}
+ onRangeClick={this.setLineTime}
rangeOpacity={0.3}
rangeColor={'#45bdff'}
startColor={'#40a9db'}
@@ -1331,29 +1427,29 @@ class TimelineAxis extends React.Component {
: null
}
- {this.props.draggerSelected === 'selectedB'
+ {draggerSelected === 'selectedB'
? <React.Fragment>
<Dragger
toggleShowDraggerTime={this.toggleShowDraggerTime}
handleDragDragger={this.handleDragDragger}
selectDragger={this.selectDragger}
- compareModeActive={this.props.compareModeActive}
+ compareModeActive={compareModeActive}
disabled={true}
draggerName='selected'
- draggerPosition={this.state.draggerPosition}
- draggerVisible={this.state.draggerVisible}
- transformX={this.state.currentTransformX}
+ draggerPosition={draggerPosition}
+ draggerVisible={draggerVisible}
+ transformX={transformX}
/>
<Dragger
toggleShowDraggerTime={this.toggleShowDraggerTime}
handleDragDragger={this.handleDragDragger}
selectDragger={this.selectDragger}
- compareModeActive={this.props.compareModeActive}
+ compareModeActive={compareModeActive}
disabled={false}
draggerName='selectedB'
- draggerPosition={this.state.draggerPositionB}
- draggerVisible={this.state.draggerVisibleB}
- transformX={this.state.currentTransformX}
+ draggerPosition={draggerPositionB}
+ draggerVisible={draggerVisibleB}
+ transformX={transformX}
/>
</React.Fragment>
: <React.Fragment>
@@ -1361,23 +1457,23 @@ class TimelineAxis extends React.Component {
toggleShowDraggerTime={this.toggleShowDraggerTime}
handleDragDragger={this.handleDragDragger}
selectDragger={this.selectDragger}
- compareModeActive={this.props.compareModeActive}
+ compareModeActive={compareModeActive}
disabled={true}
draggerName='selectedB'
- draggerPosition={this.state.draggerPositionB}
- draggerVisible={this.state.draggerVisibleB}
- transformX={this.state.currentTransformX}
+ draggerPosition={draggerPositionB}
+ draggerVisible={draggerVisibleB}
+ transformX={transformX}
/>
<Dragger
toggleShowDraggerTime={this.toggleShowDraggerTime}
handleDragDragger={this.handleDragDragger}
selectDragger={this.selectDragger}
- compareModeActive={this.props.compareModeActive}
+ compareModeActive={compareModeActive}
disabled={false}
draggerName='selected'
- draggerPosition={this.state.draggerPosition}
- draggerVisible={this.state.draggerVisible}
- transformX={this.state.currentTransformX}
+ draggerPosition={draggerPosition}
+ draggerVisible={draggerVisible}
+ transformX={transformX}
/>
</React.Fragment>
}
@@ -1386,34 +1482,34 @@ class TimelineAxis extends React.Component {
{/* DRAGGER TIME */}
<div
- className="dateToolTip"
+ className='dateToolTip'
style={{
transform: `translate(${draggerTimeLeftOffest}px, -100px)`,
- 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'
+ display: !isTimelineDragging && showDraggerTime && draggerTimeState ? 'block' : 'none',
+ // opacity: showDraggerTime && draggerTimeState ? '1' : '0',
+ width: hasSubdailyLayers ? '220px' : '115px'
}}
>
- { this.state.showDraggerTime && this.state.draggerTimeState
- ? this.props.draggerSelected === 'selected'
- ? 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]
+ { showDraggerTime && draggerTimeState
+ ? draggerSelected === 'selected'
+ ? hasSubdailyLayers ? draggerTimeState.split('T').join(' ') : draggerTimeState.split('T')[0]
+ : hasSubdailyLayers ? draggerTimeStateB.split('T').join(' ') : draggerTimeStateB.split('T')[0]
: null
}
</div>
{/* HOVER TIME */}
<div
- className="dateToolTip"
+ className='dateToolTip'
style={{
transform: `translate(${hoverTimeLeftOffset}px, -100px)`,
- 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'
+ display: !isTimelineDragging && !showDraggerTime && showHoverLine ? 'block' : 'none',
+ // opacity: !showDraggerTime && showHoverLine ? '1' : '0',
+ width: hasSubdailyLayers ? '220px' : '115px'
}}
>
- { !this.state.showDraggerTime && this.state.hoverTime
- ? this.props.hasSubdailyLayers ? this.state.hoverTime.split('T').join(' ') : this.state.hoverTime.split('T')[0]
+ { !showDraggerTime && hoverTime
+ ? hasSubdailyLayers ? hoverTime.split('T').join(' ') : hoverTime.split('T')[0]
: null
}
</div>
@@ -1426,6 +1522,39 @@ class TimelineAxis extends React.Component {
TimelineAxis.defaultProps = {
};
TimelineAxis.propTypes = {
+ animEndLocationDate: PropTypes.date,
+ animStartLocationDate: PropTypes.date,
+ axisWidth: PropTypes.number,
+ changeCustomInterval: PropTypes.func,
+ changeDate: PropTypes.func,
+ changeTimeScale: PropTypes.func,
+ closeAnimation: PropTypes.func,
+ compareModeActive: PropTypes.bool,
+ customIntervalValue: PropTypes.number,
+ customIntervalZoomLevel: PropTypes.string,
+ customSelected: PropTypes.bool,
+ dateFormatted: PropTypes.string,
+ dateFormattedB: PropTypes.string,
+ draggerSelected: PropTypes.string,
+ endTime: PropTypes.date,
+ hasSubdailyLayers: PropTypes.bool,
+ intervalChangeAmt: PropTypes.number,
+ isAnimationWidgetOpen: PropTypes.bool,
+ leftArrowDisabled: PropTypes.bool,
+ onChangeSelectedDragger: PropTypes.func,
+ openAnimation: PropTypes.func,
+ parentOffset: PropTypes.number,
+ rightArrowDisabled: PropTypes.bool,
+ selectInterval: PropTypes.func,
+ selectedDate: PropTypes.string,
+ selectedDateB: PropTypes.string,
+ startDate: PropTypes.string,
+ timeScale: PropTypes.string,
+ timeScaleChangeUnit: PropTypes.string,
+ timelineEndDateLimit: PropTypes.string,
+ timelineStartDateLimit: PropTypes.string,
+ toggleActiveCompareState: PropTypes.func,
+ updateAnimationRange: PropTypes.func
};
export default TimelineAxis;
diff --git a/web/js/components/timeline/timeline-axis/timeline-dragger.js b/web/js/components/timeline/timeline-axis/timeline-dragger.js
index 5254abca2..9b2b4d4c3 100644
--- a/web/js/components/timeline/timeline-axis/timeline-dragger.js
+++ b/web/js/components/timeline/timeline-axis/timeline-dragger.js
@@ -3,31 +3,66 @@ import PropTypes from 'prop-types';
import Draggable from 'react-draggable';
class Dragger extends PureComponent {
+ constructor(props) {
+ super(props);
+ this.selectDragger = this.selectDragger.bind(this);
+ this.handleDragDragger = this.handleDragDragger.bind(this);
+ this.startShowDraggerTime = this.startShowDraggerTime.bind(this);
+ this.stopShowDraggerTime = this.stopShowDraggerTime.bind(this);
+ };
+
+ // Select between A 'selected' or B 'selectedB'
+ selectDragger = (e) => {
+ this.props.selectDragger(this.props.draggerName, e);
+ };
+
+ // Handles deltaX changes on dragging
+ handleDragDragger = (e, d) => {
+ this.props.handleDragDragger(this.props.draggerName, e, d);
+ };
+
+ // Show dragger tooltip on start dragging
+ startShowDraggerTime = () => {
+ this.props.toggleShowDraggerTime(true);
+ };
+
+ // Hide dragger tooltip on stop dragging
+ stopShowDraggerTime = () => {
+ this.props.toggleShowDraggerTime(false);
+ };
+
render() {
let { transformX,
draggerPosition,
draggerVisible,
draggerName,
- handleDragDragger,
- toggleShowDraggerTime,
- selectDragger,
compareModeActive,
- disabled } = this.props;
+ disabled
+ } = this.props;
return (
<Draggable
axis='x'
- onMouseDown={selectDragger.bind(this, draggerName)}
- onDrag={handleDragDragger.bind(this, draggerName)}
+ onMouseDown={this.selectDragger}
+ onDrag={this.handleDragDragger}
position={{ x: draggerPosition - 12, y: -20 }}
- onStart={() => toggleShowDraggerTime(true)}
- onStop={() => toggleShowDraggerTime(false)}
+ onStart={this.startShowDraggerTime}
+ onStop={this.stopShowDraggerTime}
disabled={disabled}
>
<g
- style={{ cursor: 'pointer', display: draggerVisible ? 'block' : 'none' }}
- className='gridShell dragger' transform={`translate(${transformX}, 0)`}
+ style={{
+ cursor: 'pointer',
+ display: draggerVisible ? 'block' : 'none'
+ }}
+ className='gridShell dragger'
+ transform={`translate(${transformX}, 0)`}
>
- <polygon fill={disabled ? '#7a7a7a' : '#ccc'} stroke='#333' strokeWidth='1px' points='60,20, 95,65, 25,65'></polygon>
+ <polygon
+ fill={disabled ? '#7a7a7a' : '#ccc'}
+ stroke='#333'
+ strokeWidth='1px'
+ points='60,20, 95,65, 25,65'>
+ </polygon>
{compareModeActive
? <text
fontSize='30px'
@@ -41,9 +76,13 @@ class Dragger extends PureComponent {
{draggerName === 'selected' ? 'A' : 'B'}
</text>
: <React.Fragment>
- <rect pointerEvents="none" fill='#515151' width='3' height='20' x='52' y='39'></rect>
- <rect pointerEvents="none" fill='#515151' width='3' height='20' x='58' y='39'></rect>
- <rect pointerEvents="none" fill='#515151' width='3' height='20' x='64' y='39'></rect>
+ <rect
+ pointerEvents='none' fill='#515151'
+ width='3' height='20' x='52' y='39'></rect>
+ <rect pointerEvents='none' fill='#515151'
+ width='3' height='20' x='58' y='39'></rect>
+ <rect pointerEvents='none' fill='#515151'
+ width='3' height='20' x='64' y='39'></rect>
</React.Fragment>
}
</g>
diff --git a/web/js/components/timeline/timeline-controls/axis-timescale-change-controls.js b/web/js/components/timeline/timeline-controls/axis-timescale-change-controls.js
index 43b60f8e0..c8e760361 100644
--- a/web/js/components/timeline/timeline-controls/axis-timescale-change-controls.js
+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change-controls.js
@@ -12,12 +12,16 @@ class AxisTimeScaleChangeControls extends PureComponent {
onClickUp = () => {
this.props.decrementTimeScale();
}
-
onClickDown = () => {
this.props.incrementTimeScale();
}
render() {
- let { timeScale, toolTipHovered, changeTimeScale, hasSubdailyLayers } = this.props;
+ let {
+ timeScale,
+ toolTipHovered,
+ changeTimeScale,
+ hasSubdailyLayers
+ } = this.props;
return (
<div className="zoom-level-change-arrows">
<AxisTimeScaleChangeTooltip
@@ -43,7 +47,6 @@ class AxisTimeScaleChangeControls extends PureComponent {
</svg>
</div>
</div>
-
);
}
}
diff --git a/web/js/components/timeline/timeline-controls/axis-timescale-change-tooltip.js b/web/js/components/timeline/timeline-controls/axis-timescale-change-tooltip.js
index b27ef6e03..15a4236d8 100644
--- a/web/js/components/timeline/timeline-controls/axis-timescale-change-tooltip.js
+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change-tooltip.js
@@ -8,8 +8,33 @@ import PropTypes from 'prop-types';
* @extends PureComponent
*/
class AxisTimeScaleChangeTooltip extends PureComponent {
+ // Handle change axis timescale
+ changeTimeScale = (timeScale) => {
+ this.props.changeTimeScale(timeScale);
+ }
+ // Individual linking timescale handlers
+ changeTimeScaleYear = () => {
+ this.changeTimeScale(1);
+ }
+ changeTimeScaleMonth = () => {
+ this.changeTimeScale(2);
+ }
+ changeTimeScaleDay = () => {
+ this.changeTimeScale(3);
+ }
+ changeTimeScaleHour = () => {
+ this.changeTimeScale(4);
+ }
+ changeTimeScaleMinute = () => {
+ this.changeTimeScale(5);
+ }
+
render() {
- let { timeScale, toolTipHovered, changeTimeScale, hasSubdailyLayers } = this.props;
+ let {
+ timeScale,
+ toolTipHovered,
+ hasSubdailyLayers
+ } = this.props;
return (
<React.Fragment>
<div id="zoom-btn-container-axis">
@@ -23,44 +48,53 @@ class AxisTimeScaleChangeTooltip extends PureComponent {
style={{ display: toolTipHovered ? 'block' : 'none' }}
>
<div id="timeline-zoom" className="timeline-zoom">
- <label style={{ textDecoration: 'underline', paddingBottom: '4px', color: '#fff' }}>TIMESCALE</label>
+ <label style={{
+ textDecoration: 'underline',
+ paddingBottom: '4px',
+ color: '#fff'
+ }}>
+ TIMESCALE
+ </label>
<span
id="zoom-years"
className="zoom-btn zoom-btn-inactive zoom-years"
- onClick={() => changeTimeScale(1)}
+ onClick={this.changeTimeScaleYear}
>
YEAR
</span>
<span
id="zoom-months"
className="zoom-btn zoom-btn-inactive zoom-months"
- onClick={() => changeTimeScale(2)}
+ onClick={this.changeTimeScaleMonth}
>
MONTH
</span>
<span
id="zoom-days"
className="zoom-btn zoom-btn-inactive zoom-days"
- onClick={() => changeTimeScale(3)}
+ onClick={this.changeTimeScaleDay}
>
DAY
</span>
- <span
- id="zoom-hours"
- className="zoom-btn zoom-btn-inactive zoom-hours"
- style={{ display: hasSubdailyLayers ? 'block' : 'none' }}
- onClick={() => changeTimeScale(4)}
- >
- HOUR
- </span>
- <span
- id="zoom-minutes"
- className="zoom-btn zoom-btn-inactive zoom-minutes"
- style={{ display: hasSubdailyLayers ? 'block' : 'none' }}
- onClick={() => changeTimeScale(5)}
- >
- MINUTE
- </span>
+ {hasSubdailyLayers
+ ? <React.Fragment>
+ <span
+ id="zoom-hours"
+ className="zoom-btn zoom-btn-inactive zoom-hours"
+ onClick={this.changeTimeScaleHour}
+ >
+ HOUR
+ </span>
+ <span
+ id="zoom-minutes"
+ className="zoom-btn zoom-btn-inactive zoom-minutes"
+ onClick={this.changeTimeScaleMinute}
+ >
+ MINUTE
+ </span>
+ </React.Fragment>
+ : null
+ }
</div>
</div>
</div>
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 7089c8a1f..c9ba7533d 100644
--- a/web/js/components/timeline/timeline-controls/axis-timescale-change.js
+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change.js
@@ -18,12 +18,27 @@ class AxisTimeScaleChange extends PureComponent {
};
}
- // Toggle timeScale select tooltip
- toggleTooltipHover = (isHovered) => {
- // toggle visibility of map scales
+ // TimeScale select tooltip on
+ toolTipHoverOn = () => {
+ this.disableMapScales(true);
+ this.setState({
+ toolTipHovered: true
+ });
+ }
+
+ // TimeScale select tooltip off
+ toolTipHoverOff = () => {
+ this.disableMapScales(false);
+ this.setState({
+ toolTipHovered: false
+ });
+ }
+
+ // Toggle visibility of map scales
+ disableMapScales = (disable) => {
let imperialMapScale = document.querySelectorAll('.wv-map-scale-imperial');
let metricMapScale = document.querySelectorAll('.wv-map-scale-metric');
- if (isHovered) {
+ if (disable) {
for (let el of imperialMapScale) {
el.style.display = 'none';
}
@@ -38,9 +53,6 @@ class AxisTimeScaleChange extends PureComponent {
el.style.display = 'block';
}
}
- this.setState({
- toolTipHovered: isHovered
- });
}
// ex: month(2) to day(3)
@@ -61,7 +73,12 @@ class AxisTimeScaleChange extends PureComponent {
}
render() {
- let { timeScale, timelineHidden, hasSubdailyLayers, changeTimeScale } = this.props;
+ let {
+ timeScale,
+ timelineHidden,
+ hasSubdailyLayers,
+ changeTimeScale
+ } = this.props;
return (
<div
className="zoom-level-change"
@@ -71,8 +88,8 @@ class AxisTimeScaleChange extends PureComponent {
>
{ timeScale
? <div
- onMouseEnter={() => this.toggleTooltipHover(true)}
- onMouseLeave={() => this.toggleTooltipHover(false)}>
+ onMouseEnter={this.toolTipHoverOn}
+ onMouseLeave={this.toolTipHoverOff}>
<AxisTimeScaleChangeControls
timeScale={timeScale}
hasSubdailyLayers={hasSubdailyLayers}
diff --git a/web/js/components/timeline/timeline-controls/date-change-arrows.js b/web/js/components/timeline/timeline-controls/date-change-arrows.js
index c5008ec6e..5989611b9 100644
--- a/web/js/components/timeline/timeline-controls/date-change-arrows.js
+++ b/web/js/components/timeline/timeline-controls/date-change-arrows.js
@@ -3,7 +3,14 @@ import PropTypes from 'prop-types';
class DateChangeArrows extends PureComponent {
render() {
- let { leftArrowDisabled, leftArrowDown, leftArrowUp, rightArrowDisabled, rightArrowDown, rightArrowUp } = this.props;
+ let {
+ leftArrowDisabled,
+ leftArrowDown,
+ leftArrowUp,
+ rightArrowDisabled,
+ rightArrowDown,
+ rightArrowUp
+ } = this.props;
return (
<div>
{/* LEFT ARROW */}
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 131423a31..8308ce63a 100644
--- a/web/js/components/timeline/timeline-controls/interval-timescale-change.js
+++ b/web/js/components/timeline/timeline-controls/interval-timescale-change.js
@@ -10,19 +10,48 @@ class TimeScaleIntervalChange extends Component {
};
}
- // Toggle zoom select tooltip
- toggleTooltipHover = (isHovered) => {
+ // Zoom select tooltip on
+ toolTipHoverOn = () => {
this.setState({
- toolTipHovered: isHovered
+ toolTipHovered: true
});
}
- handleClickZoom = (intervalSelected, openDialog) => {
- // close tooltip
+ // Zoom select tooltip off
+ toolTipHoverOff = () => {
+ this.setState({
+ toolTipHovered: false
+ });
+ }
+
+ // handle click zoom of timescale intervals
+ handleClickZoom = (timescale, openDialog) => {
// send props function to change timescale zoom level throughout app
this.setState({
toolTipHovered: false
- }, this.props.setTimeScaleIntervalChangeUnit(intervalSelected, openDialog));
+ }, this.props.setTimeScaleIntervalChangeUnit(timescale, openDialog));
+ }
+ // individual linking timescale handlers
+ handleClickZoomYear = () => {
+ this.handleClickZoom('year');
+ }
+ handleClickZoomMonth = () => {
+ this.handleClickZoom('month');
+ }
+ handleClickZoomDay= () => {
+ this.handleClickZoom('day');
+ }
+ handleClickZoomHour = () => {
+ this.handleClickZoom('hour');
+ }
+ handleClickZoomMinute = () => {
+ this.handleClickZoom('minute');
+ }
+ handleClickZoomCustom = () => {
+ this.handleClickZoom('custom');
+ }
+ handleClickZoomCustomStatic = () => {
+ this.handleClickZoom('custom', true);
}
// set custom text for custom interval
@@ -39,7 +68,11 @@ class TimeScaleIntervalChange extends Component {
}
componentDidUpdate (prevProps, prevState) {
- let { customDelta, timeScaleChangeUnit, customSelected } = this.props;
+ let {
+ customDelta,
+ timeScaleChangeUnit,
+ customSelected
+ } = this.props;
if (customDelta && timeScaleChangeUnit) {
if (customSelected && customDelta !== 1 && this.state.customIntervalText === 'Custom') {
this.setCustomIntervalText();
@@ -50,14 +83,20 @@ class TimeScaleIntervalChange extends Component {
}
render() {
- let { customIntervalText, toolTipHovered } = this.state;
- let { customSelected, timeScaleChangeUnit } = this.props;
+ let {
+ customIntervalText,
+ toolTipHovered
+ } = this.state;
+ let {
+ customSelected,
+ timeScaleChangeUnit
+ } = this.props;
return (
<React.Fragment>
<div id="zoom-btn-container"
className="noselect"
- onMouseEnter={() => this.toggleTooltipHover(true)}
- onMouseLeave={() => this.toggleTooltipHover(false)}
+ onMouseEnter={this.toolTipHoverOn}
+ onMouseLeave={this.toolTipHoverOff}
>
{/* timeScale display */}
<span
@@ -75,35 +114,35 @@ class TimeScaleIntervalChange extends Component {
<span
id="zoom-years"
className="zoom-btn zoom-btn-inactive zoom-years"
- onClick={() => this.handleClickZoom('year')}
+ onClick={this.handleClickZoomYear}
>
Year
</span>
<span
id="zoom-months"
className="zoom-btn zoom-btn-inactive zoom-months"
- onClick={() => this.handleClickZoom('month')}
+ onClick={this.handleClickZoomMonth}
>
Month
</span>
<span
id="zoom-days"
className="zoom-btn zoom-btn-inactive zoom-days"
- onClick={() => this.handleClickZoom('day')}
+ onClick={this.handleClickZoomDay}
>
Day
</span>
<span
id="zoom-hours"
className="zoom-btn zoom-btn-inactive zoom-hours"
- onClick={() => this.handleClickZoom('hour')}
+ onClick={this.handleClickZoomHour}
>
Hour
</span>
<span
id="zoom-minutes"
className="zoom-btn zoom-btn-inactive zoom-minutes"
- onClick={() => this.handleClickZoom('minute')}
+ onClick={this.handleClickZoomMinute}
>
Minute
</span>
@@ -111,14 +150,14 @@ class TimeScaleIntervalChange extends Component {
id="zoom-custom"
className="zoom-btn zoom-btn-inactive zoom-custom custom-interval-text"
style={{ display: customIntervalText === 'Custom' ? 'none' : 'block' }}
- onClick={() => this.handleClickZoom('custom')}
+ onClick={this.handleClickZoomCustom}
>
{customIntervalText}
</span>
<span
id="zoom-custom-static"
className="zoom-btn zoom-btn-inactive zoom-custom custom-interval-text"
- onClick={() => this.handleClickZoom('custom', true)}
+ onClick={this.handleClickZoomCustomStatic}
>
Custom
</span>
@@ -135,6 +174,7 @@ TimeScaleIntervalChange.propTypes = {
customIntervalText: PropTypes.string,
customSelected: PropTypes.bool,
setTimeScaleIntervalChangeUnit: PropTypes.func,
+ customIntervalZoomLevel: PropTypes.string,
timeScaleChangeUnit: PropTypes.string
};
diff --git a/web/js/components/timeline/timeline.css b/web/js/components/timeline/timeline.css
index 4c00619c7..4bb885a94 100644
--- a/web/js/components/timeline/timeline.css
+++ b/web/js/components/timeline/timeline.css
@@ -17,7 +17,6 @@ html, body {
}
.inner {
- /* background: rgba(0, 0, 0, 0.5); */
height: 64px;
display: flex;
flex-direction: row;
@@ -39,6 +38,7 @@ html, body {
height: 25px;
line-height: 25px;
white-space: nowrap;
+ user-select: none;
/* transition: opacity 0.3s ease-in-out; */
}
@@ -69,11 +69,6 @@ line {
/* DEVELOPMENT */
-#wv-animation-widget-custom-interval select {
- text-align-last: center;
- padding-left: 15px;
-}
-
#timelineContainer > div:nth-child(1) > div.wv-date-selector-widget {
background: #999;
}
@@ -128,10 +123,9 @@ line {
padding: 0;
text-align: center;
border: thin solid #fff;
- /* margin: 5px 0 5px 0; */
}
-.interval-timescale-select {
+.interval-timescale-select-form-container {
width: 100px;
height: 40px;
color: #7890cd;
@@ -145,20 +139,19 @@ line {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
- /* padding: 15px; */
text-align: center;
}
-.interval-timescale-select select {
+.interval-timescale-select {
padding: 0;
- /* background: #212121; */
- background: transparent;
+ background: rgba(40, 40, 40, 1);
color: #7890cd;
height: 24px;
font-size: 16px;
width: 118px;
border: thin solid #fff;
- /* margin-top: 1px; */
+ text-align-last: center;
+ padding-left: 15px;
}
.custom-interval-text {
@@ -166,9 +159,7 @@ line {
}
.wv-timeline-hide {
- /* vertical-align: middle; */
display: block;
- /* margin: 26px 0 0 7px; */
top: 18px;
right: -5px;
color: white;
@@ -228,7 +219,6 @@ line {
width: 225px;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
- /* background: #212121; */
background: rgba(40, 40, 40, 0.85);
position: absolute;
top: -58px;
@@ -253,8 +243,3 @@ line {
display: inline-block;
margin: 7px 0 0 10px;
}
-
-/* DEMO DOM CLEANUP */
-/* #timeline-footer svg {
- overflow: visible !important;
-} */
\ No newline at end of file
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index 1262a7348..dc925700b 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -39,6 +39,7 @@ class Timeline extends React.Component {
timelineHidden: false,
customIntervalModalOpen: false
};
+ // left/right arrows
this.animator = 0;
}
/**
@@ -46,7 +47,7 @@ class Timeline extends React.Component {
*
* @return {void}
*/
- stopper() {
+ stopper = () => {
if (this.state.animationInProcess) {
clearInterval(this.animator);
this.animator = 0;
@@ -129,11 +130,20 @@ class Timeline extends React.Component {
});
}
- // left/right arrows increment date
- incrementDate = (multiplier) => {
+ // right arrow increment date
+ incrementDate = () => {
let delta = this.props.customSelected ? this.props.intervalChangeAmt : 1;
this.animateByIncrement(
- Number(delta * multiplier),
+ Number(delta),
+ this.props.timeScaleChangeUnit
+ );
+ }
+
+ // left arrow decrement date
+ decrementDate = () => {
+ let delta = this.props.customSelected ? this.props.intervalChangeAmt : 1;
+ this.animateByIncrement(
+ Number(delta * -1),
this.props.timeScaleChangeUnit
);
}
@@ -217,11 +227,11 @@ class Timeline extends React.Component {
/>
<DateChangeArrows
- leftArrowDown={() => this.incrementDate(-1)}
- leftArrowUp={this.stopper.bind(this)}
+ leftArrowDown={this.decrementDate}
+ leftArrowUp={this.stopper}
leftArrowDisabled={leftArrowDisabled}
- rightArrowDown={() => this.incrementDate(1)}
- rightArrowUp={this.stopper.bind(this)}
+ rightArrowDown={this.incrementDate}
+ rightArrowUp={this.stopper}
rightArrowDisabled={rightArrowDisabled}
/>
</div>
@@ -249,10 +259,10 @@ class Timeline extends React.Component {
changeTimeScale={this.changeTimeScale}
compareModeActive={compareModeActive}
draggerSelected={draggerSelected}
- onChangeSelectedDragger={this.onChangeSelectedDragger.bind(this)}
+ onChangeSelectedDragger={this.onChangeSelectedDragger}
timelineStartDateLimit={timelineStartDateLimit}
timelineEndDateLimit={timelineEndDateLimit}
- updateAnimationRange={this.updateAnimationRange.bind(this)}
+ updateAnimationRange={this.updateAnimationRange}
animStartLocationDate={animStartLocationDate}
animEndLocationDate={animEndLocationDate}
isAnimationWidgetOpen={isAnimationWidgetOpen}
@@ -306,6 +316,23 @@ function mapStateToProps(state) {
const { isCompareA, activeString } = compare;
const compareModeActive = compare.active;
let hasSubdailyLayers = hasSubDaily(layers[compare.activeString]);
+ customSelected = Boolean(customSelected);
+
+ // handle changing timescale and intervals if in subdaily state
+ // when removing all subdaily layers
+ // TODO: how to dynamically update store based on remove layer?
+ // if (!hasSubdailyLayers) {
+ // if (selectedZoom > 3) {
+ // selectedZoom = 3;
+ // }
+ // if (interval > 3) {
+ // interval = 3;
+ // }
+ // if (customInterval > 3) {
+ // customInterval = 3;
+ // }
+ // }
+
let endTime;
if (compareModeActive) {
hasSubdailyLayers =
@@ -392,10 +419,6 @@ const mapDispatchToProps = dispatch => ({
toggleActiveCompareState: () => {
dispatch(toggleActiveCompareState());
}
- // set currently selected delta - will always be 1 if !customSelected
- // selectDelta: val => {
- // dispatch(selectDelta(val));
- // }
});
export default connect(
diff --git a/web/js/modules/date/actions.js b/web/js/modules/date/actions.js
index 815086db1..79655d3fe 100644
--- a/web/js/modules/date/actions.js
+++ b/web/js/modules/date/actions.js
@@ -36,7 +36,7 @@ export function selectInterval(delta, interval, customSelected) {
type: CHANGE_INTERVAL,
value: interval,
delta: delta,
- customSelected
+ customSelected: Boolean(customSelected)
};
}
// export function selectDelta(delta) {
diff --git a/web/js/modules/date/constants.js b/web/js/modules/date/constants.js
index 441868d22..fad19e965 100644
--- a/web/js/modules/date/constants.js
+++ b/web/js/modules/date/constants.js
@@ -13,12 +13,12 @@ export const timeScaleFromNumberKey = {
'5': 'minute'
};
export const timeScaleToNumberKey = {
- custom: '0',
- year: '1',
- month: '2',
- day: '3',
- hour: '4',
- minute: '5'
+ custom: 0,
+ year: 1,
+ month: 2,
+ day: 3,
+ hour: 4,
+ minute: 5
};
export const timeScaleOptions = {
'minute': {