Interactive interface for browsing global, full-resolution satellite imagery
add more off time line into individual components, left right arrows, hamburger, animation button
Edward Plato93ce28be7162
diff --git a/web/css/dateselector.css b/web/css/dateselector.cssindex 2bb1615fa..6f6097ccd 100644--- a/web/css/dateselector.css+++ b/web/css/dateselector.css@@ -57,13 +57,13 @@display: inline-block;}-.button-action-group,+/* .button-action-group,.date-arrows {-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;-}+} */.button-action-group {height: 40px;diff --git a/web/css/timeline.css b/web/css/timeline.cssindex 1f7ce6974..71a4a026f 100644--- a/web/css/timeline.css+++ b/web/css/timeline.css@@ -259,13 +259,13 @@ g.plot rect.data-bar-invisible {width: 86px;}-.button-action-group,+/* .button-action-group,.date-arrows {-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;-}+} */.button-action-group {height: 60px;diff --git a/web/js/animation/ui.js b/web/js/animation/ui.jsindex 7c1ec52e3..a64b66b9f 100644--- a/web/js/animation/ui.js+++ b/web/js/animation/ui.js@@ -184,7 +184,8 @@ export function animationUi(models, ui) {**/self.getInterval = function () {- return zooms[ui.timeline.config.currentZoom - 1];+ // return zooms[ui.timeline.config.currentZoom - 1];+ return zooms[3];};/*diff --git a/web/js/animation/widget.js b/web/js/animation/widget.jsindex c3335f9c2..83a4cfd8f 100644--- a/web/js/animation/widget.js+++ b/web/js/animation/widget.js@@ -174,7 +174,8 @@ export function animationWidget(models, config, ui) {} else {zooms = ['yearly', 'monthly', 'daily'];}- return zooms[timeline.config.currentZoom - 1];+ // return zooms[timeline.config.currentZoom - 1];+ return zooms[2];};/*diff --git a/web/js/app.js b/web/js/app.jsindex 287d62f37..955d4ff90 100644--- a/web/js/app.js+++ b/web/js/app.js@@ -483,15 +483,15 @@ class App extends React.Component {// ui.timeline.ticks = timelineTicks(models, config, ui);// ui.timeline.pick = timelinePick(models, config, ui);// ui.timeline.pan = timelinePan(models, config, ui);- ui.timeline.input = timelineInput(models, config, ui);+ // ui.timeline.input = timelineInput(models, config, ui);// ui.timeline.config = timelineConfig(models, config, ui);- // if (config.features.animation) {- // ui.anim = {};- // ui.anim.rangeselect = animationRangeSelect(models, config, ui); // SETS STATE: NEEDS TO LOAD BEFORE ANIMATION WIDGET- // ui.anim.widget = animationWidget(models, config, ui);- // ui.anim.gif = animationGif(models, config, ui);- // ui.anim.ui = animationUi(models, ui);- // }+ if (config.features.animation) {+ ui.anim = {};+ ui.anim.rangeselect = animationRangeSelect(models, config, ui); // SETS STATE: NEEDS TO LOAD BEFORE ANIMATION WIDGET+ ui.anim.widget = animationWidget(models, config, ui);+ ui.anim.gif = animationGif(models, config, ui);+ ui.anim.ui = animationUi(models, ui);+ }if (config.features.compare) {ui.timeline.compare = timelineCompare(models, config, ui);}diff --git a/web/js/components/date-selector/date-selector.js b/web/js/components/date-selector/date-selector.jsindex 94429141d..c6e0133bf 100644--- a/web/js/components/date-selector/date-selector.js+++ b/web/js/components/date-selector/date-selector.js@@ -73,7 +73,9 @@ class DateSelector extends React.Component {this.setState({date: date});- this.props.onDateChange(date, this.props.id, type, amt);+ // this.props.onDateChange(date, this.props.id, type, amt);+ // # send argument to indicate input change for time axis updateScale call+ this.props.onDateChange(date, true);}renderSubdaily() {if (this.state.maxZoom >= 4) {@@ -126,7 +128,6 @@ class DateSelector extends React.Component {}}render() {- // console.log(this.props.date)return (<div className="wv-date-selector-widget"><DateInputColumndiff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.jsindex 90cc61de8..dbbdb37f4 100644--- a/web/js/components/timeline/timeline-axis/timeline-axis.js+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js@@ -123,7 +123,8 @@ class TimelineAxis extends React.Component {let hoverTimeZero;let hoverTimeNextZero;- let draggerDateActual = moment.utc(this.state.draggerTimeState);+ let draggerDateActual = moment.utc(inputDate ? inputDate : this.state.draggerTimeState);+ console.log(draggerDateActual)let draggerDateActualB = moment.utc(this.state.draggerTimeStateB);if (timeScale === 'minute') {@@ -221,6 +222,8 @@ class TimelineAxis extends React.Component {// console.log(draggerPosition - pixelsToAdd + position - 49)// console.log(draggerPositionB - pixelsToAdd + position - 49)this.setState({+ draggerTimeState: draggerDateActual.format(),+ // redLineTime: draggerDateActual.format(),draggerPosition: draggerPosition - pixelsToAdd + position - 49,draggerVisible: draggerVisible,draggerPositionB: draggerPositionB - pixelsToAdd + position - 49,@@ -579,7 +582,7 @@ class TimelineAxis extends React.Component {// this.handleDragDragger(null, {'deltaX': this.state.leftOffset})// console.log(this.state.leftOffset)// TODO: FIX PARENT OFFSET- let draggerPosition = this.state.draggerSelected ? this.state.leftOffset - (this.props.subdaily ? 404 : 310) - 10 - 49 : this.state.draggerPosition;+ let draggerPosition = this.state.draggerSelected ? this.state.leftOffset - 49 : this.state.draggerPosition;let draggerPositionB = this.state.draggerSelectedB ? this.state.leftOffset - 49 : this.state.draggerPositionB;// console.log(this.state.draggerSelected, this.state.draggerSelectedB)@@ -591,7 +594,7 @@ class TimelineAxis extends React.Component {draggerTimeState: this.state.hoverTime,selectedDate: this.state.hoverTime,moved: false- }, this.props.updateDate(this.state.hoverTime))+ }, this.props.updateDate(this.state.hoverTime));}}@@ -606,12 +609,13 @@ class TimelineAxis extends React.Component {}, function() {let parentBoundingClientRect = document.querySelector('#wv-timeline-axis').getBoundingClientRect();this.setState({- parentBoundingClientRectLeft: parentBoundingClientRect.left+ parentBoundingClientRectLeft: this.props.parentOffset});})};componentDidMount() {+ console.log(this.props)//# resizewindow.addEventListener("resize", this.handleResize);// let axisWidth = Number((window.innerWidth * 0.9).toFixed(2));@@ -714,7 +718,7 @@ class TimelineAxis extends React.Component {// console.log(setPosition)let parentBoundingClientRect = document.querySelector('#wv-timeline-axis').getBoundingClientRect();this.setState({- parentBoundingClientRectLeft: parentBoundingClientRect.left+ parentBoundingClientRectLeft: this.props.parentOffset});});}@@ -731,14 +735,20 @@ class TimelineAxis extends React.Component {//# BEST WAY TO HANDLE THIS?componentDidUpdate(prevProps, prevState) {+ // console.log(this.props)+ if (this.props.inputChange === true) {+ console.log(this.props.selectedDate)+ this.updateScale(this.props.selectedDate, this.state.timeScale);+ this.props.resetInput();+ }// console.log(this.props.selectedDate, prevProps.selectedDate)// console.log(moment.utc(prevProps.selectedDate).format(), moment.utc(prevState.selectedDate).format())// let propsSelectedDate = moment.utc(prevProps.selectedDate).format();// let stateSelectedDate = moment.utc(prevState.selectedDate).format();// console.log(propsSelectedDate, stateSelectedDate)- console.log(prevProps.timeScaleChangeUnit, this.props.timeScaleChangeUnit, this.state.timeScaleChangeUnit, prevState.timeScaleChangeUnit)+ // console.log(prevProps.timeScaleChangeUnit, this.props.timeScaleChangeUnit, this.state.timeScaleChangeUnit, prevState.timeScaleChangeUnit)if (this.state.timeScale !== prevState.timeScale) {this.updateScale(null, this.state.timeScale);}@@ -751,11 +761,22 @@ class TimelineAxis extends React.Component {this.handleResize();}+// console.log(prevProps.selectedDate, this.props.selectedDate, this.state.selectedDate, prevState.selectedDate)+// console.log(prevProps.draggerTimeState, this.props.draggerTimeState, this.state.draggerTimeState, prevState.draggerTimeState)++ if (this.props.selectedDate !== prevProps.selectedDate &&+ this.state.draggerTimeState !== prevState.draggerTimeState &&+ moment.utc(this.state.draggerTimeState).format() !== moment.utc(prevState.draggerTimeState).format()) {++ // moment.utc(this.state.draggerTimeState).format() !== moment.utc(prevState.draggerTimeState).format()) {s++ // if (this.props.selectedDate !== prevProps.selectedDate &&+ // moment.utc(this.state.hoverTime).format() !== moment.utc(this.props.selectedDate).format()+ // && moment.utc(this.state.draggerTimeState).format() !== moment.utc(this.props.selectedDate).format()) {- if (this.props.selectedDate !== prevProps.selectedDate) {+ // console.log(this.props.selectedDate, prevProps.selectedDate, this.state.hoverTime, this.state.draggerTimeState)+ // console.log(moment.utc(this.state.hoverTime).format(), moment.utc(this.props.selectedDate).format())- // console.log(this.props.selectedDate, prevProps.selectedDate)- // console.log('ok', this.props)let manualTimeScaleChangeUnit = this.props.timeScaleChangeUnit || this.state.timeScale;let options = timeScaleOptions[manualTimeScaleChangeUnit].timeAxis;@@ -766,11 +787,12 @@ class TimelineAxis extends React.Component {// console.log(newSelectedDate.format(), frontDate.format(), manualTimeScaleChangeUnit, gridWidth)// console.log(moment.utc(this.props.selectedDate).format(), moment.utc(prevProps.selectedDate).format())- let newDraggerPosition = this.getDraggerPosition(newSelectedDate, frontDate, manualTimeScaleChangeUnit, gridWidth)+ // let newDraggerPosition = this.getDraggerPosition(newSelectedDate, frontDate, manualTimeScaleChangeUnit, gridWidth)// console.log(this.state.draggerPosition, newDraggerPosition)// console.log(this.props, newSelectedDate, moment.utc(this.props.selectedDate).format())- this.setDraggerToTime(this.props.selectedDate)+ // this.setDraggerToTime(this.props.selectedDate)+ // this.updateScale(this.props.selectedDate, this.state.timeScale);// if (this.props.changeAmt !== null) {// console.log('hit')// if (this.props.changeAmt > 0) {@@ -1064,7 +1086,7 @@ handleDragDragger = (draggerName, e, d) => {console.log(newDraggerTime)this.setState({draggerPosition: draggerPosition,- redLineTime: newDraggerTime,+ // redLineTime: newDraggerTime,draggerTimeState: newDraggerTime,moved: true,draggerSelected: true,@@ -1211,6 +1233,7 @@ handleDragDragger = (draggerName, e, d) => {<rect width="200" height="70" /></clipPath></defs>+ <g id="wv-rangeselector-case"></g><Draggableaxis="x"onDrag={this.handleDrag.bind(this)}@@ -1255,10 +1278,10 @@ handleDragDragger = (draggerName, e, d) => {</svg>: null }{/* <div className="line" style={{transform: `translate(${this.state.leftOffset}px, 0px)`, display: this.state.showHoverLine ? 'block' : 'none'}}></div> */}- <div className="dateToolTip" style={{transform: `translate(${this.state.draggerPosition - 5}px, -100px)`, display: this.state.showDraggerTime && this.state.redLineTime ? 'block' : 'none'}}>{this.state.showDraggerTime && this.state.redLineTime ? this.state.redLineTime : null}</div>+ <div className="dateToolTip" style={{transform: `translate(${this.state.draggerPosition - 5}px, -100px)`, display: this.state.showDraggerTime && this.state.draggerTimeState ? 'block' : 'none'}}>{this.state.showDraggerTime && this.state.draggerTimeState ? this.state.draggerTimeState : null}</div>{/* 404 is #timeline-header width and 10 is margin - parent offset issue most likely */}- <div className="dateToolTip" style={{transform: `translate(${this.state.leftOffset - 52 - (this.props.subdaily ? 404 : 310) - 10}px, -100px)`, display: !this.state.showDraggerTime && this.state.showHoverLine ? 'block' : 'none'}}>{!this.state.showDraggerTime && this.state.hoverTime ? this.state.hoverTime : null}</div>+ <div className="dateToolTip" style={{transform: `translate(${this.state.leftOffset - 52}px, -100px)`, display: !this.state.showDraggerTime && this.state.showHoverLine ? 'block' : 'none'}}>{!this.state.showDraggerTime && this.state.hoverTime ? this.state.hoverTime : null}</div></div>{/* <div style={{ display: 'flex', marginTop: 10 }}>diff --git a/web/js/components/timeline/timeline-controls/animation-button.js b/web/js/components/timeline/timeline-controls/animation-button.jsnew file mode 100644index 000000000..84348cf42--- /dev/null+++ b/web/js/components/timeline/timeline-controls/animation-button.js@@ -0,0 +1,18 @@+import React, { PureComponent } from 'react';++class AnimationButton extends PureComponent {+ render() {+ return (+ <div+ className="button-action-group animate-button"+ id="animate-button"+ title="Set up animation"+ onClick={this.props.clickAnimationButton}+ >+ <i id="wv-animate" className="fas fa-video wv-animate" />+ </div>+ );+ }+}++export default AnimationButton;diff --git a/web/js/components/timeline/timeline-controls/date-change-arrows.js b/web/js/components/timeline/timeline-controls/date-change-arrows.jsindex 8cadfc890..89e1bdaeb 100644--- a/web/js/components/timeline/timeline-controls/date-change-arrows.js+++ b/web/js/components/timeline/timeline-controls/date-change-arrows.js@@ -4,11 +4,13 @@ class DateChangeArrows extends PureComponent {render() {return (<div>- {/* left arrow */}- {/* <div+ {/* LEFT ARROW */}+ <divclassName="button-action-group"id="left-arrow-group"title="Click and hold to animate backwards"+ onMouseDown={this.props.leftArrowDown}+ onMouseUp={this.props.leftArrowUp}><svg id="timeline-svg" width="24" height="30"><path@@ -16,13 +18,15 @@ class DateChangeArrows extends PureComponent {className="arrow"/></svg>- </div> */}+ </div>- {/* right arrow */}- {/* <div+ {/* RIGHT ARROW */}+ <divclassName="button-action-group"id="right-arrow-group"title="Click and hold to animate forwards"+ onMouseDown={this.props.rightArrowDown}+ onMouseUp={this.props.rightArrowUp}><svg width="24" height="30"><path@@ -30,7 +34,7 @@ class DateChangeArrows extends PureComponent {className="arrow"/></svg>- </div> */}+ </div></div>);}diff --git a/web/js/components/timeline/timeline.js b/web/js/components/timeline/timeline.jsindex 744b3d665..a7bafd3ef 100644--- a/web/js/components/timeline/timeline.js+++ b/web/js/components/timeline/timeline.js@@ -8,6 +8,10 @@ import './timeline.css';import TimelineAxisContainer from './timeline-axis/timeline-axis-container';import IntervalSelectorWidget from './interval-selector/interval-selector';+import DateSelector from '../date-selector/date-selector';+import DateChangeArrows from './timeline-controls/date-change-arrows';+import AnimationButton from './timeline-controls/animation-button';+class Timeline extends React.Component {constructor(props) {super(props);@@ -22,7 +26,8 @@ class Timeline extends React.Component {changeAmt: '',customIntervalValue: '',customIntervalZoomLevel: '',- customIntervalModalOpen: false+ customIntervalModalOpen: false,+ inputChange: false};}@@ -39,20 +44,33 @@ class Timeline extends React.Component {// })// }- updateDate = (date) => {- // console.log(date)- this.props.updateDate(date);- let dateFormatted = new Date(date).toISOString();+ updateDate = (date, inputChange) => {+ console.log(date)+ if (inputChange) {+ this.setState({+ inputChange: true+ }, this.props.updateDate(date));+ } else {+ this.props.updateDate(date);+ }++ // let dateFormatted = new Date(date).toISOString();// this.setState({// selectedDate: dateFormatted,// dateFormatted: dateFormatted// })}+ resetInput = () => {+ this.setState({+ inputChange: false+ });+ }+toggleCustomIntervalModal = () => {this.setState(prevState => ({customIntervalModalOpen: !prevState.customIntervalModalOpen- }))+ }));}componentDidUpdate() {@@ -75,14 +93,14 @@ class Timeline extends React.Component {changeAmt: 1,customIntervalValue: 1,customIntervalZoomLevel: this.props.timeScale- })+ });}setInterval = (intervalValue, zoomLevel) => {this.setState({customIntervalValue: intervalValue,customIntervalZoomLevel: zoomLevel- }, this.props.setIntervalInput(intervalValue, zoomLevel))+ }, this.props.setIntervalInput(intervalValue, zoomLevel));}setTimeScale = (timeScaleChangeUnit) => {@@ -101,93 +119,95 @@ class Timeline extends React.Component {}}+ // left/right arrows increment date+ incrementDate = (multiplier) => {+ this.props.incrementDate((multiplier * this.state.customIntervalValue), this.state.customIntervalZoomLevel);+ }++ // open animation dialog+ clickAnimationButton = () => {+ this.props.clickAnimationButton();+ }+shouldComponentUpdate(nextProps, nextState) {// console.log(this.props, nextProps, this.state, nextState)+ // if (this.state.inputChange) {+ // this.setState({+ // inputChange: false+ // })+ // return false;+ // }return true;}render() {console.log(this.props.selectedDate, this.props.dateFormatted, this.state.dateFormatted, this.props)-+ console.log(this.state)return (this.state.dateFormatted ?<React.Fragment>- <div id="timeline-header">- <div id="date-selector-main" />- <div id="zoom-buttons-group">- {/* <div id="zoom-btn-container"> */}-- <DateZoomChange timeScaleChangeUnit={this.state.timeScaleChangeUnit} setTimeScale={this.setTimeScale} />-- {/* </div> */}- {/* <DateChangeControls- toggleCustomIntervalModal={this.toggleCustomIntervalModal}- selectedDate={this.state.dateFormatted}- dateChange={this.updateDate} /> */}- {/* <TimelineAxis {...this.state} selectedDate={dateFormatted}/> */}---- {/* custom interval selector */}- <IntervalSelectorWidget- setInterval={this.setInterval}- customIntervalValue={1}- customIntervalZoomLevel={this.props.timeScale}- toggleCustomIntervalModal={this.toggleCustomIntervalModal}- customIntervalModalOpen={this.state.customIntervalModalOpen} />+ <div id="timeline-header">+ <div id="date-selector-main">+ <DateSelector+ {...this.props.inputProps}+ onDateChange={this.updateDate}+ date={new Date(this.state.dateFormatted)}+ />+ </div>+ <div id="zoom-buttons-group">+ <DateZoomChange+ timeScaleChangeUnit={this.state.timeScaleChangeUnit}+ setTimeScale={this.setTimeScale}+ />++ {/* </div> */}+ {/* <DateChangeControls+ toggleCustomIntervalModal={this.toggleCustomIntervalModal}+ selectedDate={this.state.dateFormatted}+ dateChange={this.updateDate} /> */}++ {/* custom interval selector */}+ <IntervalSelectorWidget+ setInterval={this.setInterval}+ customIntervalValue={1}+ customIntervalZoomLevel={this.props.timeScale}+ toggleCustomIntervalModal={this.toggleCustomIntervalModal}+ customIntervalModalOpen={this.state.customIntervalModalOpen}+ />++ <DateChangeArrows+ leftArrowDown={() => this.incrementDate(-1)}+ leftArrowUp={this.props.stopper}+ rightArrowDown={() => this.incrementDate(1)}+ rightArrowUp={this.props.stopper}+ />+ </div>++ <AnimationButton+ clickAnimationButton={this.clickAnimationButton}+ />+ </div>+ <div id="timeline-footer">+ <div id="wv-animation-widet-case"> </div>+ {/* <svg width="1207" height="107" id="timeline-footer-svg" viewBox="0 9 1207 91"> */}+ {/* new modular version - currently a shell */}+ <TimelineAxisContainer+ {...this.state}+ selectedDate={this.state.dateFormatted}+ updateDate={this.updateDate}+ subdaily={this.props.subdaily}+ parentOffset={this.props.parentOffset}+ resetInput={this.resetInput}+ />+ {/* </svg> */}+ </div>{/* hammmmmmmmmmmburger 🍔 */}- {/* <div id="timeline-hide">+ <div id="timeline-hide"><svg className="hamburger" width="10" height="9"><path d="M 0,0 0,1 10,1 10,0 0,0 z M 0,4 0,5 10,5 10,4 0,4 z M 0,8 0,9 10,9 10,8 0,8 z" /></svg>- </div> */}-- <div- className="button-action-group"- id="left-arrow-group"- title="Click and hold to animate backwards"- >- <svg id="timeline-svg" width="24" height="30">- <path- d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z"- className="arrow"- />- </svg>- </div>- <div- className="button-action-group"- id="right-arrow-group"- title="Click and hold to animate forwards"- >- <svg width="24" height="30">- <path- d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z"- className="arrow"- />- </svg>- </div>- </div>- <div- className="button-action-group animate-button"- id="animate-button"- title="Set up animation"- >- <i id="wv-animate" className="fas fa-video wv-animate" />- </div>- </div>- <div id="timeline-footer">- <div id="wv-animation-widet-case"> </div>- {/* <svg width="1207" height="107" id="timeline-footer-svg" viewBox="0 9 1207 91"> */}- {/* new modular version - currently a shell */}- <TimelineAxisContainer {...this.state} selectedDate={this.state.dateFormatted} updateDate={this.updateDate} subdaily={this.props.subdaily} />- {/* </svg> */}- </div>- <div id="timeline-hide">- <svg className="hamburger" width="10" height="9">- <path d="M 0,0 0,1 10,1 10,0 0,0 z M 0,4 0,5 10,5 10,4 0,4 z M 0,8 0,9 10,9 10,8 0,8 z" />- </svg>- </div>+ </div></React.Fragment>:nulldiff --git a/web/js/date/timeline.js b/web/js/date/timeline.jsindex 5c4667356..05f82ba83 100644--- a/web/js/date/timeline.js+++ b/web/js/date/timeline.js@@ -10,9 +10,300 @@ import DateZoomChange from '../components/timeline/timeline-controls/date-zoom-cexport function timeline(models, config, ui) {var self = {};var model = models.date;- var subdaily;+ let subdaily = models.layers.hasSubDaily();self.enabled = false;+ self.startDate = new Date(config.startDate);+ self.parentOffset = (subdaily ? 404 : 310) + 10;++ // ? INPUT REFACTOR+ self.interval = 'day';+ self.delta = 1;+ self.active = false;+ self.delay = 500;+ var animator = null;+ var keyDown;++ let animationInProcess = false;++ var $incrementBtn = $('#right-arrow-group');+ var $decrementBtn = $('#left-arrow-group');++ var initInput = function() {+ models.layers.events.on('subdaily-updated', updateMaxZoom);+ // $incrementBtn+ // .mousedown(function(e) {+ // console.log(self.delta, self.interval)+ // e.preventDefault();+ // switch (ui.timeline.config.currentZoom) {+ // case 1:+ // self.animateByIncrement(self.delta, 'year');+ // break;+ // case 2:+ // self.animateByIncrement(self.delta, 'month');+ // break;+ // case 3:+ // self.animateByIncrement(self.delta, 'day');+ // break;+ // case 4:+ // self.animateByIncrement(self.delta, 'minute');+ // break;+ // default:+ // self.animateByIncrement(self.delta, 'day');+ // }+ // })+ // .mouseup(stopper);++ // $decrementBtn+ // .mousedown(function(e) {+ // e.preventDefault();+ // switch (ui.timeline.config.currentZoom) {+ // case 1:+ // self.animateByIncrement(-self.delta, 'year');+ // break;+ // case 2:+ // self.animateByIncrement(-self.delta, 'month');+ // break;+ // case 3:+ // self.animateByIncrement(-self.delta, 'day');+ // break;+ // case 4:+ // self.animateByIncrement(-self.delta, 'minute');+ // break;+ // default:+ // self.animateByIncrement(-self.delta, 'day');+ // }+ // })+ // .mouseup(stopper);++ $(document)+ // .mouseout(stopper)+ .keydown(function(event) {+ if (event.target.nodeName === 'INPUT' || keyDown === event.keyCode) {+ return;+ }+ switch (event.keyCode) {+ case util.key.LEFT:+ switch (models.date.selectedZoom) {+ case 1:+ self.animateByIncrement(-self.delta, 'year');+ break;+ case 2:+ self.animateByIncrement(-self.delta, 'month');+ break;+ case 3:+ self.animateByIncrement(-self.delta, 'day');+ break;+ case 4:+ self.animateByIncrement(-self.delta, 'minute');+ break;+ }+ break;+ case util.key.RIGHT:+ switch (models.date.selectedZoom) {+ case 1:+ self.animateByIncrement(self.delta, 'year');+ break;+ case 2:+ self.animateByIncrement(self.delta, 'month');+ break;+ case 3:+ self.animateByIncrement(self.delta, 'day');+ break;+ case 4:+ self.animateByIncrement(self.delta, 'minute');+ break;+ }+ event.preventDefault();+ break;+ }+ keyDown = event.keyCode;+ })+ .keyup(function(event) {+ switch (event.keyCode) {+ case util.key.LEFT:+ case util.key.RIGHT:+ stopper();+ event.preventDefault();+ break;+ }+ keyDown = null;+ });++ // self.reactComponent = ReactDOM.render(+ // React.createElement(DateSelector, getProps()),+ // document.getElementById(dateSelectorStr)+ // );+ // model.events.on('select', date => {+ // self.reactComponent.setState({ date: date });+ // });++ if (config.features.compare) {+ let dateModel = models.date;+ dateModel.events.on('state-update', () => {+ self.reactComponent.setState({+ date: dateModel[dateModel.activeDate]+ });+ updateInput();+ });+ }+ updateInput();+ };++ var updateMaxZoom = function() {+ if (model.maxZoom >= 4) {+ document.getElementById('timeline-header').classList.add('subdaily');+ } else {+ if (ui.timeline && ui.timeline.config.currentZoom > 3) {+ document.getElementById('zoom-days').click();+ }+ document.getElementById('timeline-header').classList.remove('subdaily');+ }+ self.reactComponent.setState({ maxZoom: model.maxZoom });+ // model.events.trigger('update-timewheel');+ };++ var updateInput = function(date) {+ var ms = date || new Date(model[model.activeDate]);+ var endDate = models.layers.lastDate();+ var endDateTime = models.layers.lastDateTime();+ let nt = new Date(ms);+ let nd = new Date(ms);+ let pd = new Date(ms);++ nt = new Date(nt.setUTCMinutes(nt.getUTCMinutes() + 10));+ nd = new Date(nd.setUTCDate(nd.getUTCDate() + 1));+ pd = new Date(pd.setUTCDate(pd.getUTCDate() - 1));++ // Disable arrows if nothing before/after selection+ if (model.selectedZoom > 3 && nt >= endDateTime) {+ $incrementBtn.addClass('button-disabled');+ } else if (model.selectedZoom < 4 && nd > endDate) {+ $incrementBtn.addClass('button-disabled');+ } else {+ $incrementBtn.removeClass('button-disabled');+ }+ if (pd.toUTCString() === self.startDate.toUTCString()) {+ $decrementBtn.addClass('button-disabled');+ } else {+ $decrementBtn.removeClass('button-disabled');+ }++ // tl.pick.update();+ };++ /**+ * @param {Number} delta Date and direction to change+ * @param {Number} increment Zoom level of change+ * e.g. months,minutes, years, days+ * @return {Object} JS Date Object+ */+ var getNextTimeSelection = function(delta, increment) {+ var prevDate = model[model.activeDate];++ switch (increment) {+ case 'year':+ return new Date(+ new Date(prevDate).setUTCFullYear(prevDate.getUTCFullYear() + delta)+ );+ case 'month':+ return new Date(+ new Date(prevDate).setUTCMonth(prevDate.getUTCMonth() + delta)+ );+ case 'day':+ return new Date(+ new Date(prevDate).setUTCDate(prevDate.getUTCDate() + delta)+ );+ case 'minute':+ return new Date(+ new Date(prevDate).setUTCMinutes(prevDate.getUTCMinutes() + delta)+ );+ }+ };+ var getInputProps = function() {+ var model = models.date;+ var min = model.minDate();+ var max = model.maxDate();+ var date = model[model.activeDate];+ var maxZoom = model.maxZoom;+ if (model.maxZoom >= 4 || config.parameters.showSubdaily) {+ document.getElementById('timeline-header').classList.add('subdaily');+ maxZoom = 4;+ }++ return {+ width: '120',+ height: '30',+ id: 'main',+ idSuffix: 'animation-widget-main',+ minDate: min,+ maxDate: max,+ maxZoom: maxZoom,+ // onDateChange: onDateSelect,+ date: date,+ fontSize: null+ };+ };++ // var onDateSelect = function(date) {+ // console.log(date)+ // models.date.select(date);+ // };+ /**+ * Add timeout to date change when buttons are being held so that+ * date changes don't happen too quickly+ *+ * @todo Create smart precaching so animation is smooth+ *+ * @param {number} delta Amount of time to change+ * @param {String} increment Zoom level of timeline+ * e.g. months,minutes, years, days+ * @return {void}+ */+ self.animateByIncrement = function(delta, increment) {+ // console.log(delta, increment)+ var endTime = models.layers.lastDateTime();+ var endDate = models.layers.lastDate();+ self.delta = Math.abs(delta);++ function animate() {+ var nextTime = getNextTimeSelection(delta, increment);+ // console.log(tl.data.start(), nextTime, endTime, increment)+ if (subdaily) {+ if (self.startDate <= nextTime && nextTime <= endTime) {+ models.date.add(increment, delta);+ }+ } else {+ if (self.startDate <= nextTime && nextTime <= endDate) {+ models.date.add(increment, delta);+ }+ }+ animationInProcess = true;+ animator = setTimeout(animate, self.delay);+ }+ animate();+ };++ /**+ * Clear animateByIncrement's Timeout+ *+ * @return {void}+ */+ var stopper = function() {+ console.log('stoppppp')+ if (animationInProcess) {+ animationInProcess = false;+ // # invokes when mouse over < > and date selector arrows/boxes+ // # sticks on new timeline date selector+ clearInterval(animator);+ animator = 0;+ }+ };++ // ? INPUT ABOVE+ // ? INPUT ABOVE+ // ? INPUT ABOVE+ // ? INPUT ABOVEself.margin = {top: 0,right: 50,@@ -28,11 +319,13 @@ export function timeline(models, config, ui) {self.getWidth = function() {let subdaily = models.layers.hasSubDaily();+ self.parentOffset = (subdaily ? 404 : 310) + 10;+self.width =$(window).outerWidth(true) -// $('#timeline-header').outerWidth(true) -// $('#timeline-hide').outerWidth(true) -- (subdaily ? 404 : 310) -+ self.parentOffset -20 -self.margin.left -self.margin.right +@@ -147,9 +440,10 @@ export function timeline(models, config, ui) {// self.reactComponent.setState({ selectedDate: date });// };- var incrementDate = (timeScale, increment) => {+ var incrementDate = (increment, timeScale) => {// self.expand(true);- // console.log(timeScale, increment)+ console.log(increment, timeScale)+ self.animateByIncrement(increment, timeScale);// models.date.add(timeScale, increment);// self.input.animateByIncrement(increment, timeScale);// models.date.select(date);@@ -160,27 +454,34 @@ export function timeline(models, config, ui) {// console.log(models)// self.input.update(updatedDate);// models.date.setActiveDate(updatedDate);-// console.log('updateDate', date, updatedDate)+ // console.log('updateDate', date, updatedDate)//# ALLOWS UPDATE OF MODELS DATE WHICH LAYERS IS CONNECTED TOmodels.date.select(updatedDate);};var setIntervalInput = (intervalValue, zoomLevel) => {- console.log(self.input.delta)- self.input.delta = intervalValue;- self.input.interval = zoomLevel;+ // console.log(self.input.delta)+ self.delta = intervalValue;+ self.interval = zoomLevel;let zoomCustomText = document.querySelector('#zoom-custom');zoomCustomText.textContent = `${intervalValue} ${zoomLevel.toUpperCase().substr(0, 3)}`;// console.log(self)- }+ };++ var clickAnimationButton = () => {+ console.log(ui);+ };var getInitialProps = () => {// console.log(self)let selectedDate = models.date[models.date.activeDate];let subdaily = models.layers.hasSubDaily();++ let inputProps = getInputProps();return {width: self.width,+ parentOffset: self.parentOffset,subdailyLayers: subdaily,height: self.height,selectedDate: selectedDate,@@ -189,7 +490,10 @@ export function timeline(models, config, ui) {incrementDate: incrementDate,updateDate: updateDate,setIntervalInput: setIntervalInput,- dateFormatted: new Date(selectedDate).toISOString()+ dateFormatted: new Date(selectedDate).toISOString(),+ inputProps: inputProps,+ stopper: stopper,+ clickAnimationButton: clickAnimationButton};};@@ -285,8 +589,11 @@ export function timeline(models, config, ui) {};var updateTimeUi = function() {+ console.log('%c updateTimeUi ', 'background: #555; color: cornflowerblue');+updateReactTimelineDate();- self.input.update();+ // updateInput();+ // self.input.update();// self.pick.shiftView();};var onLayerUpdate = function() {@@ -311,6 +618,8 @@ export function timeline(models, config, ui) {// e.stopPropagation();// });+ initInput();+$('#zoom-custom').on('click', function() {self.reactComponent.setState({customIntervalModalOpen: true@@ -360,7 +669,7 @@ export function timeline(models, config, ui) {$(window).resize(function() {self.resize();- self.zoom.refresh();+ // self.zoom.refresh();self.setClip();});model.events.on('select', updateTimeUi);