Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add leftright arrow custom disabling, revise changeTimeScale and child component usage to use integers, destructure and clean up various component state and props at render and update cycles

Edward Platodfdc1be82413
diff --git a/web/css/timeline.css b/web/css/timeline.css
index 231da0ad1..cf5d2169e 100644
--- a/web/css/timeline.css
+++ b/web/css/timeline.css
@@ -144,7 +144,7 @@ g.plot rect.data-bar-invisible {
}
#timeline-header.subdaily {
- width: 404px;
+ width: 414px;
}
#timeline-header .timeline-zoom,
diff --git a/web/js/animation/range-select.js b/web/js/animation/range-select.js
index f966e815c..4887594b5 100644
--- a/web/js/animation/range-select.js
+++ b/web/js/animation/range-select.js
@@ -16,11 +16,11 @@ const timeScaleFromNumberKey = {
export function animationRangeSelect(models, config, ui) {
var self = {};
var model;
- var timeline = ui.timeline;
- var $mountLocation = $('#wv-rangeselector-case');
+ // var timeline = ui.timeline;
+ // var $mountLocation = $('#wv-rangeselector-case');
var $footer = $('#timeline-footer');
- var $header = $('#timeline-header');
- var $timeline = $('#timeline');
+ // var $header = $('#timeline-header');
+ // var $timeline = $('#timeline');
// get timeline min/max date, zero out end date, and format to ISO
var timelineStartDateLimit = config.startDate;
@@ -80,7 +80,7 @@ export function animationRangeSelect(models, config, ui) {
*
*/
self.render = function() {
- var options;
+ // var options;
var startLocation;
var endLocation;
// TODO: Pull in new dragger pick
@@ -91,10 +91,10 @@ export function animationRangeSelect(models, config, ui) {
// d3.transform(pick.attr('transform')).translate[0] - pickWidth / 2; // getting guitar pick location
// var animEndLocation = 300;
if (model.rangeState.startDate) {
- startLocation = self.getLocationFromStringDate(
- model.rangeState.startDate
- );
- endLocation = self.getLocationFromStringDate(model.rangeState.endDate);
+ // startLocation = self.getLocationFromStringDate(
+ // model.rangeState.startDate
+ // );
+ // endLocation = self.getLocationFromStringDate(model.rangeState.endDate);
} else {
// startLocation = animEndLocation - 100;
// endLocation = animEndLocation;
@@ -139,13 +139,13 @@ export function animationRangeSelect(models, config, ui) {
* @returns {number} OffsetX
*
*/
- self.getHeaderOffset = function() {
- return (
- $header.width() +
- Number($timeline.css('left').replace('px', '')) +
- Number($footer.css('margin-left').replace('px', ''))
- );
- };
+ // self.getHeaderOffset = function() {
+ // return (
+ // $header.width() +
+ // Number($timeline.css('left').replace('px', '')) +
+ // Number($footer.css('margin-left').replace('px', ''))
+ // );
+ // };
/*
* calculates offset of date
@@ -188,31 +188,31 @@ export function animationRangeSelect(models, config, ui) {
* @returns {object} maxWidth
*
*/
- self.getMaxWidth = function() {
- // end of timeline
- // let $dataWidth = timeline.x(timeline.data.end());
- let $dataWidth = 1556127454524;
- // start of timeline
- // let $dataStart = timeline.x(timeline.data.start());
- let $dataStart = 1556129454524;
- // default start/end false
- let maxWidth = {
- width: $footer.width(),
- startOffset: $dataStart,
- start: false,
- end: false
- };
- // end of timeline in view
- if (maxWidth.width > $dataWidth) {
- maxWidth.width = $dataWidth;
- maxWidth.end = true;
- }
- // start of timeline in view
- if ($dataStart > 0) {
- maxWidth.start = true;
- }
- return maxWidth;
- };
+ // self.getMaxWidth = function() {
+ // // end of timeline
+ // // let $dataWidth = timeline.x(timeline.data.end());
+ // let $dataWidth = 1556127454524;
+ // // start of timeline
+ // // let $dataStart = timeline.x(timeline.data.start());
+ // let $dataStart = 1556129454524;
+ // // default start/end false
+ // let maxWidth = {
+ // width: $footer.width(),
+ // startOffset: $dataStart,
+ // start: false,
+ // end: false
+ // };
+ // // end of timeline in view
+ // if (maxWidth.width > $dataWidth) {
+ // maxWidth.width = $dataWidth;
+ // maxWidth.end = true;
+ // }
+ // // start of timeline in view
+ // if ($dataStart > 0) {
+ // maxWidth.start = true;
+ // }
+ // return maxWidth;
+ // };
/*
* Gets prop updates
@@ -223,17 +223,17 @@ export function animationRangeSelect(models, config, ui) {
* @returns {object} props
*
*/
- self.updateOptions = function() {
- var state = model.rangeState;
- var props = {};
- props.startLocation = self.getLocationFromStringDate(state.startDate);
- props.endLocation = self.getLocationFromStringDate(state.endDate);
- props.startLocationDate = state.startDate;
- props.endLocationDate = state.endDate;
- props.max = self.getMaxWidth();
+ // self.updateOptions = function() {
+ // var state = model.rangeState;
+ // var props = {};
+ // props.startLocation = self.getLocationFromStringDate(state.startDate);
+ // props.endLocation = self.getLocationFromStringDate(state.endDate);
+ // props.startLocationDate = state.startDate;
+ // props.endLocationDate = state.endDate;
+ // props.max = self.getMaxWidth();
- return props;
- };
+ // return props;
+ // };
/*
* Handles click on widget:
@@ -248,13 +248,13 @@ export function animationRangeSelect(models, config, ui) {
* @returns {object} props
*
*/
- self.onRangeClick = function(e) {
- var headerOffset = self.getHeaderOffset();
- var offsetX = e.pageX - headerOffset;
- // var date = timeline.x.invert(offsetX);
- var date = new Date();
- models.date.select(date);
- };
+ // self.onRangeClick = function(e) {
+ // var headerOffset = self.getHeaderOffset();
+ // var offsetX = e.pageX - headerOffset;
+ // // var date = timeline.x.invert(offsetX);
+ // var date = new Date();
+ // models.date.select(date);
+ // };
/*
* Updates start and end dates and triggers
@@ -269,16 +269,16 @@ export function animationRangeSelect(models, config, ui) {
* @returns {object} props
*
*/
- self.updateRange = function(startLocation, EndLocation, TEST) {
+ self.updateRange = function(startLocation, endLocation, inputDates) {
// var startDate = util.roundTimeTenMinute(timeline.x.invert(startLocation));
// var endDate = util.roundTimeTenMinute(timeline.x.invert(EndLocation));
let selectedZoom = timeScaleFromNumberKey[models.date.selectedZoom];
var startDate = util.dateAdd(new Date(), selectedZoom, -7);
var endDate = new Date();
- if (TEST) {
+ if (inputDates) {
startDate = new Date(startLocation);
- endDate = new Date(EndLocation);
+ endDate = new Date(endLocation);
}
var state = model.rangeState;
diff --git a/web/js/components/timeline/interval-selector/interval-input.js b/web/js/components/timeline/interval-selector/interval-input.js
index 372df877a..b96577108 100644
--- a/web/js/components/timeline/interval-selector/interval-input.js
+++ b/web/js/components/timeline/interval-selector/interval-input.js
@@ -2,15 +2,13 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
/*
- * A react component, is a draggable svg
- * group. It is a parent component that
- * rerenders when child elements are dragged
+ * Interval Input for Custom Interval Selector
+ * group. It is a child component.
*
- * @class TimelineRangeSelector
+ * @class IntervalInput
*/
const regex = /^[0-9\b]+$/;
-
class IntervalInput extends PureComponent {
onKeyInput = (e) => {
let value = e.target.value;
diff --git a/web/js/components/timeline/interval-selector/interval-selector.js b/web/js/components/timeline/interval-selector/interval-selector.js
index 6fba225cb..8467bfb94 100644
--- a/web/js/components/timeline/interval-selector/interval-selector.js
+++ b/web/js/components/timeline/interval-selector/interval-selector.js
@@ -4,11 +4,10 @@ import IntervalInput from './interval-input';
import TimeScaleSelect from './timescale-select';
/*
- * A react component, Builds a rather specific
- * interactive widget
+ * CustomIntervalSelectorWidget for Custom Interval Selector
+ * group. It is a parent component of this group.
*
- * @class AnimationWidget
- * @extends React.Component
+ * @class CustomIntervalSelectorWidget
*/
class CustomIntervalSelectorWidget extends PureComponent {
constructor(props) {
@@ -60,27 +59,30 @@ class CustomIntervalSelectorWidget extends PureComponent {
}
componentDidUpdate(prevProps) {
+ let { customIntervalModalOpen, customIntervalValue, zoomLevel, customIntervalZoomLevel } = this.props;
// handle focus widget on opening
- if (this.props.customIntervalModalOpen && !prevProps.customIntervalModalOpen) {
+ if (customIntervalModalOpen && !prevProps.customIntervalModalOpen) {
this.customIntervalWidget.focus();
}
// update if higher state changed
- if (prevProps.customIntervalValue !== this.props.customIntervalValue
- || prevProps.zoomLevel !== this.props.zoomLevel) {
+ if (customIntervalValue !== prevProps.customIntervalValue
+ || zoomLevel !== prevProps.zoomLevel) {
this.setState({
- intervalValue: this.props.customIntervalValue,
- zoomLevel: this.props.customIntervalZoomLevel
+ intervalValue: customIntervalValue,
+ zoomLevel: customIntervalZoomLevel
})
}
}
render() {
+ let { customIntervalModalOpen, hasSubdailyLayers, toggleCustomIntervalModal } = this.props;
+ let { intervalValue, zoomLevel } = this.state;
return (
<div
id="wv-animation-widget-custom-interval"
onKeyDown={this.handleKeyPress}
className='wv-animation-widget-custom-interval'
- style={{display: this.props.customIntervalModalOpen ? 'block' : 'none'}}
+ style={{display: customIntervalModalOpen ? 'block' : 'none'}}
tabIndex={0}
ref={(customIntervalWidget) => { this.customIntervalWidget = customIntervalWidget; }}
>
@@ -89,18 +91,18 @@ class CustomIntervalSelectorWidget extends PureComponent {
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', height: '25px' }}>
<div style={{display: 'flex', flexDirection: 'row' }}>
<IntervalInput
- intervalValue={Number(this.state.intervalValue)}
+ intervalValue={Number(intervalValue)}
changeInterval={this.changeInterval}
/>
<TimeScaleSelect
- hasSubdailyLayers={this.props.hasSubdailyLayers}
- zoomLevel={this.state.zoomLevel}
+ hasSubdailyLayers={hasSubdailyLayers}
+ zoomLevel={zoomLevel}
changeZoomLevel={this.changeZoomLevel}
/>
</div>
</div>
- <i className="fa fa-times wv-close" onClick={this.props.toggleCustomIntervalModal}/>
+ <i className="fa fa-times wv-close" onClick={toggleCustomIntervalModal}/>
</div>
);
}
diff --git a/web/js/components/timeline/interval-selector/timescale-select.js b/web/js/components/timeline/interval-selector/timescale-select.js
index 74412e209..3500a6597 100644
--- a/web/js/components/timeline/interval-selector/timescale-select.js
+++ b/web/js/components/timeline/interval-selector/timescale-select.js
@@ -1,5 +1,12 @@
import React, { PureComponent } from 'react';
+import PropTypes from 'prop-types';
+/*
+ * TimeScaleSelect for Custom Interval Selector
+ * group. It is a child component.
+ *
+ * @class TimeScaleSelect
+ */
class TimeScaleSelect extends PureComponent {
handleChangeZoomLevel = (e) => {
let zoomLevel = e.target.value;
@@ -11,14 +18,15 @@ class TimeScaleSelect extends PureComponent {
}
render() {
+ let { zoomLevel, hasSubdailyLayers } = this.props;
return (
<form className="interval-timescale-select" onSubmit={this.handleSubmit}>
<label>
- <select value={this.props.zoomLevel} onChange={this.handleChangeZoomLevel}>
+ <select value={zoomLevel} onChange={this.handleChangeZoomLevel}>
<option value="year">year</option>
<option value="month">month</option>
<option value="day">day</option>
- {this.props.hasSubdailyLayers ?
+ {hasSubdailyLayers ?
<React.Fragment>
<option value="hour">hour</option>
<option value="minute">minute</option>
@@ -33,4 +41,10 @@ class TimeScaleSelect extends PureComponent {
}
}
+TimeScaleSelect.propTypes = {
+ changeZoomLevel: PropTypes.func,
+ zoomLevel: PropTypes.string,
+ hasSubdailyLayers: PropTypes.bool
+};
+
export default TimeScaleSelect;
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 4e82f74c5..8b9f629a6 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
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import TileRect from './tile-rect';
import TileText from './tile-text';
-// determine if text will be rendered
+// determine if text will be rendered via itemDateObject param used with timeScale key
const tileTextConditionOptions = {
minute: (itemDateObject) => {
let timeScaleUnit = itemDateObject.minutes;
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 624bb772a..3fefaf78f 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
@@ -1,81 +1,6 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
-// const axisScaleGridElement = {
-// minute: (gridWidth, index, item) => {
-// let timeScaleUnit = item.dateObject.minutes;
-// let lineLengthY = timeScaleUnit === 0 ||
-// timeScaleUnit === 15 ||
-// timeScaleUnit === 30 ||
-// timeScaleUnit === 45 ? 62 : timeScaleUnit % 5 === 0 ? 20 : 10;
-// let whiteLineStrokeWidth = lineLengthY !== 10 ? 2 : 1;
-// return (
-// <React.Fragment>
-// <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)`} />
-// </React.Fragment>
-// )
-// },
-// hour: (gridWidth, index, item) => {
-// let timeScaleUnit = item.dateObject.hours;
-// let lineLengthY = timeScaleUnit === 0 ? 62 :
-// timeScaleUnit === 6 ||
-// timeScaleUnit === 12 ||
-// timeScaleUnit === 18 ? 22 : 10;
-// let whiteLineStrokeWidth = lineLengthY !== 10 ? 2 : 1;
-// return (
-// <React.Fragment>
-// <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)`} />
-// </React.Fragment>
-// )
-// },
-// day: (gridWidth, index, item) => {
-// let timeScaleUnit = item.dateObject.date;
-// let dayOfWeek = item.dayOfWeek;
-// let lineLengthY = timeScaleUnit === 1 ? 62 : dayOfWeek === 0 ? 22 : 10;
-// let whiteLineStrokeWidth = lineLengthY !== 10 ? 2 : 1;
-// return (
-// <React.Fragment>
-// <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)`} />
-// </React.Fragment>
-// )
-// },
-// month: (gridWidth, index, item) => {
-// let timeScaleUnit = item.dateObject.months;
-// let lineLengthY = timeScaleUnit === 0 ? 62 : timeScaleUnit % 3 === 0 ? 22 : 10;
-// let whiteLineStrokeWidth = lineLengthY !== 10 ? 2 : 1;
-// return (
-// <React.Fragment>
-// <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)`} />
-// </React.Fragment>
-// )
-// },
-// year: (gridWidth, index, item) => {
-// let timeScaleUnit = item.dateObject.years;
-// let lineLengthY = timeScaleUnit % 10 === 0 ? 62 : timeScaleUnit % 5 === 0 ? 22 : 10;
-// let whiteLineStrokeWidth = lineLengthY !== 10 ? 2 : 1;
-// return (
-// <React.Fragment>
-// <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)`} />
-// </React.Fragment>
-// )
-// },
-// }
-
const tileRectTimeScaleOptions = {
minute: function() {
return {
@@ -140,7 +65,6 @@ class TileRect extends PureComponent {
return (
<React.Fragment>
<g onMouseMove={(e) => showHover(e, item.rawDate, item.rawNextDate, index)}>
- {/* { axisScaleGridElement[item.timeScale](gridWidth, index, item) } */}
<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" />
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index 00b7b59fa..d11a89b6c 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -12,6 +12,16 @@ import TimelineRangeSelector from '../../range-selection/range-selection';
const draggerWidth = 49;
const timeScales = [ 'year', 'month', 'day', 'hour', 'minute' ];
+
+const timeScaleToNumberKey = {
+ 'custom': 0,
+ 'year': 1,
+ 'month': 2,
+ 'day': 3,
+ 'hour': 4,
+ 'minute': 5
+};
+
const timeScaleOptions = {
'minute': {
timeAxis: {
@@ -83,12 +93,13 @@ 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)
+ console.log(inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff, hoverChange)
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;
+ console.log(this.state.leftOffset)
if (leftOffset === 0) {
leftOffset = axisWidth / 2;
}
@@ -244,22 +255,19 @@ class TimelineAxis extends React.Component {
// changes timeScale state
wheelZoom = (e) => {
// e.preventDefault(); //TODO: investigate treated as passive event error/warning when on
- let arrayIndex = timeScales.indexOf(this.props.timeScale);
- let maxIndex = this.props.hasSubdailyLayers ? 4 : 2;
+ let timeScaleNumber = timeScaleToNumberKey[this.props.timeScale];
+ let maxTimeScaleNumber = this.props.hasSubdailyLayers ? 5 : 3;
if (e.deltaY > 0) { // wheel zoom out
- if (arrayIndex > 0) {
- let nextGreaterTimeScale = timeScales[arrayIndex - 1];
+ if (timeScaleNumber > 1) {
this.setState({
wheelZoom: true
- }, this.props.changeTimescale(nextGreaterTimeScale))
+ }, this.props.changeTimeScale(timeScaleNumber - 1))
}
} else {
- if (arrayIndex < maxIndex) { // wheel zoom in
- let nextSmallerTimeScale = timeScales[arrayIndex + 1];
- // this.props.changeTimescale(nextSmallerTimeScale);
+ if (timeScaleNumber < maxTimeScaleNumber) { // wheel zoom in
this.setState({
wheelZoom: true
- }, this.props.changeTimescale(nextSmallerTimeScale))
+ }, this.props.changeTimeScale(timeScaleNumber + 1))
}
}
}
@@ -763,7 +771,7 @@ class TimelineAxis extends React.Component {
if (this.state.wheelZoom === true) {
draggerDate = this.state.hoverTime;
} else {
- leftOffset = 0.5;
+ leftOffset = 0.75;
if (this.props.draggerSelected === 'selected') {
draggerDate = this.state.draggerTimeState;
} else {
@@ -1398,7 +1406,7 @@ class TimelineAxis extends React.Component {
draggerPosition={this.state.draggerPosition}
draggerVisible={this.state.draggerVisible}
transformX={this.state.currentTransformX}
- parentPosition={this.state.position} />
+ />
<Dragger
toggleShowDraggerTime={this.toggleShowDraggerTime}
handleDragDragger={this.handleDragDragger}
@@ -1409,7 +1417,7 @@ class TimelineAxis extends React.Component {
draggerPosition={this.state.draggerPositionB}
draggerVisible={this.state.draggerVisibleB}
transformX={this.state.currentTransformX}
- parentPosition={this.state.position} />
+ />
</React.Fragment>
:
<React.Fragment>
@@ -1423,7 +1431,7 @@ class TimelineAxis extends React.Component {
draggerPosition={this.state.draggerPositionB}
draggerVisible={this.state.draggerVisibleB}
transformX={this.state.currentTransformX}
- parentPosition={this.state.position} />
+ />
<Dragger
toggleShowDraggerTime={this.toggleShowDraggerTime}
handleDragDragger={this.handleDragDragger}
@@ -1434,7 +1442,7 @@ class TimelineAxis extends React.Component {
draggerPosition={this.state.draggerPosition}
draggerVisible={this.state.draggerVisible}
transformX={this.state.currentTransformX}
- parentPosition={this.state.position} />
+ />
</React.Fragment>
}
</svg>
diff --git a/web/js/components/timeline/timeline-axis/timeline-dragger.js b/web/js/components/timeline/timeline-axis/timeline-dragger.js
index 785cc98b7..15c05895f 100644
--- a/web/js/components/timeline/timeline-axis/timeline-dragger.js
+++ b/web/js/components/timeline/timeline-axis/timeline-dragger.js
@@ -1,10 +1,18 @@
import React, { PureComponent } from 'react';
+import PropTypes from 'prop-types';
import Draggable from 'react-draggable';
class Dragger extends PureComponent {
render() {
- let { transformX, draggerPosition, draggerName, handleDragDragger, toggleShowDraggerTime, selectDragger, compareModeActive, disabled } = this.props;
- let draggerLetter = draggerName === 'selected' ? 'A' : 'B';
+ let { transformX,
+ draggerPosition,
+ draggerVisible,
+ draggerName,
+ handleDragDragger,
+ toggleShowDraggerTime,
+ selectDragger,
+ compareModeActive,
+ disabled } = this.props;
return (
<Draggable
axis='x'
@@ -16,7 +24,7 @@ class Dragger extends PureComponent {
disabled={disabled}
>
<g
- style={{ cursor: 'pointer', display: this.props.draggerVisible ? 'flex' : 'none' }}
+ style={{ cursor: 'pointer', display: draggerVisible ? 'flex' : '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>
@@ -24,13 +32,13 @@ class Dragger extends PureComponent {
? <text
fontSize='30px'
fontWeight='400'
- x='0'
- y='65'
+ x='11'
+ y='48'
fill={disabled ? '#ccc' : '#000'}
transform='translate(39, 10)'
textRendering='optimizeLegibility'
clipPath='url(#textDisplay)'>
- {draggerLetter}
+ {draggerName === 'selected' ? 'A' : 'B'}
</text>
: <React.Fragment>
<rect pointerEvents="none" fill='#515151' width='3' height='20' x='52' y='39'></rect>
@@ -44,4 +52,16 @@ class Dragger extends PureComponent {
}
}
+Dragger.propTypes = {
+ compareModeActive: PropTypes.bool,
+ disabled: PropTypes.bool,
+ draggerName: PropTypes.string,
+ draggerPosition: PropTypes.number,
+ draggerVisible: PropTypes.bool,
+ handleDragDragger: PropTypes.func,
+ selectDragger: PropTypes.func,
+ toggleShowDraggerTime: PropTypes.func,
+ transformX: PropTypes.number
+};
+
export default Dragger;
diff --git a/web/js/components/timeline/timeline-controls/animation-button.js b/web/js/components/timeline/timeline-controls/animation-button.js
index 84348cf42..b33667f48 100644
--- a/web/js/components/timeline/timeline-controls/animation-button.js
+++ b/web/js/components/timeline/timeline-controls/animation-button.js
@@ -1,4 +1,5 @@
import React, { PureComponent } from 'react';
+import PropTypes from 'prop-types';
class AnimationButton extends PureComponent {
render() {
@@ -15,4 +16,8 @@ class AnimationButton extends PureComponent {
}
}
+AnimationButton.propTypes = {
+ clickAnimationButton: PropTypes.func
+};
+
export default AnimationButton;
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 ce1c8b4c5..837a94f5d 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
@@ -6,7 +6,7 @@ import AxisTimeScaleChangeTooltip from './axis-timescale-change-tooltip';
* Up/down arrows for changing timeScale, also wrapper for tooltip
*
* @class AxisTimeScaleChangeControls
- * @extends React.Component
+ * @extends PureComponent
*/
class AxisTimeScaleChangeControls extends PureComponent {
onClickUp = () => {
@@ -17,13 +17,14 @@ class AxisTimeScaleChangeControls extends PureComponent {
this.props.decrementTimeScale();
}
render() {
+ let { timeScale, toolTipHovered, changeTimeScale, hasSubdailyLayers } = this.props;
return (
<div className="zoom-level-change-arrows">
<AxisTimeScaleChangeTooltip
- timeScale={this.props.timeScale}
- toolTipHovered={this.props.toolTipHovered}
- changeTimeScale={this.props.changeTimeScale}
- hasSubdailyLayers={this.props.hasSubdailyLayers}
+ timeScale={timeScale}
+ toolTipHovered={toolTipHovered}
+ changeTimeScale={changeTimeScale}
+ hasSubdailyLayers={hasSubdailyLayers}
/>
<div
onClick={this.onClickUp}
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 3736fb94b..b27ef6e03 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
@@ -5,10 +5,11 @@ import PropTypes from 'prop-types';
* Tooltip appears on hover with clickable timeScales based on subdaily availabilty
*
* @class AxisTimeScaleChangeTooltip
- * @extends React.Component
+ * @extends PureComponent
*/
class AxisTimeScaleChangeTooltip extends PureComponent {
render() {
+ let { timeScale, toolTipHovered, changeTimeScale, hasSubdailyLayers } = this.props;
return (
<React.Fragment>
<div id="zoom-btn-container-axis">
@@ -16,47 +17,47 @@ class AxisTimeScaleChangeTooltip extends PureComponent {
id="current-zoom"
className={'zoom-btn zoom-level-display-text'}
>
- {this.props.timeScale}
+ {timeScale}
</span>
<div className="wv-zoom-tooltip"
- style={{ display: this.props.toolTipHovered ? 'block' : 'none' }}
+ style={{ display: toolTipHovered ? 'block' : 'none' }}
>
<div id="timeline-zoom" className="timeline-zoom">
<label style={{ textDecoration: 'underline', paddingBottom: '4px', color: '#fff' }}>TIMESCALE</label>
<span
id="zoom-years"
className="zoom-btn zoom-btn-inactive zoom-years"
- onClick={() => this.props.changeTimeScale('year')}
+ onClick={() => changeTimeScale(1)}
>
YEAR
</span>
<span
id="zoom-months"
className="zoom-btn zoom-btn-inactive zoom-months"
- onClick={() => this.props.changeTimeScale('month')}
+ onClick={() => changeTimeScale(2)}
>
MONTH
</span>
<span
id="zoom-days"
className="zoom-btn zoom-btn-inactive zoom-days"
- onClick={() => this.props.changeTimeScale('day')}
+ onClick={() => changeTimeScale(3)}
>
DAY
</span>
<span
id="zoom-hours"
className="zoom-btn zoom-btn-inactive zoom-hours"
- style={{ display: this.props.hasSubdailyLayers ? 'block' : 'none' }}
- onClick={() => this.props.changeTimeScale('hour')}
+ style={{ display: hasSubdailyLayers ? 'block' : 'none' }}
+ onClick={() => changeTimeScale(4)}
>
HOUR
</span>
<span
id="zoom-minutes"
className="zoom-btn zoom-btn-inactive zoom-minutes"
- style={{ display: this.props.hasSubdailyLayers ? 'block' : 'none' }}
- onClick={() => this.props.changeTimeScale('minute')}
+ style={{ display: hasSubdailyLayers ? 'block' : 'none' }}
+ onClick={() => changeTimeScale(5)}
>
MINUTE
</span>
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 3690546ac..25096c6a3 100644
--- a/web/js/components/timeline/timeline-controls/axis-timescale-change.js
+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change.js
@@ -2,6 +2,15 @@ import React 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
+};
+
/*
* Parent element for timeScale change controls and tooltip
* on the right side of the timeline
@@ -13,8 +22,7 @@ class AxisTimeScaleChange extends React.Component {
constructor(props) {
super(props);
this.state = {
- toolTipHovered: false,
- timeScales: [ 'day', 'month', 'year' ]
+ toolTipHovered: false
};
}
@@ -43,58 +51,33 @@ class AxisTimeScaleChange extends React.Component {
})
}
- // get available time scales based on if subdaily or not
- getTimeScales = (hasSubdailyLayers) => {
- if (hasSubdailyLayers) {
- return [ 'minute', 'hour', 'day', 'month', 'year' ];
- } else {
- return [ 'day', 'month', 'year' ];
- }
- }
-
incrementTimeScale = () => {
- let timeScales = this.state.timeScales;
- let arrayIndex = timeScales.indexOf(this.props.timeScale);
- if (arrayIndex < timeScales.length - 1) {
- let nextGreaterTimeScale = timeScales[arrayIndex + 1];
- this.props.changeTimescale(nextGreaterTimeScale);
+ let timeScaleNumber = timeScaleToNumberKey[this.props.timeScale];
+ let maxTimeScaleNumber = this.props.hasSubdailyLayers ? 5 : 3;
+ if (timeScaleNumber < maxTimeScaleNumber) {
+ this.props.changeTimeScale(timeScaleNumber + 1);
}
}
decrementTimeScale = () => {
- let timeScales = this.state.timeScales;
- let arrayIndex = timeScales.indexOf(this.props.timeScale);
- if (arrayIndex > 0) {
- let nextSmallerTimeScale = timeScales[arrayIndex - 1];
- this.props.changeTimescale(nextSmallerTimeScale);
- }
- }
-
- componentDidMount() {
- this.setState({
- timeScales: this.getTimeScales(this.props.hasSubdailyLayers)
- })
- }
-
- componentDidUpdate(prevProps) {
- if(this.props.hasSubdailyLayers !== prevProps.hasSubdailyLayers) {
- this.setState({
- timeScales: this.getTimeScales(this.props.hasSubdailyLayers)
- })
+ let timeScaleNumber = timeScaleToNumberKey[this.props.timeScale];
+ if (timeScaleNumber > 1) {
+ this.props.changeTimeScale(timeScaleNumber - 1);
}
}
render() {
+ let { timeScale, hasSubdailyLayers, changeTimeScale } = this.props;
return (
- this.props.timeScale ?
+ timeScale ?
<div
onMouseEnter={() => this.toggleTooltipHover(true)}
onMouseLeave={() => this.toggleTooltipHover(false)}>
<AxisTimeScaleChangeControls
- timeScale={this.props.timeScale}
- hasSubdailyLayers={this.props.hasSubdailyLayers}
+ timeScale={timeScale}
+ hasSubdailyLayers={hasSubdailyLayers}
toolTipHovered={this.state.toolTipHovered}
- changeTimeScale={this.props.changeTimescale}
+ changeTimeScale={changeTimeScale}
incrementTimeScale={this.incrementTimeScale}
decrementTimeScale={this.decrementTimeScale}
/>
@@ -107,7 +90,7 @@ class AxisTimeScaleChange extends React.Component {
AxisTimeScaleChange.propTypes = {
timeScale: PropTypes.string,
- changeTimescale: PropTypes.func,
+ changeTimeScale: PropTypes.func,
hasSubdailyLayers: PropTypes.bool
};
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 cd30a2728..c5008ec6e 100644
--- a/web/js/components/timeline/timeline-controls/date-change-arrows.js
+++ b/web/js/components/timeline/timeline-controls/date-change-arrows.js
@@ -1,16 +1,18 @@
import React, { PureComponent } from 'react';
+import PropTypes from 'prop-types';
class DateChangeArrows extends PureComponent {
render() {
+ let { leftArrowDisabled, leftArrowDown, leftArrowUp, rightArrowDisabled, rightArrowDown, rightArrowUp } = this.props;
return (
<div>
{/* LEFT ARROW */}
<div
- className={`button-action-group ${this.props.leftArrowDisabled ? 'button-disabled' : ''}`}
+ className={`button-action-group ${leftArrowDisabled ? 'button-disabled' : ''}`}
id="left-arrow-group"
title="Click and hold to animate backwards"
- onMouseDown={this.props.leftArrowDown}
- onMouseUp={this.props.leftArrowUp}
+ onMouseDown={leftArrowDown}
+ onMouseUp={leftArrowUp}
>
<svg id="timeline-svg" width="24" height="30">
<path
@@ -22,11 +24,11 @@ class DateChangeArrows extends PureComponent {
{/* RIGHT ARROW */}
<div
- className={`button-action-group ${this.props.rightArrowDisabled ? 'button-disabled' : ''}`}
+ className={`button-action-group ${rightArrowDisabled ? 'button-disabled' : ''}`}
id="right-arrow-group"
title="Click and hold to animate forwards"
- onMouseDown={this.props.rightArrowDown}
- onMouseUp={this.props.rightArrowUp}
+ onMouseDown={rightArrowDown}
+ onMouseUp={rightArrowUp}
>
<svg width="24" height="30">
<path
@@ -40,4 +42,13 @@ class DateChangeArrows extends PureComponent {
}
}
+DateChangeArrows.propTypes = {
+ leftArrowDisabled: PropTypes.bool,
+ leftArrowDown: PropTypes.func,
+ leftArrowUp: PropTypes.func,
+ rightArrowDisabled: PropTypes.bool,
+ rightArrowDown: PropTypes.func,
+ rightArrowUp: PropTypes.func
+};
+
export default DateChangeArrows;
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 7efdf46ad..834499194 100644
--- a/web/js/components/timeline/timeline-controls/interval-timescale-change.js
+++ b/web/js/components/timeline/timeline-controls/interval-timescale-change.js
@@ -39,16 +39,19 @@ class TimeScaleIntervalChange extends Component {
}
componentDidUpdate (prevProps, prevState) {
- if (this.props.customIntervalValue && this.props.timeScaleChangeUnit) {
- if (this.props.customSelected && this.props.customIntervalValue !== 1 && this.state.customIntervalText === 'Custom') {
+ let { customIntervalValue, timeScaleChangeUnit, customSelected } = this.props;
+ if (customIntervalValue && timeScaleChangeUnit) {
+ if (customSelected && customIntervalValue !== 1 && this.state.customIntervalText === 'Custom') {
this.setCustomIntervalText();
- } else if (this.props.customSelected && (this.props.customIntervalValue !== prevProps.customIntervalValue || this.props.timeScaleChangeUnit !== prevProps.timeScaleChangeUnit)) {
+ } else if (customSelected && (customIntervalValue !== prevProps.customIntervalValue || timeScaleChangeUnit !== prevProps.timeScaleChangeUnit)) {
this.setCustomIntervalText();
}
}
}
render() {
+ let { customIntervalText, toolTipHovered } = this.state;
+ let { customSelected, timeScaleChangeUnit } = this.props;
return (
<React.Fragment>
<div id="zoom-btn-container"
@@ -58,14 +61,14 @@ class TimeScaleIntervalChange extends Component {
{/* timeScale display */}
<span
id="current-zoom"
- className={`zoom-btn zoom-btn-active${this.props.customSelected ? ' custom-interval-text' : ''}`}
+ className={`zoom-btn zoom-btn-active${customSelected ? ' custom-interval-text' : ''}`}
>
- {this.props.customSelected ? this.state.customIntervalText : 1 + ' ' + this.props.timeScaleChangeUnit}
+ {customSelected ? customIntervalText : 1 + ' ' + timeScaleChangeUnit}
</span>
{/* hover timeScale unit dialog / entry point to Custom selector */}
<div className="wv-tooltip"
- style={{ display: this.state.toolTipHovered ? 'block' : 'none' }}
+ style={{ display: toolTipHovered ? 'block' : 'none' }}
>
<div id="timeline-zoom" className="timeline-zoom">
<span
@@ -106,10 +109,10 @@ class TimeScaleIntervalChange extends Component {
<span
id="zoom-custom"
className="zoom-btn zoom-btn-inactive zoom-custom custom-interval-text"
- style={{ display: this.state.customIntervalText === 'Custom' ? 'none' : 'block' }}
+ style={{ display: customIntervalText === 'Custom' ? 'none' : 'block' }}
onClick={() => this.handleClickZoom('custom')}
>
- {this.state.customIntervalText}
+ {customIntervalText}
</span>
<span
id="zoom-custom-static"
diff --git a/web/js/components/timeline/timeline.css b/web/js/components/timeline/timeline.css
index db8d3483c..4e0c0e701 100644
--- a/web/js/components/timeline/timeline.css
+++ b/web/js/components/timeline/timeline.css
@@ -69,38 +69,8 @@ line {
}
/* DEVELOPMENT */
-.line {
- top: 102px;
- width: 2px;
- height: 60px;
- background: rgba(21,21,255,0.4);
- position: absolute;
- pointer-events: none;
-}
-
-.linered {
- width: 3px;
- height: 70px;
- background: red;
- position: absolute;
- pointer-events: none;
-}
-.dateTempHolderTextBlock {
- height: 90px;
- width: 300px;
- border: 2px solid;
- text-align: center;
- font-size: 24px;
- background: rgba(0, 0, 0, 0.5);
- color: white;
-}
-
-.tick {
- margin-left: -1px;
-}
-
-form button, form input, form select {
+/* form button, form input, form select {
border: none;
outline: thin solid black;
width: 96px;
@@ -112,15 +82,11 @@ form button {
form select {
text-align-last: center;
padding-left: 15px;
-}
-.incrementButton {
- width: 70px;
- height: 99px;
- font-weight: 700;
-}
-.changeZoomLevelButtons button {
- background: dimgrey;
- color: white;
+} */
+
+#wv-animation-widget-custom-interval select {
+ text-align-last: center;
+ padding-left: 15px;
}
#timelineContainer > div:nth-child(1) > div.wv-date-selector-widget {
diff --git a/web/js/components/timeline/timeline.js b/web/js/components/timeline/timeline.js
index 25663f3c9..969ffe533 100644
--- a/web/js/components/timeline/timeline.js
+++ b/web/js/components/timeline/timeline.js
@@ -22,6 +22,24 @@ import AxisTimeScaleChange from './timeline-controls/axis-timescale-change';
// minute: 'min'
// };
+const timeScaleFromNumberKey = {
+ '0': 'custom',
+ '1': 'year',
+ '2': 'month',
+ '3': 'day',
+ '4': 'hour',
+ '5': 'minute'
+};
+
+const timeScaleToNumberKey = {
+ 'custom': '0',
+ 'year': '1',
+ 'month': '2',
+ 'day': '3',
+ 'hour': '4',
+ 'minute': '5'
+};
+
class Timeline extends React.Component {
constructor(props) {
super(props);
@@ -64,9 +82,9 @@ class Timeline extends React.Component {
}
// Change the timescale parent state
- changeTimescale = (timeScale) => {
- if (this.state.timeScale !== timeScale) {
- this.props.changeTimeScale(timeScale);
+ changeTimeScale = (timeScaleNumber) => {
+ if (this.state.timeScale !== timeScaleFromNumberKey[timeScaleNumber]) {
+ this.props.changeTimeScale(timeScaleNumber);
}
}
@@ -95,28 +113,44 @@ class Timeline extends React.Component {
// checkLeftArrowDisabled
checkLeftArrowDisabled = () => {
- let previousPastDateBasedOnIncrement;
- if (this.state.draggerSelected === 'selected') {
- previousPastDateBasedOnIncrement = moment.utc(this.state.dateFormatted).subtract(this.state.intervalChangeAmt, this.state.timeScaleChangeUnit);
- } else {
- previousPastDateBasedOnIncrement = moment.utc(this.state.dateFormattedB).subtract(this.state.intervalChangeAmt, this.state.timeScaleChangeUnit);
+ let { draggerSelected,
+ dateFormatted,
+ dateFormattedB,
+ intervalChangeAmt,
+ timeScaleChangeUnit,
+ timelineStartDateLimit } = this.state;
+ let previousIncrementDate;
+ if (intervalChangeAmt && timeScaleChangeUnit) {
+ if (draggerSelected === 'selected') {
+ previousIncrementDate = moment.utc(dateFormatted).subtract(intervalChangeAmt, timeScaleChangeUnit);
+ } else {
+ previousIncrementDate = moment.utc(dateFormattedB).subtract(intervalChangeAmt, timeScaleChangeUnit);
+ }
+ this.setState({
+ leftArrowDisabled: previousIncrementDate.isSameOrBefore(timelineStartDateLimit)
+ })
}
- this.setState({
- leftArrowDisabled: previousPastDateBasedOnIncrement.isSameOrBefore(this.state.timelineStartDateLimit)
- })
}
// checkRightArrowDisabled
checkRightArrowDisabled = () => {
- let nextFutureDateBasedOnIncrement;
- if (this.state.draggerSelected === 'selected') {
- nextFutureDateBasedOnIncrement = moment.utc(this.state.dateFormatted).add(this.state.intervalChangeAmt, this.state.timeScaleChangeUnit);
- } else {
- nextFutureDateBasedOnIncrement = moment.utc(this.state.dateFormattedB).add(this.state.intervalChangeAmt, this.state.timeScaleChangeUnit);
+ let { draggerSelected,
+ dateFormatted,
+ dateFormattedB,
+ intervalChangeAmt,
+ timeScaleChangeUnit,
+ timelineEndDateLimit } = this.state;
+ let nextIncrementDate;
+ if (intervalChangeAmt && timeScaleChangeUnit) {
+ if (draggerSelected === 'selected') {
+ nextIncrementDate = moment.utc(dateFormatted).add(intervalChangeAmt, timeScaleChangeUnit);
+ } else {
+ nextIncrementDate = moment.utc(dateFormattedB).add(intervalChangeAmt, timeScaleChangeUnit);
+ }
+ this.setState({
+ rightArrowDisabled: nextIncrementDate.isSameOrAfter(timelineEndDateLimit)
+ })
}
- this.setState({
- rightArrowDisabled: nextFutureDateBasedOnIncrement.isSameOrAfter(this.state.timelineEndDateLimit)
- })
}
// open animation dialog
@@ -170,9 +204,11 @@ class Timeline extends React.Component {
// }
componentDidUpdate(prevProps, prevState) {
- if ((this.state.intervalChangeAmt !== prevState.intervalChangeAmt || this.state.timeScaleChangeUnit !== prevState.timeScaleChangeUnit)
- || (this.state.draggerSelected === 'selected' && this.state.dateFormatted !== prevState.dateFormatted)
- || (this.state.draggerSelected === 'selectedB' && this.state.dateFormattedB !== prevState.dateFormattedB)) {
+ let { intervalChangeAmt, timeScaleChangeUnit, draggerSelected, dateFormatted, dateFormattedB } = this.state;
+ if ((intervalChangeAmt !== prevState.intervalChangeAmt || timeScaleChangeUnit !== prevState.timeScaleChangeUnit)
+ || (draggerSelected === 'selected' && dateFormatted !== prevState.dateFormatted)
+ || (draggerSelected === 'selectedB' && dateFormattedB !== prevState.dateFormattedB)
+ || (draggerSelected !== prevState.draggerSelected)) {
this.checkLeftArrowDisabled();
this.checkRightArrowDisabled();
}
@@ -228,7 +264,7 @@ class Timeline extends React.Component {
updateDate={this.updateDate}
hasSubdailyLayers={this.state.hasSubdailyLayers}
parentOffset={this.state.parentOffset}
- changeTimescale={this.changeTimescale}
+ changeTimeScale={this.changeTimeScale}
compareModeActive={this.state.compareModeActive}
draggerSelected={this.state.draggerSelected}
onChangeSelectedDragger={this.props.onChangeSelectedDragger}
@@ -256,18 +292,18 @@ class Timeline extends React.Component {
<div className="zoom-level-change" style={{ width: '75px', display: this.state.timelineHidden ? 'none' : 'block'}}>
<AxisTimeScaleChange
timeScale={this.state.timeScale}
- changeTimescale={this.changeTimescale}
+ changeTimeScale={this.changeTimeScale}
hasSubdailyLayers={this.state.hasSubdailyLayers}
/>
</div>
{/* 🍔 Open/Close Chevron 🍔 */}
<div id="timeline-hide" onClick={this.toggleHideTimeline}>
- {this.state.timelineHidden ?
- <div className="wv-timeline-hide wv-timeline-hide-double-chevron-left"></div>
- :
- <div className="wv-timeline-hide wv-timeline-hide-double-chevron-right"></div>
- }
+ {/* {this.state.timelineHidden ? */}
+ <div className={`wv-timeline-hide wv-timeline-hide-double-chevron-${this.state.timelineHidden ? 'left' : 'right'}`}></div>
+ {/* : */}
+ {/* <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 bb1836871..bb63ab733 100644
--- a/web/js/date/timeline.js
+++ b/web/js/date/timeline.js
@@ -28,7 +28,7 @@ export function timeline(models, config, ui) {
let subdaily = models.layers.hasSubDaily();
self.enabled = false;
self.startDate = new Date(config.startDate);
- self.parentOffset = (subdaily ? 404 : 310) + 10;
+ self.parentOffset = (subdaily ? 414 : 310) + 10;
self.active = false;
self.delay = 500;
@@ -157,6 +157,11 @@ export function timeline(models, config, ui) {
}
};
+ /**
+ * Get Date Selector Input Props
+ *
+ * @return {void}
+ */
var getInputProps = function() {
var model = models.date;
var min = model.minDate();
@@ -199,7 +204,7 @@ export function timeline(models, config, ui) {
} else {
hasSubDaily = models.layers.hasSubDaily();
}
- self.parentOffset = (hasSubDaily ? 404 : 310) + 10;
+ self.parentOffset = (hasSubDaily ? 414 : 310) + 10;
self.width =
// $(window).outerWidth(true) -
@@ -362,7 +367,7 @@ export function timeline(models, config, ui) {
});
};
- // TEST updateRange
+ // updateRange of animation draggers
var updateAnimationRange = (startDate, endDate) => {
ui.anim.rangeselect.updateRange(startDate, endDate, true);
};
@@ -434,8 +439,9 @@ export function timeline(models, config, ui) {
};
// change time scale
- var changeTimeScale = (timeScale) => {
- models.date.setSelectedZoom(timeScaleToNumberKey[timeScale]);
+ // timeScaleNumber is an integer 1 - 5
+ self.changeTimeScale = (timeScaleNumber) => {
+ models.date.setSelectedZoom(timeScaleNumber);
updateTimeScaleState();
};
@@ -515,7 +521,7 @@ export function timeline(models, config, ui) {
stopper: stopper,
clickAnimationButton: clickAnimationButton,
toggleHideTimeline: self.toggle,
- changeTimeScale: changeTimeScale,
+ changeTimeScale: self.changeTimeScale,
intervalTimeScale: intervalSelected,
intervalDelta: intervalDelta,
setSelectedInterval: setSelectedInterval,
@@ -633,7 +639,7 @@ export function timeline(models, config, ui) {
setIntervalInput(1, 'day');
self.reactComponent.setState({
hasSubdailyLayers: subdaily
- }, changeTimeScale('day'));
+ }, self.changeTimeScale(3)); // default to day
} else {
self.reactComponent.setState({
hasSubdailyLayers: subdaily