Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

pull in timeline dom els including main timeline svg and dismantle previous data, zoom, and pan imports functions

Edward Plato9d7916c475eb
diff --git a/web/css/timeline.css b/web/css/timeline.css
index b5f4f36d9..1f7ce6974 100644
--- a/web/css/timeline.css
+++ b/web/css/timeline.css
@@ -395,7 +395,7 @@ g.plot rect.data-bar-invisible {
}
#timeline-footer svg {
- overflow: visible;
+ /* overflow: visible; */
}
#wv-rangeselector-case > .wv-timeline-range-selector {
@@ -444,7 +444,7 @@ g.plot rect.data-bar-invisible {
}
#zoom-btn-container .wv-tooltip {
- display: none;
+ /* display: none; */
position: absolute;
bottom: 100%;
border-bottom: 8px solid transparent;
diff --git a/web/js/animation/range-select.js b/web/js/animation/range-select.js
index 628daafb2..bd805c9c3 100644
--- a/web/js/animation/range-select.js
+++ b/web/js/animation/range-select.js
@@ -74,10 +74,13 @@ export function animationRangeSelect(models, config, ui) {
var options;
var startLocation;
var endLocation;
- var pick = d3.select('#guitarpick');
- var pickWidth = pick.node().getBoundingClientRect().width;
- var animEndLocation =
- d3.transform(pick.attr('transform')).translate[0] - pickWidth / 2; // getting guitar pick location
+ // TODO: Pull in new dragger pick
+ // var pick = d3.select('#guitarpick');
+ // var pickWidth = pick.node().getBoundingClientRect().width;
+ var pickWidth = 50;
+ // var animEndLocation =
+ // 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
diff --git a/web/js/app.js b/web/js/app.js
index 02c8acc69..287d62f37 100644
--- a/web/js/app.js
+++ b/web/js/app.js
@@ -16,11 +16,11 @@ import dateWheels from './date/wheels';
// Timeline
import { timeline } from './date/timeline';
import { timelineData } from './date/timeline-data'; // remove
-import { timelineConfig } from './date/config'; // replaced
-import { timelineZoom } from './date/timeline-zoom'; // replaced
-import { timelineTicks } from './date/timeline-ticks'; // replaced
-import { timelinePick } from './date/timeline-pick'; // replaced
-import { timelinePan } from './date/timeline-pan'; // replaced
+// import { timelineConfig } from './date/config'; // replaced
+// import { timelineZoom } from './date/timeline-zoom'; // replaced
+// import { timelineTicks } from './date/timeline-ticks'; // replaced
+// import { timelinePick } from './date/timeline-pick'; // replaced
+// import { timelinePan } from './date/timeline-pan'; // replaced
import { timelineInput } from './date/timeline-input';
import { timelineCompare } from './date/compare-picks';
@@ -192,12 +192,18 @@ class App extends React.Component {
id="timeline"
className="timeline-inner clearfix"
style={{ display: 'none' }}
+ ></section>
+
+ {/* <section
+ id="timeline"
+ className="timeline-inner clearfix"
+ style={{ display: 'none' }}
>
<div id="timeline-header">
<div id="date-selector-main" />
<div id="zoom-buttons-group">
- <div id="zoom-btn-container">
- <span
+ <div id="zoom-btn-container"> */}
+ {/* <span
id="current-zoom"
className="zoom-btn zoom-btn-active"
data-zoom="3"
@@ -243,8 +249,8 @@ class App extends React.Component {
Custom
</span>
</div>
- </div>
- </div>
+ </div> */}
+ {/* </div>
<div
className="button-action-group"
id="left-arrow-group"
@@ -286,7 +292,7 @@ class App extends React.Component {
<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>
- </section>
+ </section> */}
<OlCoordinates mouseEvents={this.mapMouseEvents} />
</div>
);
@@ -473,19 +479,19 @@ class App extends React.Component {
function timelineInit() {
ui.timeline = timeline(models, config, ui);
ui.timeline.data = timelineData(models, config, ui);
- ui.timeline.zoom = timelineZoom(models, config, ui);
- ui.timeline.ticks = timelineTicks(models, config, ui);
- ui.timeline.pick = timelinePick(models, config, ui);
- ui.timeline.pan = timelinePan(models, config, ui);
+ // ui.timeline.zoom = timelineZoom(models, config, ui);
+ // 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.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);
- }
+ // 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.compare) {
ui.timeline.compare = timelineCompare(models, config, ui);
}
diff --git a/web/js/components/timeline/custom-interval-selector.js b/web/js/components/timeline/custom-interval-selector.js
deleted file mode 100644
index 86600cba7..000000000
--- a/web/js/components/timeline/custom-interval-selector.js
+++ /dev/null
@@ -1,238 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-// import Slider, { Handle } from 'rc-slider';
-// import TimeSelector from '../date-selector/date-selector';
-// import LoopButton from './loop-button';
-// import PlayButton from './play-button';
-// import AnimWidgetHeader from './header';
-// import googleTagManager from 'googleTagManager';
-
-// const RangeHandle = props => {
-// const { value, offset, dragging, ...restProps } = props;
-
-// const positionStyle = {
-// position: 'absolute',
-// left: `${(offset - 5).toFixed(2)}%`
-// };
-
-// return (
-// <React.Fragment>
-// <span className="anim-frame-rate-label" style={positionStyle}>
-// {value < 10 ? value.toFixed(1) : value}
-// </span>
-// <Handle
-// dragging={dragging.toString()}
-// value={value}
-// offset={offset}
-// {...restProps}
-// />
-// </React.Fragment>
-// );
-// };
-/*
- * A react component, Builds a rather specific
- * interactive widget
- *
- * @class AnimationWidget
- * @extends React.Component
- */
-class CustomIntervalSelectorWidget extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- // value: props.sliderSpeed,
- // looping: props.looping,
- // startDate: props.startDate,
- // endDate: props.endDate,
- // maxZoom: props.maxZoom,
- // header: props.header,
- // incrementArray: props.incrementArray,
- // increment: props.increment
- };
- }
-
- /*
- * Sets a new state value when a
- * when the slider is adjusted
- *
- * @method onSlide
- *
- * @param {number} value - Value of the slider
- * selection
- *
- * @return {void}
- */
- // onSlide(value) {
- // this.props.onSlide(value);
- // this.setState({
- // value: value
- // });
- // }
-
- /*
- * calls the callback, passing the
- * current state elements as parameters
- *
- * @method play
- *
- * @return {void}
- */
- // play() {
- // this.props.onPushPlay();
- // this.setState({
- // playing: true
- // });
- // }
- // pause() {
- // this.props.onPushPause();
- // this.setState({
- // playing: false
- // });
- // }
- /*
- * Sets a new state to say whether or not
- * the animation should loop
- *
- * @method onLoop
- *
- * @param {Object} component - slider react
- * component
- * @param {number} value - Value of the slider
- * selection
- *
- * @return {void}
- */
- // onLoop() {
- // var loop = true;
- // if (this.state.looping) {
- // loop = false;
- // }
- // this.setState({
- // looping: loop
- // });
- // this.props.onPushLoop(loop);
- // }
- // onDateChange(date, id) {
- // const { endDate, startDate } = this.state;
- // // googleTagManager.pushEvent({
- // // event: 'GIF_animation_date_case'
- // // });
- // if (id === 'start') {
- // this.setState({
- // startDate: date
- // });
- // this.props.onDateChange(date, endDate);
- // } else {
- // this.setState({
- // endDate: date
- // });
- // this.props.onDateChange(startDate, date);
- // }
- // }
- render() {
- return (
- <div
- id="wv-animation-widget-custom-interval"
- // className={
- // 'wv-animation-widget' + (this.state.maxZoom >= 4 ? ' subdaily' : '')
- // }
- className='wv-animation-widget'
- style={{display: }}
- >
- {/* <AnimWidgetHeader
- text={this.state.increment}
- toolTipTextArray={this.state.incrementArray}
- onClick={this.props.onZoomSelect}
- />
-
- <PlayButton
- playing={this.state.playing}
- play={this.play.bind(this)}
- pause={this.pause.bind(this)}
- />
- <LoopButton
- looping={this.state.looping}
- onLoop={this.onLoop.bind(this)}
- /> */}
- {/* <div className="wv-slider-case">
- <Slider
- className="input-range"
- step={0.5}
- max={10}
- min={0.5}
- value={this.state.value}
- onChange={this.onSlide.bind(this)}
- handle={RangeHandle}
- />
- <span className="wv-slider-label">{this.props.sliderLabel}</span>
- </div> */}
-
- {/* <a
- href="javascript:void(null)"
- title="Create Animated GIF"
- className="wv-icon-case"
- onClick={this.props.onPushGIF}
- >
- <i
- id="wv-animation-widget-file-video-icon"
- className="fas fa-file-video wv-animation-widget-icon"
- />
- </a> */}
- {/* <div className="wv-anim-dates-case">
- <TimeSelector
- width="120"
- height="30"
- date={this.state.startDate}
- id="start"
- idSuffix="animation-widget-start"
- onDateChange={this.onDateChange.bind(this)}
- maxDate={this.state.endDate}
- minDate={this.props.minDate}
- maxZoom={this.state.maxZoom}
- />
- <div className="thru-label">To</div>
- <TimeSelector
- width="120"
- height="30"
- date={this.state.endDate}
- id="end"
- idSuffix="animation-widget-end"
- onDateChange={this.onDateChange.bind(this)}
- maxDate={this.props.maxDate}
- minDate={this.state.startDate}
- maxZoom={this.state.maxZoom}
- />
- </div> */}
- {/* <i className="fa fa-times wv-close" onClick={this.props.onClose} /> */}
- <i className="fa fa-times wv-close"/>
- </div>
- );
- }
-}
-// RangeHandle.propTypes = {
-// value: PropTypes.number,
-// offset: PropTypes.number
-// };
-// AnimationWidget.propTypes = {
-// sliderSpeed: PropTypes.number,
-// looping: PropTypes.bool,
-// startDate: PropTypes.object,
-// endDate: PropTypes.object,
-// header: PropTypes.element,
-// incrementArray: PropTypes.array,
-// increment: PropTypes.string,
-// onSlide: PropTypes.func,
-// onPushPlay: PropTypes.func,
-// onPushPause: PropTypes.func,
-// onPushLoop: PropTypes.func,
-// onDateChange: PropTypes.func,
-// onZoomSelect: PropTypes.func,
-// sliderLabel: PropTypes.string,
-// onPushGIF: PropTypes.func,
-// minDate: PropTypes.object,
-// maxDate: PropTypes.object,
-// maxZoom: PropTypes.number,
-// onClose: PropTypes.func
-// };
-
-export default CustomIntervalSelectorWidget;
diff --git a/web/js/components/timeline/dateCalc.js b/web/js/components/timeline/dateCalc.js
deleted file mode 100644
index 6652b54e1..000000000
--- a/web/js/components/timeline/dateCalc.js
+++ /dev/null
@@ -1,82 +0,0 @@
-
-import moment from 'moment';
-
-// const pastDateLimit = '1940-01-01T00:00:00.000';
-// const futureDateLimit = '2020-01-01T00:00:00.000';
-const pastDateLimit = moment.utc('1940-01-01T00:00:00.000');
-const futureDateLimit = moment.utc('2020-01-01T00:00:00.000');
-
-const timeScaleOptions = {
- 'minute': {
- timeAxis: {
- scale: 'minute',
- format: 'HH:mm'
- }
- },
- 'hour': {
- timeAxis: {
- scale: 'hour',
- // format: 'DD-HH-mm:ss',
- format: 'MMM D'
- }
- },
- 'day': {
- timeAxis: {
- scale: 'day',
- // format: 'MM-DD-HH-mm:ss-YYYY',
- format: 'MMM YYYY'
- }
- },
- 'month': {
- timeAxis: {
- scale: 'month',
- format: 'YYYY'
- }
- },
- 'year': {
- timeAxis: {
- scale: 'year',
- format: 'YYYY'
- }
- }
-};
-
-export default (function (self) {
- self.getTimeRange = (startDate, endDate, timeScale) => {
- // const startTime = performance.now();
- let dates = [];
- let { format } = timeScaleOptions[timeScale].timeAxis;
-
- while(startDate <= endDate) {
-
- let date = startDate.format(format);
- let rawDate = startDate.format();
- let nextDate = startDate.clone().add(1, timeScale);
- let rawNextDate = nextDate.format();
-
- //# EXPENSIVE IN BETWEEN FOR LARGE NUMBERS - removing cuts function time down some, but may be neglible - main focus is smaller total request size
- let withinRange = startDate.isBetween(pastDateLimit, futureDateLimit, null, '[]');
-
- let timeObject = {
- dateObject: startDate.toObject(),
- date: date.toUpperCase(),
- dayOfWeek: startDate.day(),
- rawDate: rawDate,
- rawNextDate: rawNextDate,
- timeScale: timeScale,
- withinRange: withinRange
- }
- dates.push(timeObject);
- startDate = nextDate;
- }
- let timeRange = {
- dates: dates
- };
- // const duration = performance.now() - startTime;
- // console.log(`87 someMethodIThinkMightBeSlow took ${duration}ms`);
-
- return timeRange;
- };
-
- return self;
-})({});
diff --git a/web/js/components/timeline/grid-range.js b/web/js/components/timeline/grid-range.js
deleted file mode 100644
index b6607efbe..000000000
--- a/web/js/components/timeline/grid-range.js
+++ /dev/null
@@ -1,284 +0,0 @@
-import React, { PureComponent } from 'react';
-import moment from 'moment';
-
-//# PureComponent performs a shallow comparison of props and state - may not need shouldComponentUpdate
-class GridRange extends PureComponent {
-// constructor(props) {
-// super(props);
-// this.state= {
-// hoverLinePosition: 0
-// }
-// }
-
- showHover = (e, itemDate, nextDate, index) => {
- e.preventDefault();
- e.stopPropagation();
- e.persist();
- // let target = e.target;
- // let clientX = e.clientX;
- // let boundingClientRect = target.getBoundingClientRect();
- // //! IE11 doesn't like boundingClientRect.x
- // let xHoverPositionInCurrentGrid = Math.floor(clientX) - Math.floor(boundingClientRect.left);
- requestAnimationFrame(() => {
- let target = e.target;
- let clientX = e.clientX;
- let boundingClientRect = target.getBoundingClientRect();
- //! IE11 doesn't like boundingClientRect.x
- let xHoverPositionInCurrentGrid = Math.floor(clientX) - Math.floor(boundingClientRect.left);
-
- let gridWidth = this.props.gridWidth;
- // let boundingClientRect = e.target.getBoundingClientRect();
- // //! IE11 doesn't like boundingClientRect.x
- // let xHoverPositionInCurrentGrid = Math.floor(e.clientX) - Math.floor(boundingClientRect.left);
-
- let currentDateValue = moment.utc(itemDate).valueOf();
- let nextDateValue = moment.utc(nextDate).valueOf();
- let diff = nextDateValue - currentDateValue;
- let diffFactor = diff / gridWidth; // gridWidth
- let displayDate = moment.utc(currentDateValue + (xHoverPositionInCurrentGrid * diffFactor)).format();
- this.props.displayDate(displayDate, clientX);
- // this.setState({
- // hoverLinePosition: index * gridWidth + xHoverPositionInCurrentGrid
- // })
- })
- }
-
- componentDidUpdate(prevProps, prevState) {
- //# Dragger changes are tied too close to this.props.transformX since add/minus click dragger and this updates
- //# decouple
- // console.log('GridRange update', prevProps, prevState)
- }
-
- render() {
- let gridWidth = this.props.gridWidth;
- return (
- <g className="gridShell" transform={`translate(${this.props.transformX}, 0)`}>
- <TileHolder dateArray={this.props.dateArray} gridWidth={gridWidth} showHover={this.showHover} timeScale={this.props.timeScale} />
- {/* <line className="svgLine" stroke="blue" strokeWidth="2" strokeOpacity="0.48" x1="0" x2="0" y1="0" y2="90" transform={`translate(${this.state.hoverLinePosition + 2}, 0)`} shapeRendering="optimizeSpeed"/> */}
- </g>
- )
- }
-}
-
-const tileTextConditionOptions = {
- minute: (itemDateObject) => {
- let timeScaleUnit = itemDateObject.minutes;
- return timeScaleUnit === 0 ||
- timeScaleUnit === 15 ||
- timeScaleUnit === 30 ||
- timeScaleUnit === 45;
- },
- hour: (itemDateObject) => {
- let timeScaleUnit = itemDateObject.hours;
- return timeScaleUnit === 0 ||
- timeScaleUnit === 6 ||
- timeScaleUnit === 12 ||
- timeScaleUnit === 18;
- },
- day: (itemDateObject) => {
- let timeScaleUnit = itemDateObject.date;
- return timeScaleUnit === 1;
- },
- month: (itemDateObject) => {
- let timeScaleUnit = itemDateObject.months;
- return timeScaleUnit === 0;
- },
- year: (itemDateObject) => {
- let timeScaleUnit = itemDateObject.years;
- return timeScaleUnit % 10 === 0;
- }
-}
-
-class TileHolder extends PureComponent {
- render() {
- let timeScale = this.props.timeScale;
- let tileTextCondition = tileTextConditionOptions[timeScale];
- let midTile = Math.floor(this.props.dateArray.length / 2);
- return (
- <React.Fragment>
- {this.props.dateArray.map((item, index) => {
- return (
- item.withinRange ?
- <React.Fragment key={index}>
- <TileRect
- item={item}
- index={index}
- gridWidth={this.props.gridWidth}
- showHover={this.props.showHover}
- midTile={midTile === index ? true : false}
- />
- {tileTextCondition(item.dateObject) ?
- <TileText
- item={item}
- index={index}
- gridWidth={this.props.gridWidth}
- />
- : null }
- </React.Fragment>
- : null
- )
- }
- )}
- </React.Fragment>
- )
- }
-}
-
-const axisScaleGridElement = {
- minute: (gridWidth, index, item) => {
- let timeScaleUnit = item.dateObject.minutes;
- let lineLengthY = timeScaleUnit === 0 ||
- timeScaleUnit === 15 ||
- timeScaleUnit === 30 ||
- timeScaleUnit === 45 ? 58 : timeScaleUnit % 5 === 0 ? 20 : 10;
- 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="white" strokeLinecap="round" strokeWidth="2" 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 ? 58 :
- timeScaleUnit === 6 ||
- timeScaleUnit === 12 ||
- timeScaleUnit === 18 ? 22 : 10;
- // let lineLengthY = timeScaleUnit === 0 ? 58 : timeScaleUnit === 12 ? 22 : 10;
- 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="white" strokeLinecap="round" strokeWidth="2" x1="0" x2="0" y1="0" y2={lineLengthY} transform={`translate(${index * gridWidth + 1}, 0)`} />
- </React.Fragment>
- )
- },
- day: (gridWidth, index, item, midTile) => {
- let dayOfWeek = item.dayOfWeek;
- let lineLengthY = item.dateObject.date === 1 ? 58 : dayOfWeek === 0 ? 22 : 10;
- 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> */}
- <rect className="grid" width={gridWidth} height={100} transform={`translate(${index * gridWidth}, 0)`} fill={midTile ? 'yellow' : 'rgba(0,0,0,0)'} 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="white" strokeLinecap="round" strokeWidth="2" 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 ? 58 : timeScaleUnit % 3 === 0 ? 22 : 10;
- 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="white" strokeLinecap="round" strokeWidth="2" 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 ? 58 : timeScaleUnit % 5 === 0 ? 22 : 10;
- 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="white" strokeLinecap="round" strokeWidth="2" x1="0" x2="0" y1="0" y2={lineLengthY} transform={`translate(${index * gridWidth + 1}, 0)`} />
- </React.Fragment>
- )
- },
-}
-
-const axisScaleTextElement = {
- minute: (gridWidth, index, item) => {
- return (
- <React.Fragment>
- <g>
- <text className="gridText" x="0" y="45" fill={item.withinRange ? 'white' : ''} transform={`translate(${(index * gridWidth) + 8}, 20)`} textRendering="optimizeLegibility" clipPath="url(#textDisplay)">{item.date}</text>
- </g>
- </React.Fragment>
- )
- },
- hour: (gridWidth, index, item) => {
- let timeScaleUnit = item.dateObject.hours;
- let dateText = timeScaleUnit === 12 || timeScaleUnit === 6 || timeScaleUnit === 18 ? `${timeScaleUnit}:00` : item.date;
- return (
- <React.Fragment>
- <g>
- <text className="gridText" x="0" y="45" fill={item.withinRange ? 'white' : ''} transform={`translate(${(index * gridWidth) + 8}, 20)`} textRendering="optimizeLegibility" clipPath="url(#textDisplay)">{dateText}</text>
- </g>
- </React.Fragment>
- )
- },
- day: (gridWidth, index, item) => {
- // let timeScaleUnit = item.dateObject.date;
- return (
- <React.Fragment>
- <g>
- <text className="gridText" x="0" y="45" fill={item.withinRange ? 'white' : ''} transform={`translate(${(index * gridWidth) + 8}, 20)`} textRendering="optimizeLegibility" clipPath="url(#textDisplay)">{item.date}</text>
- </g>
- </React.Fragment>
- )
- },
- month: (gridWidth, index, item) => {
- // let timeScaleUnit = item.dateObject.months;
- return (
- <React.Fragment>
- <g>
- <text className="gridText" x="0" y="45" fill={item.withinRange ? 'white' : ''} transform={`translate(${(index * gridWidth) + 5}, 20)`} textRendering="optimizeLegibility" clipPath="url(#textDisplay)">{item.date}</text>
- </g>
- </React.Fragment>
- )
- },
- year: (gridWidth, index, item) => {
- // let timeScaleUnit = item.dateObject.years;
- return (
- <React.Fragment>
- <g>
- <text className="gridText" x="0" y="45" fill={item.withinRange ? 'white' : ''} transform={`translate(${(index * gridWidth) + 5}, 20)`} textRendering="optimizeLegibility" clipPath="url(#textDisplay)">{item.date}</text>
- </g>
- </React.Fragment>
- )
- },
-}
-
-class TileRect extends PureComponent {
- // componentDidUpdate() {
- // console.log('TileRect update')
- // }
- render() {
- let { item, gridWidth, index, midTile, showHover } = this.props;
- // console.log(item.dateObject)
- return (
- <React.Fragment>
- <g onMouseMove={(e) => showHover(e, item.rawDate, item.rawNextDate, index)}>
- { axisScaleGridElement[item.timeScale](gridWidth, index, item, midTile) }
- </g>
- </React.Fragment>
- )
- }
-}
-
-class TileText extends PureComponent {
- //# TODO: all of these (if visible or not) are being updated - should optimize so only visible are shown
- // componentDidUpdate() {
- // console.log('TileText update')
- // }
- render() {
- let { item, gridWidth, index } = this.props;
- // console.log(item)
- return (
- axisScaleTextElement[item.timeScale](gridWidth, index, item)
- )
- }
-}
-
-// FUNCTIONAL COMPONENT VERSION OF ABOVE - less code in compile
-// const TileText = ({ item, gridWidth, index }) => {
-// return (
-// axisScaleTextElement[item.timeScale](gridWidth, index, item)
-// )
-// }
-
-export default GridRange;
\ No newline at end of file
diff --git a/web/js/components/timeline/timeline-axis.js b/web/js/components/timeline/timeline-axis.js
deleted file mode 100644
index 02f98dde7..000000000
--- a/web/js/components/timeline/timeline-axis.js
+++ /dev/null
@@ -1,1177 +0,0 @@
-import React, { Component, PureComponent } from 'react';
-import Draggable from "react-draggable";
-import Deque from 'double-ended-queue';
-import moment from 'moment';
-
-import './timeline-axis.css';
-import dateCalc from './dateCalc';
-import GridRange from './grid-range';
-
-//? PROPS NEEDED TO PASS DOWN FOR PANELS: #####################################################################################################
-//? positon
-//? panel width - gives transforms, gives pre/post changes
-//? selected date/offset (redLineOffset)
-
-//? https://developers.google.com/web/updates/2016/07/infinite-scroller
-//? terms used: runway (total area), viewport (viewable), sentinel (checking for necessary change)
-
-//! CONCERNS: #################################################################################################################################
-//! hover over & show time - how to handle too fast/too slow date updates - debounce? real time is an ugly blur, too slow would defeat the purpose ?
-//! what kind of realistic time scaling should i expect, is hovering over the first pixel of a year and getting Jan 5th 5:30am all right?
-//!
-
-const timeScales = [ 'minute', 'hour', 'day', 'month', 'year' ];
-
-//? can set gridWidth, actual daeArrays (assume length will vary? - minute level will be more individual DOM els than day for example)
-const timeScaleOptions = {
- 'minute': {
- timeAxis: {
- scale: 'minute',
- gridWidth: 12,
- scaleMs: 60000
- }
- },
- 'hour': {
- timeAxis: {
- scale: 'hour',
- gridWidth: 20,
- scaleMs: 3600000
- }
- },
- 'day': {
- timeAxis: {
- scale: 'day',
- gridWidth: 12,
- scaleMs: 86400000
- }
- },
- 'month': {
- timeAxis: {
- scale: 'month',
- gridWidth: 12,
- scaleMs: null //# null set to require a
- // scaleMs: 2678400000
- }
- },
- 'year': {
- timeAxis: {
- scale: 'year',
- gridWidth: 12,
- scaleMs: null
- // scaleMs: 31536000000
- }
- }
-};
-
-class TimelineAxis extends Component {
- constructor(props) {
- super(props);
- this.state = {
- // midTileDate: '',
- compareMode: true,
- dragSentinelCount: 0,
- draggerPosition: 0,
- draggerVisible: true,
- draggerSelected: true,
- draggerPositionB: 0,
- draggerVisibleB: true,
- draggerSelectedB: false,
- moved: false,
- timeScaleChange: false,
- deque: null,
- timeScaleSelectValue: 'day',
- increment: 1,
- axisWidth: 800,
- hoverTime: null,
- showHoverLine: false,
- draggerTimeState: null,
- leftOffset: 0,
- redLineOffset: -254,
- redLineClick: -254,
- selectedDate: this.props.selectedDate, // center of viewport unless restricted by being start/end of available time
- timeScale: 'day',
- endDate: null,
- startDate: null,
- position: -2500,
- currentDateRange: null,
- currentTransformX: 0,
- gridWidth: 100,
- pastDateLimit: '1940-01-01T00:00:00.000',
- futureDateLimit: '2020-01-01T00:00:00.000',
- }
- // this.timelineRef = React.createRef(); //# REF
-
- // this.showHoverOn = this.showHoverOn.bind(this);
- // this.showHoverOff = this.showHoverOff.bind(this);
- }
- //? how do position and transforms change between scale changes? lock into one line would be ideal
- updateScale = (timeScale, axisWidthInput) => {
- let options = timeScaleOptions[timeScale].timeAxis;
- let gridWidth = options.gridWidth;
- let axisWidth = axisWidthInput ? axisWidthInput : this.state.axisWidth;
- let leftOffset = this.state.leftOffset;
-
- if (leftOffset === 0) {
- leftOffset = axisWidth / 2;
- }
-
- let numberOfVisibleTiles = Number((axisWidth / gridWidth).toFixed(8));
- // console.log(numberOfVisibleTiles)
- // let tilesTillSelectedDAte = Math.floor(numberOfVisibleTiles / 2);
- // let draggerPosition = tilesTillSelectedDAte * gridWidth - 48;
- // let dragSentinelChangeNumber = numberOfVisibleTiles * gridWidth;
- // let midPoint = -((gridWidth * 120) / 2) + ((numberOfVisibleTiles / 2) * gridWidth);
- // let numOfTiles = 120;
-
- let gridNumber = Math.floor(numberOfVisibleTiles * 1.5); // should get from state?
- // console.log(gridNumber, numberOfVisibleTiles, numberOfVisibleTiles * 1.5)
- let dragSentinelChangeNumber = gridWidth * (Math.floor(numberOfVisibleTiles * 0.25) + 1);
- // if (timeScale === 'year') {
- // gridNumber = 2020 - 1940;
- // }
-
- // Floating point issues need to be handled more cleanly
- //# currently off 1 PIXEL - 1 pixel added on the end of this equation currently
- // let midPoint = -((gridWidth * gridNumber) / 2) + ((numberOfVisibleTiles / 2) * gridWidth); //# CAN'T FLOOR numberOfVisibleTiles / 2
-
- //# taken from older, working commit - current version being used, but may need to still handle floating point issues
- let midPoint = -((gridWidth * gridNumber) / 2) + ((numberOfVisibleTiles / 2) * gridWidth);
- // midPoint = midPointWorkingCommit
-
- //# this causing offset issue, but "fixes" floating point
- // let midPoint = +(-(+((gridWidth * +(numberOfVisibleTiles * 1.5).toFixed(10)) / 2).toFixed(10)) + +(+(numberOfVisibleTiles / 2).toFixed(10) * gridWidth).toFixed(10)).toFixed(10); //# CAN'T FLOOR numberOfVisibleTiles / 2
- //# -0.5(12 * 1.5numberOfVisibleTiles) + 0.5numberOfVisibleTiles * 12
-
- // let mockPropsSelectedDate = '1941-01-01';
- // console.log(hoverTime, draggerDateActual, hoverTime)
- let hoverTime = moment.utc(this.state.hoverTime);
- console.log(hoverTime.format())
- let hoverTimeZero;
- let hoverTimeNextZero;
-
- let draggerDateActual = moment.utc(this.state.draggerTimeState);
- let draggerDateActualB = moment.utc(this.state.draggerTimeStateB);
-
- if (timeScale === 'minute') {
- hoverTimeZero = hoverTime.clone().startOf('minute');
- hoverTimeNextZero = hoverTimeZero.clone().add(1, timeScale);
- }
- if (timeScale === 'hour') {
- hoverTimeZero = hoverTime.clone().startOf('hour');
- hoverTimeNextZero = hoverTimeZero.clone().add(1, timeScale);
- }
- if (timeScale === 'day') {
- hoverTimeZero = hoverTime.clone().startOf('day');
- hoverTimeNextZero = hoverTimeZero.clone().add(1, timeScale);
- }
- if (timeScale === 'month') {
- hoverTimeZero = hoverTime.clone().startOf('month');
- hoverTimeNextZero = hoverTimeZero.clone().add(1, timeScale);
- }
- if (timeScale === 'year') {
- hoverTimeZero = moment.utc(this.state.pastDateLimit);
- hoverTimeNextZero = hoverTimeZero.clone().add(1, timeScale);
- }
-
- // console.log(hoverTime.format(), hoverTimeZero.format(), hoverTimeNextZero.format())
-
- // value of hover time, hover time timeunit zeroed, hover time next unit timeunit zeroed
- let hoverTimeValue = hoverTime.valueOf();
- let hoverTimeZeroValue = hoverTimeZero.valueOf();
- let hoverTimeNextZeroValue = hoverTimeNextZero.valueOf();
-
- let diffZeroValues = hoverTimeNextZeroValue - hoverTimeZeroValue;
- let diffFactor = diffZeroValues / gridWidth;
- let diffStartAndZeroed = hoverTimeValue - hoverTimeZeroValue;
-
- let pixelsToAdd = diffStartAndZeroed / diffFactor;
- // console.log(pixelsToAdd)
-
- // console.log(hoverTime, hoverTime.format(), pixelsToAdd);
- // console.log(Math.floor(leftOffset / gridWidth));
-
- //! offset grids needed since each zoom in won't be centered
- //! maybe non equal past/future dates - this.getDateArray(80, 40, timeScale, hoverTime);
- //! additional offset needed for midPoint and/or position
- let offSetGrids = Math.floor(leftOffset / gridWidth);
-
- // console.log(Math.floor(gridNumber/2), offSetGrids, gridNumber/2)
- //# MOST EXPENSIVE FUNCTION!!!! Greater the gridNumber === longer. 960 els ~23ms vs 100 at 3.5ms)
- let current = this.getDateArray(Math.floor(gridNumber/2), Math.floor(gridNumber/2), timeScale, hoverTime);
- // console.log(current)
- let deque = new Deque(current.dates);
-
- //# NEED FUNCTION TO CHECK IF DRAGGER IS WITHIN RANGE
- //# get front and back dates
- let frontDate = moment.utc(deque.peekFront().rawDate);
- let backDate = moment.utc(deque.peekBack().rawDate);
- // console.log(frontDate.format())
- // check if dragger date is between front/back dates, null set to ignore granularity (go to ms), [] for inclusive of front/back dates
- let isBetween = draggerDateActual.isBetween(frontDate, backDate, null, '[]');
- // let pixelsToAddToDragger = 0;
- let draggerPosition = 0;
- let draggerVisible = false;
- if (isBetween) {
- // let frontDateValue = moment.utc(frontDate.rawDate).valueOf(); // ZERO
- // let draggerPositionFromFront = draggerDateActualValue - frontDateValue;
-
- // pixelsToAddToDragger = Math.abs(frontDate.diff(draggerDateActual, timeScale, true) * gridWidth);
- draggerPosition = Math.abs(frontDate.diff(draggerDateActual, timeScale, true) * gridWidth);
- draggerVisible = true;
- //? WHY IS THIS OFFSET REQUIRED? seems consistent throughout browser size changes too
- if(timeScale === 'month') {
- // pixelsToAddToDragger += 54;
- }
- }
-
- let draggerPositionB = 0;
- let draggerVisibleB = false;
- // let pixelsToAddToDraggerB = 0;
- if (this.state.compareMode) {
- let isBetweenB = draggerDateActualB.isBetween(frontDate, backDate, null, '[]');
- if (isBetweenB) {
- draggerPositionB = Math.abs(frontDate.diff(draggerDateActualB, timeScale, true) * gridWidth);
- draggerVisibleB = true;
- }
- }
-
- let position;
- //# axisWidthInput conditional in place to handle resize centering of position
- if (axisWidthInput) {
- position = midPoint;
- } else {
- position = +(midPoint - (axisWidth / 2 - leftOffset)).toFixed(10);
- if (gridNumber % 2 !== 0) {
- position += gridWidth/2;
- }
- let position2 = midPoint - (axisWidth / 2 - leftOffset);
- // console.log(position, position2)
- // console.log(midPoint, position, (axisWidth / 2 - leftOffset), axisWidth / 2, leftOffset)
- }
- // console.log(pixelsToAddToDragger, midPoint, (axisWidth / 2 - leftOffset), pixelsToAdd, position)
-
- if (timeScale === 'year') {
- // let axOff = axisWidth / 2 - leftOffset;
- position = 0 + axisWidth / 2 + (leftOffset - axisWidth / 2);
- }
- let currentTransformX = 0;
- //? this.addLine(...) added as a callback in this.setState due to relying on changed timescale/grid state
- //? can change later if passing more arguments is more performant or required due to asynchronous behavior of setState
- // console.log(midPoint, position, pixelsToAdd, leftOffset);
-
- // console.log(draggerPosition - pixelsToAdd + position - 49)
- // console.log(draggerPositionB - pixelsToAdd + position - 49)
- this.setState({
- draggerPosition: draggerPosition - pixelsToAdd + position - 49,
- draggerVisible: draggerVisible,
- draggerPositionB: draggerPositionB - pixelsToAdd + position - 49,
- draggerVisibleB: draggerVisibleB,
- deque: deque,
- currentDateRange: current.dates,
- currentTransformX: currentTransformX,
- gridNumber: gridNumber,
- gridWidth: gridWidth,
- numberOfVisibleTiles: numberOfVisibleTiles,
- moved: false,
- timeScaleChange: true,
- dragSentinelChangeNumber: dragSentinelChangeNumber,
- position: position - pixelsToAdd,
- midPoint: position,
- dragSentinelCount: 0
- })
- }
-
- getDraggerPosition = (draggerTime, frontDate, timeScale, gridWidth) => {
- return Math.abs(moment.utc(frontDate).diff(moment.utc(draggerTime), timeScale, true) * gridWidth);
- }
-
- // changes timeScale state
- wheelZoom = (e) => {
- e.preventDefault();
- let arrayIndex = timeScales.indexOf(this.state.timeScale);
- if (e.deltaY > 0) { // wheel zoom out
- if (arrayIndex < 4) {
- let nextGreaterTimeScale = timeScales[arrayIndex + 1];
-
- //# componentDidUpdate catches this change - BEST WAY TO HANDLE THIS?
- this.setState({
- timeScale: nextGreaterTimeScale
- });
- }
- } else {
- if (arrayIndex > 0) { // wheel zoom in
- let nextSmallerTimeScale = timeScales[arrayIndex - 1];
-
- //# componentDidUpdate catches this change - BEST WAY TO HANDLE THIS?
- this.setState({
- timeScale: nextSmallerTimeScale
- });
- }
- }
- }
-
- // get left offset to position blue line on mouseover
- // getLeftOffset = (e, xOffset) => {
- // e.preventDefault();
- // // TODO: would like to change this parentOffset dom selector to something more React
- // //! IE11 DOESN'T LIKE offSetLeft - use getBoundingClientRect() .left
- // requestAnimationFrame(() => {
- // let parentOffset = document.querySelector('.inner').parentElement.offsetLeft;
- // let parentBoundingClientRect = document.querySelector('.inner').parentElement.getBoundingClientRect();
- // // console.log(parentOffset, parentBoundingClientRect.left)
- // let x = e.pageX - parentOffset;
- // let relativeX = x - this.state.position;
-
- // let hoverTime = this.showTime(relativeX);
- // this.setState({
- // leftOffset: x,
- // leftOffsetRelativeToInnerParent: relativeX,
- // hoverTime: hoverTime
- // });
- // })
- // }
-
-
- handleDrag = (e, d) => {
- e.stopPropagation();
- e.preventDefault();
- // const startTime = performance.now();
- // var deltaX = d.deltaX || e.movementX; //# NOT THE SAME
- var deltaX = d.deltaX;
- // prevent over dragging
- //! CAUSES AXIS JUMP - need to refine OR make pre/post grid tile buffers larger
- // if (deltaX > 0) {
- // deltaX = Math.min(this.state.gridWidth * 3, deltaX);
- // } else if (deltaX < 0) {
- // deltaX = Math.max(-this.state.gridWidth * 3, deltaX);
- // }
- let position = this.state.position + deltaX;
- let timeScale = this.state.timeScale;
- let gridWidth = this.state.gridWidth;
- let draggerPosition = this.state.draggerPosition + deltaX;
- let draggerPositionB = this.state.draggerPositionB + deltaX;
- let dragSentinelChangeNumber = this.state.dragSentinelChangeNumber;
- let dragSentinelCount = this.state.dragSentinelCount;
- //# PRE/POST GRIDARRAY UPDATE NOT NECESSARY FOR YEAR SINCE ALL YEARS DISPLAYED
- if (timeScale === 'year') {
- console.log('YEAR', draggerPosition);
- this.setState({
- draggerPosition: draggerPosition,
- draggerPositionB: draggerPositionB,
- position: position,
- dragSentinelCount: dragSentinelCount + deltaX
- });
- } else {
-
- // TODO: preChange and postChange interaction if user drags left then right, etc. - gridmovement is key
- // TODO: need to think of flexible use cases for gridMovement, changing preChange, and should make components absolute positioned to zero out
- if (deltaX > 0) { // dragging right - exposing past dates
- if ((dragSentinelCount + deltaX) > dragSentinelChangeNumber) {
-
- let overDrag = 0;
- if ((dragSentinelCount + deltaX) > dragSentinelChangeNumber + dragSentinelChangeNumber) {
- overDrag = Math.abs((dragSentinelCount + deltaX) - dragSentinelChangeNumber - dragSentinelChangeNumber);
- }
- let { currentDateRange, deque, currentTransformX, draggerVisible, draggerVisibleB, overDragGrids, draggerPositionRevision } = this.updatePanelDateRange(timeScale, deltaX, draggerPosition, overDrag);
-// const duration = performance.now() - startTime;
-// console.log(`hitpre someMethodIThinkMightBeSlow took ${duration}ms`);
- this.setState({
- currentDateRange: currentDateRange,
- deque: deque,
- currentTransformX: currentTransformX,
- dragSentinelCount: (dragSentinelCount + deltaX) - dragSentinelChangeNumber - (overDragGrids * gridWidth),
- draggerPosition: draggerPositionRevision,
- draggerVisible: draggerVisible,
- draggerPositionB: draggerPositionB,
- draggerVisibleB: draggerVisibleB,
- position: position,
- });
- } else {
- // reset dragSentinelCount on direction change to remaining distance to dragSentinelChangeNumber
- let newDragSentinelCount = dragSentinelCount < 0 ? (dragSentinelChangeNumber + dragSentinelCount + deltaX) : dragSentinelCount + deltaX;
- this.setState({
- draggerPosition: draggerPosition,
- draggerPositionB: draggerPositionB,
- position: position,
- dragSentinelCount: newDragSentinelCount
- });
- }
- } else if (deltaX < 0) { // dragging left - exposing future dates
-
-//# get dragSentinelCount 'number over dragSentinelChangeNumber' - add to variable to use to supplement below state (dragSentinelCount, postChangePosition)
-//# send down to this.updateDatePanelRange as argument
-//# use 'number over dragSentinelChangeNumber' to determine how many tiles to add/remove and how to shift transform
-
-//# need to evaluate the trade off of handling ALL tile adds like this vs. current 'dragSentinelChangeNumber' sentinel number
-
- if ((dragSentinelCount + deltaX) < -dragSentinelChangeNumber) {
- let overDrag = 0;
- if ((dragSentinelCount + deltaX) < -dragSentinelChangeNumber - dragSentinelChangeNumber) {
- overDrag = Math.abs((dragSentinelCount + deltaX) - -dragSentinelChangeNumber - -dragSentinelChangeNumber);
- }
- let { currentDateRange, deque, currentTransformX, draggerVisible, draggerVisibleB, overDragGrids, draggerPositionRevision } = this.updatePanelDateRange(timeScale, deltaX, draggerPosition, overDrag);
-// const duration = performance.now() - startTime;
-// console.log(`hitpost someMethodIThinkMightBeSlow took ${duration}ms`);
- this.setState({
- currentDateRange: currentDateRange,
- deque: deque,
- currentTransformX: currentTransformX,
- dragSentinelCount: (dragSentinelCount + deltaX) - -dragSentinelChangeNumber + (overDragGrids * gridWidth),
- draggerPosition: draggerPositionRevision,
- draggerVisible: draggerVisible,
- draggerPositionB: draggerPositionB,
- draggerVisibleB: draggerVisibleB,
- position: position,
- });
- } else {
- // reset dragSentinelCount on direction change to remaining distance to dragSentinelChangeNumber
- let newDragSentinelCount = dragSentinelCount > 0 ? (-dragSentinelChangeNumber + dragSentinelCount + deltaX) : dragSentinelCount + deltaX;
- this.setState({
- draggerPosition: draggerPosition,
- draggerPositionB: draggerPositionB,
- position: position,
- dragSentinelCount: newDragSentinelCount
- });
- }
- }
- }
- }
-
- updatePanelDateRange = (timeScale, deltaX, draggerPosition, overDrag) => {
- // const startTime = performance.now();
- let gridWidth = this.state.gridWidth;
- let deque = this.state.deque;
- let numberOfVisibleTiles = Math.floor(this.state.numberOfVisibleTiles * 0.25);
- let overDragGrids = Math.ceil(overDrag / gridWidth);
- let draggerVisible = this.state.draggerVisible;
- let draggerVisibleB = this.state.draggerVisibleB;
- let draggerDateActual = moment.utc(this.state.draggerTimeState);
- let dateArrayAdd;
- let dateArray;
- let transform;
- // let overDragGrids = Math.ceil(overDrag / gridWidth);
- // numberOfVisibleTiles = Math.floor(numberOfVisibleTiles * 0.25);
- if (deltaX > 0) { // dragging right - exposing past dates
- // PHASE 1
- let firstDateInRange = moment.utc(deque.peekFront().rawDate);
- dateArrayAdd = this.getDateArray(numberOfVisibleTiles + 1 + overDragGrids, -1, timeScale, firstDateInRange);
- // PHASE 2
- this.removeBackMultipleInPlace(deque, numberOfVisibleTiles + 1 + overDragGrids);
- deque.unshift(...dateArrayAdd.dates);
- dateArray = deque.toArray();
- // PHASE X - can be done in any order
- transform = this.state.currentTransformX - ((numberOfVisibleTiles + 1 + overDragGrids) * gridWidth);
- } else { // dragging left - exposing future dates
- // PHASE 1
- let lastDateInRange = moment.utc(deque.peekBack().rawDate);
- dateArrayAdd = this.getDateArray(-1, numberOfVisibleTiles + 1 + overDragGrids, timeScale, lastDateInRange);
- // PHASE 2
- this.removeFrontMultipleInPlace(deque, numberOfVisibleTiles + 1 + overDragGrids);
- deque.push(...dateArrayAdd.dates);
- dateArray = deque.toArray();
- // PHASE X - can be done in any order
- transform = this.state.currentTransformX + ((numberOfVisibleTiles + 1 + overDragGrids) * gridWidth);
- // transform = this.state.currentTransformX + (this.state.axisWidth); //! WHY NOT AXISWIDTH?
- }
-
- //# move this into parent function, make asynchronous and run prior to updatePanelDateRange
- //# make smarter for PAST vs FUTURE date changes, front/back dates will ONLY decerease
- //# and increase in certain changes to deque date array
- let frontDate = moment.utc(dateArray[0].rawDate);
- let backDate = moment.utc(dateArray[dateArray.length - 1].rawDate);
- let isBetween = moment.utc(this.state.draggerTimeState).isBetween(frontDate, backDate, null, '[]');
- let draggerPositionRevision = draggerPosition;
- if (isBetween) {
- // let draggerPositionRevision = Math.abs(frontDate.diff(draggerDateActual, timeScale, true) * gridWidth);
- // console.log(draggerPositionRevision)
- if (draggerVisible === false) {
- draggerPositionRevision = Math.abs(frontDate.diff(draggerDateActual, timeScale, true) * gridWidth);
- console.log('NOW VISIBLE', draggerPositionRevision)
- }
- draggerVisible = true;
- } else {
- draggerVisible = false;
- }
-
- let compareModeOn = this.state.compareMode;
- if (compareModeOn) {
- let isBetweenB = moment.utc(this.state.draggerTimeStateB).isBetween(frontDate, backDate, null, '[]');
- if (isBetweenB) {
- draggerVisibleB = true;
- } else {
- draggerVisibleB = false;
- }
- }
-
- return {
- currentDateRange: dateArray,
- deque: deque,
- currentTransformX: transform, //gridwidth * # of shifts and pushes
- draggerVisible: draggerVisible,
- draggerVisibleB: draggerVisibleB,
- overDragGrids: overDragGrids,
- draggerPositionRevision: draggerPositionRevision
- }
- }
-
- // deque extension to pop NUM times
- removeBackMultipleInPlace = (deque, num) => {
- for (let i = 0; i < num; i++) {
- deque.pop();
- }
- }
- // deque extension to shift NUM times
- removeFrontMultipleInPlace = (deque, num) => {
- for (let i = 0; i < num; i++) {
- deque.shift();
- }
- }
-
- // return array of days based on:
- // subtract - integer (negative numbers selects start date in the future)
- // add - integer (negative numbers selects end date in the past)
- getDateArray = (subtract, add, timeScale, inputDate) => {
- let dayZeroed;
- let startDate;
- let endDate;
- let dateArray;
-
- if (timeScale ==='year') {
- dayZeroed = moment.utc(inputDate).startOf('year');
- startDate = dayZeroed.year(1940);
- endDate = dayZeroed.clone().year(2021);
- } else {
- if (timeScale === 'month') {
- dayZeroed = moment.utc(inputDate).startOf('month');
- } else if(timeScale === 'day') {
- dayZeroed = moment.utc(inputDate).startOf('day');
- } else if(timeScale === 'hour') {
- dayZeroed = moment.utc(inputDate).startOf('hour');
- } else if(timeScale === 'minute') {
- dayZeroed = moment.utc(inputDate).startOf('minute');
- }
- startDate = dayZeroed.clone().subtract(subtract, timeScale);
- endDate = dayZeroed.clone().add(add, timeScale);
- }
- // console.log(inputDate, dayZeroed.format(), startDate.format(), endDate.format(), subtract, add)
- dateArray = dateCalc.getTimeRange(startDate, endDate, timeScale);
- // console.log(dateArray)
- return dateArray;
- }
-
-
- // Called when AXIS dragging starts. If `false` is returned any handler,
- // the action will cancel.
- // handleStartDrag = () => {
- // this.setState({
- // dragging: !this.state.dragging
- // });
- // }
-
- // Called when AXIS dragging stops.
- // handleStopDrag = () => {
- // this.setState({
- // dragging: !this.state.dragging
- // });
- // }
-
- // set temp place holder for where hover line was when clicked to check for drag vs click
- setLineClick = () => {
- // console.log('hit', this.state.hoverTime)
- this.setState({
- // draggerTimeState: this.state.hoverTime,
- redLineClick: this.state.leftOffset,
- })
- }
-
- // move red line to new position
- setLineTime = (e) => {
-
- e.preventDefault();
- 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
- }
- // console.dir(e.target)
- // console.log(this.state.position , this.state.leftOffset, this.state.redLineClick, this.state.moved, this.state.draggerPosition)
- // if (this.state.leftOffset === this.state.redLineClick) {
- // console.log(!this.state.moved && !this.state.timeScaleChange)
- if (!this.state.moved) {
- console.log('inner')
- // let draggerTimeState = this.showTime(this.state.leftOffsetRelativeToInnerParent);
- // this.handleDragDragger(null, {'deltaX': this.state.leftOffset})
- 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)
- this.setState({
- draggerPosition: draggerPosition,
- draggerVisible: true,
- draggerPositionB: draggerPositionB,
- // draggerVisible: true,
- // redLineOffset: this.state.leftOffsetRelativeToInnerParent,
- redLineOffset: this.state.leftOffset,
- draggerTimeState: this.state.hoverTime,
- selectedDate: this.state.hoverTime,
- moved: false
- })
- }
- }
-
- handleResize = (e) => {
- // let axisWidth = Math.floor(window.innerWidth * 0.9);
- let axisWidth = this.props.width;
- let timeScale = this.state.timeScale;
- this.updateScale(timeScale, axisWidth);
- console.log('resize')
- this.setState({
- axisWidth: axisWidth
- }, function() {
- let parentBoundingClientRect = document.querySelector('#wv-timeline-axis').getBoundingClientRect();
- this.setState({
- parentBoundingClientRectLeft: parentBoundingClientRect.left
- });
- })
- };
-
- componentDidMount() {
- //# resize
- window.addEventListener("resize", this.handleResize);
- // let axisWidth = Number((window.innerWidth * 0.9).toFixed(2));
- let axisWidth = this.props.width;
- let timeScale = this.props.timeScale; // 'day'
- let time = moment.utc(this.props.selectedDate).format() //'1941-01-01T12:00:00Z';
-
- // time = moment.utc(time.toISOString());
- console.log(time)
- // let draggerTimeStateBDraggerBTest = '1941-01-03T12:00:00Z';
- let draggerTimeStateBDraggerBTest = moment.utc(time).add(7, timeScale).format();
-
- //# get timeScale specifics based on props
- let options = timeScaleOptions[timeScale].timeAxis;
- let gridWidth = options.gridWidth; // 12
-
- //# calculate number of grids viewable based on axisWidth and gridWidth of timeScale
- // console.log(axisWidth, Math.floor(axisWidth / gridWidth))
- // this.handleResize();
- let numberOfVisibleTiles = Number((axisWidth / gridWidth).toFixed(8));
- // let tilesTillSelectedDAte = Math.floor(numberOfVisibleTiles / 2);
- // let draggerPosition = Number(((axisWidth / 2) - 50).toFixed(8));
-
- // let draggerPosition = tilesTillSelectedDAte * gridWidth - 49; //# CENTER DRAGGER A
- let draggerVisible = true;
-
- //# DRAGGER B TESTING POSITION
- // let draggerPositionB = draggerPosition + (gridWidth * 2.5);
- let draggerVisibleB = false;
- let compareModeOn = false;
- if (compareModeOn) {
- draggerVisibleB = true;
- }
-
- // console.log(numberOfVisibleTiles)
- //# times 1.5 is cutting it close (down to 1 grid at leading edge - will continue to test)
- let gridNumber = Math.floor(numberOfVisibleTiles * 1.5);
- let dragSentinelChangeNumber = gridWidth * (Math.floor(numberOfVisibleTiles * 0.25) + 1);
- // console.log(dragSentinelChangeNumber)
- //# get midPoint for position based on # of tiles and gridWidth
- //# 120 test case - this.getDateArray(60, 60, timeScale, selectedDate);
- // let midPointOLD = -((gridWidth * (numberOfVisibleTiles * 1.5)) / 2) + (numberOfVisibleTiles / 2 * gridWidth);
- // let midPoint = +(-(+((gridWidth * +(numberOfVisibleTiles * 1.5).toFixed(10)) / 2).toFixed(10)) + +(+(numberOfVisibleTiles / 2).toFixed(10) * gridWidth).toFixed(10)).toFixed(10); //# CAN'T FLOOR numberOfVisibleTiles / 2
-
- let midPoint = -((gridWidth * gridNumber) / 2) + (numberOfVisibleTiles / 2 * gridWidth);
-
- let draggerTime = moment.utc(time);
- let draggerTimeZero = moment.utc(time).startOf(timeScale)
- let draggerTimeNextZero = moment.utc(draggerTime).startOf(timeScale).add(1, timeScale);
-
- let draggerTimeValue = moment.utc(draggerTime).valueOf();
- let draggerTimeZeroValue = moment.utc(draggerTimeZero).valueOf();
- let draggerTimeNextZeroValue = moment.utc(draggerTimeNextZero).valueOf();
-
- let diffZeroValues = draggerTimeNextZeroValue - draggerTimeZeroValue;
- let diffFactor = diffZeroValues / gridWidth;
- let diffStartAndZeroed = draggerTimeValue - draggerTimeZeroValue;
-
- let pixelsToAdd = diffStartAndZeroed / diffFactor;
-
- let selectedDate = moment.utc(time);
- // console.log(selectedDate)
- //# handle date array creation
- let current = this.getDateArray(Math.floor(gridNumber/2), Math.floor(gridNumber/2), timeScale, time);
-
- let frontDate = moment.utc(current.dates[0].rawDate);
- let draggerPosition = Math.abs(frontDate.diff(draggerTime, timeScale, true) * gridWidth);
- let draggerPositionB = Math.abs(frontDate.diff(moment.utc(draggerTimeStateBDraggerBTest), timeScale, true) * gridWidth);
- // this.addLine(initDateStart);
- // console.log(numberOfVisibleTiles, dragSentinelChangeNumber)
-
- // console.log(draggerPosition, pixelsToAdd, midPoint)
- // console.log(this.getDraggerPosition(draggerTimeStateBDraggerBTest, current.dates[0].rawDate, 'day', gridWidth))
-
- this.setState({
- compareMode: false,
- timeScaleSelectValue: timeScale,
- deque: new Deque(current.dates),
- // draggerPosition: draggerPosition + pixelsToAdd,
- draggerPosition: draggerPosition + midPoint - 49,
- draggerVisible: draggerVisible,
- draggerPositionB: draggerPositionB + midPoint - 49,
- draggerVisibleB: draggerVisibleB,
- redLineOffset: draggerPosition + pixelsToAdd + 49,
- numberOfVisibleTiles: numberOfVisibleTiles,
- dragSentinelChangeNumber: dragSentinelChangeNumber,
- axisWidth: axisWidth,
- timeScale: timeScale,
- selectedDate: time,
- // midTileDate: selectedDate.format(),
- currentDateRange: current.dates,
- gridWidth: gridWidth,
- draggerTimeState: time,
- draggerTimeStateB: draggerTimeStateBDraggerBTest,
- hoverTime: time,
- currentTransformX: 0,
- midPoint: midPoint,
- position: midPoint,
- }, function() {
- // let setPosition = this.getPositionFromDate(selectedDate);
- // console.log(setPosition)
- let parentBoundingClientRect = document.querySelector('#wv-timeline-axis').getBoundingClientRect();
- this.setState({
- parentBoundingClientRectLeft: parentBoundingClientRect.left
- });
- });
- }
-
- shouldComponentUpdate(nextProps, nextState) {
- // console.log(nextProps.timeScale, nextState.timeScale, this.state.timeScale)
- // if (this.state.timeScale !== nextState.timeScale) {
- // console.log('update')
- // return true;
- // }
- // return false;
- return true;
- }
-
- //# BEST WAY TO HANDLE THIS?
- componentDidUpdate(prevProps, prevState) {
- // 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)
- if (this.state.timeScale !== prevState.timeScale) {
- this.updateScale(this.state.timeScale);
- }
-
- if (this.props.width !== prevProps.width) {
- this.handleResize();
- }
-
-
- // else if (propsSelectedDate !== stateSelectedDate) {
- // this.setState({
- // selectedDate: propsSelectedDate,
- // hoverTime: propsSelectedDate,
- // draggerTimeState: propsSelectedDate
- // }, this.updateScale(this.state.timeScale))
- // }
- }
-
- // TODO: may need to restrict based on zoom levels, year zoom adding 7 minutes does nothing for example
- // move red line forward one timeScale unit and update time
- addTimeUnit = () => {
- let timeScaleSelected = this.state.timeScaleSelectValue;
- let frontDate = moment.utc(this.state.deque.peekFront().rawDate);
- let backDate = moment.utc(this.state.deque.peekBack().rawDate);
- let increment = this.state.increment;
- let draggerTimeState = moment.utc(this.state.draggerTimeState, 'YYYY-MM-DDTHH:mm:ss.SSSZ');
- let draggerTimeStateAdded = draggerTimeState.clone().add(increment, timeScaleSelected);
-
- let isBetween = draggerTimeState.isBetween(frontDate, backDate, null, '[]');
- if (isBetween) {
- let gridWidth = this.state.gridWidth;
- let timeScale = this.state.timeScale;
- let pixelsToAddToDragger = Math.abs(frontDate.diff(draggerTimeState, timeScale, true) * gridWidth);
- let pixelsToAddToDraggerNew = Math.abs(frontDate.diff(draggerTimeStateAdded, timeScale, true) * gridWidth);
- let pixelsToAddBasedOnFrontDate = pixelsToAddToDraggerNew - pixelsToAddToDragger;
- this.setState({
- draggerPosition: this.state.draggerPosition + pixelsToAddBasedOnFrontDate,
- draggerTimeState: draggerTimeStateAdded.format(),
- redLineOffset: this.state.redLineOffset + pixelsToAddBasedOnFrontDate
- },
- this.props.incrementDate(timeScaleSelected, increment));
- } else {
- this.setState({
- draggerTimeState: draggerTimeStateAdded.format()
- });
- }
- }
-
- // move red line backward one timeScale unit and update time
- minusTimeUnit = () => {
- let timeScaleSelected = this.state.timeScaleSelectValue;
- let frontDate = moment.utc(this.state.deque.peekFront().rawDate);
- let backDate = moment.utc(this.state.deque.peekBack().rawDate);
- let increment = this.state.increment;
- let draggerTimeState = moment.utc(this.state.draggerTimeState, 'YYYY-MM-DDTHH:mm:ss.SSSZ');
- let draggerTimeStateSubtracted = draggerTimeState.clone().subtract(increment, timeScaleSelected);
-
- let isBetween = draggerTimeState.isBetween(frontDate, backDate, null, '[]');
- if (isBetween) {
- let gridWidth = this.state.gridWidth;
- let timeScale = this.state.timeScale;
- let pixelsToAddToDragger = Math.abs(frontDate.diff(draggerTimeState, timeScale, true) * gridWidth);
- let pixelsToAddToDraggerNew = Math.abs(frontDate.diff(draggerTimeStateSubtracted, timeScale, true) * gridWidth);
- let pixelsToAddBasedOnFrontDate = pixelsToAddToDraggerNew - pixelsToAddToDragger;
- this.setState({
- draggerPosition: this.state.draggerPosition + pixelsToAddBasedOnFrontDate,
- draggerTimeState: draggerTimeStateSubtracted.format(),
- redLineOffset: this.state.redLineOffset + pixelsToAddBasedOnFrontDate
- },
- this.props.incrementDate(timeScaleSelected, -increment));
- } else {
- this.setState({
- draggerTimeState: draggerTimeStateSubtracted.format()
- });
- }
- }
-
- handleStopDrag = (e, d) => {
- let midPoint = this.state.midPoint;
- let position = this.state.position - midPoint;
- // let dragSentinelChangeNumber = this.state.dragSentinelChangeNumber;
- // let timeScale = this.state.timeScale;
- let moved = false;
- // necesarry for timescale change, d.x and midPoint are off
- // after timeScale change
- // console.log(d.x, midPoint, position, this.state.currentTransformX)
- // let panelUpdate = this.state;
- if (d.x > midPoint) { // drag right
- moved = true;
-
- } else if(d.x < midPoint) { // drag left
- moved = true;
- }
- this.setState({
- moved: moved,
- position: midPoint,
- currentTransformX: this.state.currentTransformX + position,
- })
- }
-
- displayDate = (date, leftOffset) => {
- requestAnimationFrame(() => {
- //! IE11 undefined parentElement issue fix
- this.setState({
- hoverTime: date,
- leftOffset: leftOffset - this.state.parentBoundingClientRectLeft // relative location from parent bounding box for BLUE LINE
- });
- })
- }
-
- // handle dragger dragging
- handleDragDragger = (draggerName, e, d) => {
- // console.log(e,d, draggerName)
- if (e) {
- e.stopPropagation();
- e.preventDefault();
- }
-
- requestAnimationFrame(() => {
- // var deltaX = d.deltaX || e.movementX; //# NOT THE SAME
- var deltaX = d.deltaX;
- let gridWidth = this.state.gridWidth;
- let timeScale = this.state.timeScale;
- let axisWidth = this.state.axisWidth;
-
- let time;
- let draggerPosition;
- if (draggerName === 'A') {
- draggerPosition = this.state.draggerPosition + deltaX;
- time = this.state.draggerTimeState;
- } else { // draggerName === 'B'
- draggerPosition = this.state.draggerPositionB + deltaX;
- time = this.state.draggerTimeStateB;
- }
-
- // console.log(draggerPosition, time)
- // update draggerTimeState based on deltaX from state draggerTimeState
- // TODO: test consistency throught timescales, currently seems off 0.5 on ocassion
- let draggerTime = moment.utc(time);
- let draggerTimeZero = draggerTime.clone().startOf(timeScale);
- let draggerTimeNextZero = draggerTimeZero.clone().add(1, timeScale);
-
- let draggerTimeValue = draggerTime.valueOf();
- let draggerTimeZeroValue = draggerTimeZero.valueOf();
- let draggerTimeNextZeroValue = draggerTimeNextZero.valueOf();
-
- let diffZeroValues = draggerTimeNextZeroValue - draggerTimeZeroValue;
- let diffFactor = diffZeroValues / gridWidth;
- let newDraggerTime = moment.utc(draggerTimeValue + (diffFactor * deltaX)).format();
-
- // handle drag timeline
- // TODO: updatePanel
- if (draggerPosition < -49) { // handle drag timeline towards PAST
- this.setState({
- draggerPosition: -48,
- moved: true,
- position: this.state.position - deltaX * 2
- })
- } else if (draggerPosition > axisWidth - 49) { // handle drag timeline towards FUTURE
- this.setState({
- draggerPosition: axisWidth - 50,
- moved: true,
- position: this.state.position - deltaX * 2
- })
- } else { // handle drag within axis view
- if (draggerName === 'A') {
- this.setState({
- draggerPosition: draggerPosition,
- draggerTimeState: newDraggerTime,
- moved: true,
- draggerSelected: true,
- draggerSelectedB: false,
- });
- } else {
- this.setState({
- draggerPositionB: draggerPosition,
- draggerTimeStateB: newDraggerTime,
- moved: true,
- draggerSelected: false,
- draggerSelectedB: true,
- });
- }
- }
- })
- }
-
- // get mid tile date in currentDateRange from deque
- // getMidTileDate = () => {
- // let midTile = this.state.deque.get(Math.floor(this.state.deque.length / 2));
- // return midTile.rawDate;
- // }
-
- // select dragger
- selectDragger = (draggerName) => {
- console.log(draggerName)
- this.setState((prev) => ({
- draggerSelected: draggerName === 'A' ? true : false,
- draggerSelectedB: draggerName === 'B' ? true : false
- })
- )
- }
-
- //# HANDLE INCREMENT FORM TESTING
-// handleChangeZoomLevel(event) {
-// event.preventDefault();
-// this.setState({
-// timeScale: event.target.value,
-// leftOffset: this.state.axisWidth/2
-// });
-// }
-
-// handleChange(event) {
-// this.setState({ increment: Number(event.target.value) });
-// }
-
-// handleSubmit(event) {
-// event.preventDefault();
-// }
-
-// handleReset(event) {
-// this.setState({ increment: 1 });
-// }
-
-// handleTimeScaleSelectChange(event) {
-// this.setState({ timeScaleSelectValue: event.target.value })
-// }
-
- showHoverOn = () => {
- this.setState({ showHoverLine: true });
- }
-
- showHoverOff = () => {
- this.setState({ showHoverLine: false });
- }
-
- toggleCompareMode = () => {
- let frontDate = moment.utc(this.state.deque.peekFront().rawDate);
- let backDate = moment.utc(this.state.deque.peekBack().rawDate);
- let draggerTimeStateB = moment.utc(this.state.draggerTimeStateB, 'YYYY-MM-DDTHH:mm:ss.SSSZ');
- let isBetween = draggerTimeStateB.isBetween(frontDate, backDate, null, '[]');
-
- let draggerVisibleB = isBetween ? true : false;
- this.setState({
- compareMode: !this.state.compareMode,
- draggerVisibleB: draggerVisibleB
- });
- }
-
- render() {
- // TODO: debug globals added to window temporarily
- window.deque = Deque;
- window.moment = moment;
- return (
- <div>
- {/* <div style={{display: 'flex', position: 'relative', left: (window.innerWidth * 0.05)}}>
- <div style={{display: 'flex', background: '#999', border: '1px solid black', width: '155px', height: '100px'}}>
- <form onSubmit={this.handleSubmit.bind(this)}>
- <label>
- <input type="text" value={this.state.increment} onChange={(e) => this.handleChange(e)} />
- </label>
- <select value={this.state.timeScaleSelectValue} onChange={(e) => this.handleTimeScaleSelectChange(e)}>
- <option value="minute">minute</option>
- <option value="hour">hour</option>
- <option value="day">day</option>
- <option value="month">month</option>
- <option value="year">year</option>
- </select>
- <button >Set</button>
- <button onClick={() => this.handleReset()}>Reset</button>
-
- </form>
- <button className="incrementButton" onClick={() => this.minusTimeUnit()}>{"<"}</button>
- <button className="incrementButton" onClick={() => this.addTimeUnit()}>{">"}</button>
- </div>
- <div className="changeZoomLevelButtons" style={{display: 'flex', border: '1px solid black'}}>
- <button value="minute" onClick={(e) => this.handleChangeZoomLevel(e)}>minute</button>
- <button value="hour" onClick={(e) => this.handleChangeZoomLevel(e)}>hour</button>
- <button value="day" onClick={(e) => this.handleChangeZoomLevel(e)}>day</button>
- <button value="month" onClick={(e) => this.handleChangeZoomLevel(e)}>month</button>
- <button value="year" onClick={(e) => this.handleChangeZoomLevel(e)}>year</button>
- </div>
- <div>
- <button onClick={(e) => this.toggleCompareMode(e)}>Compare Mode</button>
- </div>
- </div> */}
- <div id="wv-timeline-axis"
- // ref={this.timelineRef} //# REF
- style={{width: `${this.state.axisWidth}px`}}
- // onMouseMove={(e) => this.getLeftOffset(e, e.clientX)}
- onMouseDown={() => this.setLineClick()}
- onMouseUp={(e) => this.setLineTime(e)}
- onWheel={(e) => this.wheelZoom(e)}
- // onMouseOver={() => this.setState({showHoverLine: true})}
- // onMouseLeave={() => this.setState({showHoverLine: false})}
- onMouseOver={this.showHoverOn}
- onMouseLeave={this.showHoverOff}
- >
- {this.state.currentDateRange ?
- <svg className="inner"
- width={this.state.axisWidth}
- height={70}
- viewBox={`0 0 ${this.state.axisWidth} 75`}
- preserveAspectRatio="none">
- {/* <clipPath id="myClip">
- <rect width="884" height="90" x={-this.state.position}/>
- </clipPath> */}
- <defs>
- <clipPath id="textDisplay">
- <rect width="200" height="70" />
- </clipPath>
- </defs>
- <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)}
-
- >
- {/* <g clipPath="url(#myClip)"> */}
- <g>
- <GridRange
- timeScale={this.state.timeScale}
- displayDate={this.displayDate}
- gridWidth={this.state.gridWidth}
- dateArray={this.state.currentDateRange}
- transformX={this.state.currentTransformX} />
- </g>
- </Draggable>
- <Dragger
- handleDragDragger={this.handleDragDragger}
- selectDragger={this.selectDragger}
- compareOn={this.state.compareMode}
- draggerName='A'
- draggerPosition={this.state.draggerPosition}
- draggerVisible={this.state.draggerVisible}
- transformX={this.state.currentTransformX}
- draggerSelected={this.state.draggerSelected}
- parentPosition={this.state.position} />
- <Dragger
- handleDragDragger={this.handleDragDragger}
- selectDragger={this.selectDragger}
- compareOn={this.state.compareMode}
- draggerName='B'
- draggerPosition={this.state.draggerPositionB}
- draggerVisible={this.state.compareMode ? this.state.draggerVisibleB : false}
- transformX={this.state.currentTransformX}
- draggerSelected={this.state.draggerSelectedB}
- parentPosition={this.state.position} />
- </svg>
- : null }
- {/* <div className="linered" style={{transform: `translate(${Math.floor(this.state.redLineOffset)}px, 0px)`}}></div> */}
- <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)`}}>{this.state.draggerTimeState ? this.state.draggerTimeState : null}</div>
- <div className="dateToolTip" style={{transform: `translate(${this.state.leftOffset - 52}px, -125px)`, display: this.state.showHoverLine ? 'block' : 'none'}}>{this.state.hoverTime ? this.state.hoverTime : null}</div>
-
- </div>
- <div style={{ display: 'flex', marginTop: 10 }}>
- <div className="dateTempHolderTextBlock" style={{borderColor: 'blue'}}>
- <h4 style={{marginTop: 5, marginBottom: 5}}>HOVER TIME</h4>
- <p style={{marginTop: 5, marginBottom: 0, fontSize: 20}}>{this.state.hoverTime ? this.state.hoverTime : null}</p>
- </div>
- <div className="dateTempHolderTextBlock" style={{borderColor: 'red'}}>
- <h4 style={{marginTop: 5, marginBottom: 5}}>DRAGGER A TIME</h4>
- <p style={{marginTop: 5, marginBottom: 0, fontSize: 20}}>{this.state.draggerTimeState ? this.state.draggerTimeState : null}</p>
- </div>
- <div className="dateTempHolderTextBlock" style={{borderColor: 'orange'}}>
- <h4 style={{marginTop: 5, marginBottom: 5}}>DRAGGER B TIME</h4>
- <p style={{marginTop: 5, marginBottom: 0, fontSize: 20}}>{this.state.draggerTimeStateB ? this.state.draggerTimeStateB : null}</p>
- </div>
- <div className="dateTempHolderTextBlock" style={{borderColor: 'black'}}>
- <h4 style={{marginTop: 5, marginBottom: 5}}>TIMESCALE ZOOM</h4>
- <p style={{marginTop: 5, marginBottom: 0, fontSize: 20}}>{this.state.timeScale ? this.state.timeScale.toUpperCase() : null}</p>
- </div>
- </div>
- </div>
- );
- }
-}
-
-class Dragger extends PureComponent {
- render() {
- // console.log(this.props)
- let { transformX, draggerPosition, draggerName, handleDragDragger, selectDragger, compareOn } = this.props;
- return (
- <Draggable
- axis="x"
- onMouseDown={() => selectDragger(draggerName)}
- onDrag={handleDragDragger.bind(this, draggerName)}
- position={{ x: draggerPosition, y: -25 }}
- // onStart={this.handleStartDrag.bind(this)}
- // onStop={this.handleStopDrag.bind(this)}
- // onStop={() => {
- // this.props.onStop(this.props.id, this.state.position);
- // }}
- >
- <g style={{cursor: 'pointer', display: this.props.draggerVisible ? 'flex' : 'none'}} className="gridShell dragger" transform={`translate(${transformX}, 0)`}>
- <polygon fill='#ccc' stroke={this.props.draggerSelected ? 'yellow' : '#515151'} strokeWidth='2px' points='50,25, 90,90, 10,90'></polygon>
- {compareOn ?
- <text fontSize='30px' fontWeight='700' x='0' y='65' fill='#515151' transform={`translate(39, 10)`} textRendering='optimizeLegibility' clipPath='url(#textDisplay)'>{draggerName}</text>
- :
- <React.Fragment>
- <rect fill='#515151' width='4' height='20' x='41' y='55'></rect>
- <rect fill='#515151' width='4' height='20' x='48' y='55'></rect>
- <rect fill='#515151' width='4' height='20' x='55' y='55'></rect>
- </React.Fragment>
- }
- </g>
- </Draggable>
- )
- }
-}
-
-export default TimelineAxis;
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 28e83ed3e..2ad2aae8e 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
@@ -95,6 +95,7 @@ const tileTextConditionOptions = {
class TileHolder extends PureComponent {
render() {
let timeScale = this.props.timeScale;
+ console.log(timeScale)
let tileTextCondition = tileTextConditionOptions[timeScale];
let midTile = Math.floor(this.props.dateArray.length / 2);
return (
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index dbffc3c06..90cc61de8 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -233,6 +233,7 @@ class TimelineAxis extends React.Component {
numberOfVisibleTiles: numberOfVisibleTiles,
moved: false,
timeScaleChange: true,
+ timeScale: timeScale,
dragSentinelChangeNumber: dragSentinelChangeNumber,
position: position - pixelsToAdd,
midPoint: position,
@@ -576,7 +577,9 @@ class TimelineAxis extends React.Component {
// console.log('inner')
// let draggerTimeState = this.showTime(this.state.leftOffsetRelativeToInnerParent);
// this.handleDragDragger(null, {'deltaX': this.state.leftOffset})
- let draggerPosition = this.state.draggerSelected ? this.state.leftOffset - 49 : this.state.draggerPosition;
+ // 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 draggerPositionB = this.state.draggerSelectedB ? this.state.leftOffset - 49 : this.state.draggerPositionB;
// console.log(this.state.draggerSelected, this.state.draggerSelectedB)
@@ -735,10 +738,15 @@ class TimelineAxis extends React.Component {
// let stateSelectedDate = moment.utc(prevState.selectedDate).format();
// console.log(propsSelectedDate, stateSelectedDate)
+ console.log(prevProps.timeScaleChangeUnit, this.props.timeScaleChangeUnit, this.state.timeScaleChangeUnit, prevState.timeScaleChangeUnit)
if (this.state.timeScale !== prevState.timeScale) {
this.updateScale(null, this.state.timeScale);
}
+ if (prevProps.timeScaleChangeUnit !== this.props.timeScaleChangeUnit) {
+ this.updateScale(null, this.props.timeScaleChangeUnit);
+ }
+
if (this.props.width !== prevProps.width) {
this.handleResize();
}
@@ -919,6 +927,7 @@ class TimelineAxis extends React.Component {
displayDate = (date, leftOffset) => {
requestAnimationFrame(() => {
+ // console.log(this.state.parentBoundingClientRectLeft)
//! IE11 undefined parentElement issue fix
this.setState({
hoverTime: date,
@@ -1143,7 +1152,7 @@ handleDragDragger = (draggerName, e, d) => {
window.deque = Deque;
window.moment = moment;
return (
- <div>
+ <React.Fragment>
{/* <div style={{display: 'flex', position: 'relative', left: (window.innerWidth * 0.05)}}>
<div style={{display: 'flex', background: '#999', border: '1px solid black', width: '155px', height: '100px'}}>
<form onSubmit={this.handleSubmit.bind(this)}>
@@ -1189,6 +1198,7 @@ handleDragDragger = (draggerName, e, d) => {
>
{this.state.currentDateRange ?
<svg className="inner"
+ id="timeline-footer-svg"
width={this.state.axisWidth}
height={70}
viewBox={`0 0 ${this.state.axisWidth} 75`}
@@ -1212,7 +1222,7 @@ handleDragDragger = (draggerName, e, d) => {
{/* <g clipPath="url(#myClip)"> */}
<g>
<GridRange
- showHoverLine={this.state.showHoverLine}
+ showHoverLine={this.state.showHoverLine}
timeScale={this.state.timeScale}
displayDate={this.displayDate}
gridWidth={this.state.gridWidth}
@@ -1246,7 +1256,9 @@ handleDragDragger = (draggerName, e, d) => {
: 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.leftOffset - 52}px, -100px)`, display: !this.state.showDraggerTime && this.state.showHoverLine ? 'block' : 'none'}}>{!this.state.showDraggerTime && this.state.hoverTime ? this.state.hoverTime : 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>
{/* <div style={{ display: 'flex', marginTop: 10 }}>
@@ -1267,7 +1279,7 @@ handleDragDragger = (draggerName, e, d) => {
<p style={{marginTop: 5, marginBottom: 0, fontSize: 20}}>{this.state.timeScale ? this.state.timeScale.toUpperCase() : null}</p>
</div>
</div> */}
- </div>
+ </React.Fragment>
);
}
}
diff --git a/web/js/components/timeline/timeline-controls/date-change-controls.js b/web/js/components/timeline/timeline-controls/date-change-controls.js
index ab99951f9..eb0477be5 100644
--- a/web/js/components/timeline/timeline-controls/date-change-controls.js
+++ b/web/js/components/timeline/timeline-controls/date-change-controls.js
@@ -51,9 +51,9 @@ class DateChangeControls extends React.Component {
// console.log(this.props.selectedDate)
return (
<div>
- <DateSelector
+ {/* <DateSelector
{...mockDateSelectorProps}
- />
+ /> */}
{/* <DateZoomChange />
<DateChangeArrows /> */}
diff --git a/web/js/components/timeline/timeline-controls/date-zoom-change.js b/web/js/components/timeline/timeline-controls/date-zoom-change.js
index 0a2298927..c98c97a56 100644
--- a/web/js/components/timeline/timeline-controls/date-zoom-change.js
+++ b/web/js/components/timeline/timeline-controls/date-zoom-change.js
@@ -1,63 +1,89 @@
-import React, { PureComponent } from 'react';
+import React, { Component } from 'react';
+
+class DateZoomChange extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ toolTipHovered: false
+ }
+ }
+
+ // Toggle zoom select tooltip
+ toggleTooltipHover = (isHovered) => {
+ this.setState({
+ toolTipHovered: isHovered
+ })
+ }
+
+ handleClickZoom = (zoomSelected) => {
+ // close tooltip
+ // send props function to change timescale zoom level throughout app
+ this.setState({
+ toolTipHovered: false
+ }, this.props.setTimeScale(zoomSelected));
+ }
-class DateZoomChange extends PureComponent {
render() {
return (
- <div>
-
- <div id="zoom-btn-container">
+ <React.Fragment>
+ <div id="zoom-btn-container"
+ onMouseEnter={() => this.toggleTooltipHover(true)}
+ onMouseLeave={() => this.toggleTooltipHover(false)}
+ >
{/* timeScale display */}
<span
id="current-zoom"
className="zoom-btn zoom-btn-active"
- data-zoom="3"
>
- Days
+ {this.props.timeScaleChangeUnit}
</span>
{/* hover timeScale unit dialog / entry point to Custom selector */}
- <div className="wv-tooltip">
+ <div className="wv-tooltip"
+ style={{ display: this.state.toolTipHovered ? 'block' : 'none' }}
+ >
<div id="timeline-zoom" className="timeline-zoom">
<span
id="zoom-years"
className="zoom-btn zoom-btn-inactive zoom-years"
- data-zoom="1"
+ onClick={() => this.handleClickZoom('year')}
>
Years
</span>
<span
id="zoom-months"
className="zoom-btn zoom-btn-inactive zoom-months"
- data-zoom="2"
+ onClick={() => this.handleClickZoom('month')}
>
Months
</span>
<span
id="zoom-days"
className="zoom-btn zoom-btn-inactive zoom-days"
- data-zoom="3"
+ onClick={() => this.handleClickZoom('day')}
>
Days
</span>
<span
id="zoom-minutes"
className="zoom-btn zoom-btn-inactive zoom-minutes"
- data-zoom="4"
+ onClick={() => this.handleClickZoom('minute')}
>
Minutes
</span>
<span
id="zoom-custom"
+ style={{color: '#7890cd'}}
className="zoom-btn zoom-btn-inactive zoom-custom"
- data-zoom="5"
+ onClick={() => this.handleClickZoom('custom')}
>
- Custom
+ {this.props.customTimeInterval ? this.props.customTimeInterval : 'Custom'}
</span>
</div>
</div>
</div>
- </div>
+ </React.Fragment>
);
}
}
diff --git a/web/js/components/timeline/timeline.css b/web/js/components/timeline/timeline.css
index d203b10a1..053e20f7d 100644
--- a/web/js/components/timeline/timeline.css
+++ b/web/js/components/timeline/timeline.css
@@ -13,13 +13,13 @@ html, body {
position: absolute;
/* top: 200px; */
bottom: -24px;
- left: 416px;
+ /* left: 416px; */
}
#wv-timeline-axis {
/* margin: 0 20px 0 0; */
/* margin-left: 25%; */
- width: 800px;
+ /* width: 800px; */
height: 100px;
/* position: absolute;
@@ -199,7 +199,7 @@ form select {
/* DEMO DOM CLEANUP */
-#timeline-footer-svg {
+/* #timeline-footer-svg {
opacity: 0;
display: none;
}
@@ -226,5 +226,5 @@ form select {
#wv-animation-widget {
margin-left: 500px;
-}
+} */
diff --git a/web/js/components/timeline/timeline.js b/web/js/components/timeline/timeline.js
index fa5b180cd..744b3d665 100644
--- a/web/js/components/timeline/timeline.js
+++ b/web/js/components/timeline/timeline.js
@@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import DateChangeControls from './timeline-controls/date-change-controls';
+import DateZoomChange from './timeline-controls/date-zoom-change';
import './timeline.css';
// import TimelineAxis from './timeline-axis';
import TimelineAxisContainer from './timeline-axis/timeline-axis-container';
@@ -70,7 +71,7 @@ class Timeline extends React.Component {
changeDate: this.props.changeDate,
timeScale: this.props.timeScale,
incrementDate: this.props.incrementDate,
- timeScaleChangeUnit: this.props.timeScaleChangeUnit,
+ timeScaleChangeUnit: this.props.timeScale,
changeAmt: 1,
customIntervalValue: 1,
customIntervalZoomLevel: this.props.timeScale
@@ -84,42 +85,48 @@ class Timeline extends React.Component {
}, this.props.setIntervalInput(intervalValue, zoomLevel))
}
+ setTimeScale = (timeScaleChangeUnit) => {
+
+ if (timeScaleChangeUnit === 'custom') {
+ console.log(timeScaleChangeUnit)
+ // let toggle = this.state.customIntervalModalOpen;
+ // console.log(toggle)
+ // this.setState({
+ // customIntervalModalOpen: toggle
+ // })
+ } else {
+ this.setState({
+ timeScaleChangeUnit: timeScaleChangeUnit
+ })
+ }
+ }
+
shouldComponentUpdate(nextProps, nextState) {
// console.log(this.props, nextProps, this.state, nextState)
return true;
}
render() {
- // console.log(this.props.selectedDate, this.state.dateFormatted)
- // let dateFormatted = this.state.selectedDate.toISOString();
- // let tempStyle = {
- // position: 'absolute',
- // border: '1px solid #333',
- // background: 'rgba(40, 40, 40, 0.9)',
- // borderRadius: '5px',
- // display: 'flex',
- // flexFlow: 'row nowrap',
- // marginLeft: '10px',
- // marginRight: '10px',
- // height: '67px',
- // bottom: '10px'
- // }
-
- // console.log(this.props)
- // console.log('DATE', dateFormatted)
-
+ console.log(this.props.selectedDate, this.props.dateFormatted, this.state.dateFormatted, this.props)
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}/> */}
- {/* new modular version - currently a shell */}
- <TimelineAxisContainer {...this.state} selectedDate={this.state.dateFormatted} updateDate={this.updateDate} />
+
{/* custom interval selector */}
<IntervalSelectorWidget
@@ -135,6 +142,52 @@ class Timeline extends React.Component {
<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>
</React.Fragment>
:
null
diff --git a/web/js/date/timeline-input.js b/web/js/date/timeline-input.js
index 08230c628..b29d4ddda 100644
--- a/web/js/date/timeline-input.js
+++ b/web/js/date/timeline-input.js
@@ -31,7 +31,7 @@ export function timelineInput(models, config, ui) {
models.layers.events.on('subdaily-updated', updateMaxZoom);
$incrementBtn
.mousedown(function(e) {
- console.log(self.delta)
+ console.log(self.delta, self.interval)
e.preventDefault();
switch (ui.timeline.config.currentZoom) {
case 1:
@@ -186,14 +186,14 @@ export function timelineInput(models, config, ui) {
* @return {void}
*/
self.animateByIncrement = function(delta, increment) {
- console.log(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)
+ // console.log(tl.data.start(), nextTime, endTime, increment)
if (ui.timeline.config.currentZoom >= 4) {
if (tl.data.start() <= nextTime && nextTime <= endTime) {
models.date.add(increment, delta);
@@ -277,7 +277,7 @@ export function timelineInput(models, config, ui) {
$decrementBtn.removeClass('button-disabled');
}
- tl.pick.update();
+ // tl.pick.update();
};
var updateMaxZoom = function() {
@@ -290,7 +290,7 @@ export function timelineInput(models, config, ui) {
document.getElementById('timeline-header').classList.remove('subdaily');
}
self.reactComponent.setState({ maxZoom: model.maxZoom });
- model.events.trigger('update-timewheel');
+ // model.events.trigger('update-timewheel');
};
init();
diff --git a/web/js/date/timeline.js b/web/js/date/timeline.js
index 13581b1f9..5c4667356 100644
--- a/web/js/date/timeline.js
+++ b/web/js/date/timeline.js
@@ -5,6 +5,8 @@ import ReactDOM from 'react-dom';
import googleTagManager from 'googleTagManager';
import Timeline from '../components/timeline/timeline';
+import DateZoomChange from '../components/timeline/timeline-controls/date-zoom-change';
+
export function timeline(models, config, ui) {
var self = {};
var model = models.date;
@@ -24,11 +26,14 @@ export function timeline(models, config, ui) {
};
self.getWidth = function() {
+ let subdaily = models.layers.hasSubDaily();
self.width =
$(window).outerWidth(true) -
- $('#timeline-header').outerWidth(true) -
- $('#timeline-hide').outerWidth(true) -
+ // $('#timeline-header').outerWidth(true) -
+ // $('#timeline-hide').outerWidth(true) -
+ (subdaily ? 404 : 310) -
+ 20 -
self.margin.left -
self.margin.right +
28;
@@ -41,12 +46,12 @@ export function timeline(models, config, ui) {
self.toggle = function(now) {
var tl = $('#timeline-footer');
- var tlg = self.boundary;
- var gp = d3.select('#guitarpick');
+ // var tlg = self.boundary;
+ // var gp = d3.select('#guitarpick');
if (tl.is(':hidden')) {
var afterShow = function() {
- tlg.attr('style', 'clip-path:url("#timeline-boundary")');
- gp.attr('style', 'clip-path:url(#guitarpick-boundary);');
+ // tlg.attr('style', 'clip-path:url("#timeline-boundary")');
+ // gp.attr('style', 'clip-path:url(#guitarpick-boundary);');
};
if (now) {
tl.show();
@@ -56,8 +61,8 @@ export function timeline(models, config, ui) {
}
$('#timeline').removeClass('closed');
} else {
- tlg.attr('style', 'clip-path:none');
- gp.attr('style', 'display:none;clip-path:none');
+ // tlg.attr('style', 'clip-path:none');
+ // gp.attr('style', 'display:none;clip-path:none');
tl.hide('slow');
$('#timeline').addClass('closed');
}
@@ -100,42 +105,42 @@ export function timeline(models, config, ui) {
if (self.enabled) {
self.getWidth();
- self.svg
- .attr('width', self.width)
- .attr(
- 'viewBox',
- '0 9 ' +
- self.width +
- ' ' +
- (self.height + self.margin.top + self.margin.bottom + 26)
- );
-
- d3.select('#timeline-boundary rect').attr('width', self.width);
-
- d3.select('#guitarpick-boundary rect').attr(
- 'width',
- self.width + self.margin.left + self.margin.right
- );
+ // self.svg
+ // .attr('width', self.width)
+ // .attr(
+ // 'viewBox',
+ // '0 9 ' +
+ // self.width +
+ // ' ' +
+ // (self.height + self.margin.top + self.margin.bottom + 26)
+ // );
+
+ // d3.select('#timeline-boundary rect').attr('width', self.width);
+
+ // d3.select('#guitarpick-boundary rect').attr(
+ // 'width',
+ // self.width + self.margin.left + self.margin.right
+ // );
- self.axis.select('line:first-child').attr('x2', self.width);
+ // self.axis.select('line:first-child').attr('x2', self.width);
}
self.reactComponent.setState({ width: self.getWidth() });
};
self.setClip = function() {
// This is a hack until Firefox fixes their svg rendering problems
- d3.select('#timeline-footer svg > g:nth-child(2)').attr(
- 'visibility',
- 'hidden'
- );
- d3.select('#timeline-footer svg > g:nth-child(2)').attr('style', '');
- setTimeout(function() {
- d3.select('#timeline-footer svg > g:nth-child(2)').attr(
- 'style',
- 'clip-path:url("#timeline-boundary")'
- );
- d3.select('#timeline-footer svg > g:nth-child(2)').attr('visibility', '');
- }, 50);
+ // d3.select('#timeline-footer svg > g:nth-child(2)').attr(
+ // 'visibility',
+ // 'hidden'
+ // );
+ // d3.select('#timeline-footer svg > g:nth-child(2)').attr('style', '');
+ // setTimeout(function() {
+ // d3.select('#timeline-footer svg > g:nth-child(2)').attr(
+ // 'style',
+ // 'clip-path:url("#timeline-boundary")'
+ // );
+ // d3.select('#timeline-footer svg > g:nth-child(2)').attr('visibility', '');
+ // }, 50);
};
// var changeDate = (date) => {
@@ -161,26 +166,30 @@ export function timeline(models, config, ui) {
};
var setIntervalInput = (intervalValue, zoomLevel) => {
- // console.log(self.input.delta)
+ console.log(self.input.delta)
self.input.delta = intervalValue;
self.input.interval = zoomLevel;
let zoomCustomText = document.querySelector('#zoom-custom');
zoomCustomText.textContent = `${intervalValue} ${zoomLevel.toUpperCase().substr(0, 3)}`;
- console.log(self)
+ // console.log(self)
}
var getInitialProps = () => {
// console.log(self)
+ let selectedDate = models.date[models.date.activeDate];
+ let subdaily = models.layers.hasSubDaily();
return {
width: self.width,
+ subdailyLayers: subdaily,
height: self.height,
- selectedDate: models.date[models.date.activeDate],
+ selectedDate: selectedDate,
// changeDate: changeDate,
timeScale: 'day',
incrementDate: incrementDate,
updateDate: updateDate,
- setIntervalInput: setIntervalInput
+ setIntervalInput: setIntervalInput,
+ dateFormatted: new Date(selectedDate).toISOString()
};
};
@@ -189,69 +198,79 @@ export function timeline(models, config, ui) {
let initialProps = getInitialProps();
self.reactComponent = ReactDOM.render(
React.createElement(Timeline, initialProps),
- document.getElementById('timelineContainer')
+ document.getElementById('timeline')
);
- self.svg = d3
- .select('#timeline-footer')
- .append('svg:svg')
- .attr('width', self.width) // + margin.left + margin.right)
- .attr('height', self.height + self.margin.top + self.margin.bottom + 42)
- .attr('id', 'timeline-footer-svg')
- .attr(
- 'viewBox',
- '0 9 ' +
- self.width +
- ' ' +
- (self.height + self.margin.top + self.margin.bottom + 26)
- );
-
- self.svg
- .append('svg:defs')
- .append('svg:clipPath')
- .attr('id', 'timeline-boundary')
- .append('svg:rect')
- .attr('width', self.width) // + margin.left + margin.right)
- .attr('height', self.height + self.margin.top + self.margin.bottom);
-
- d3.select('#timeline-footer svg defs')
- .append('svg:clipPath')
- .attr('id', 'guitarpick-boundary')
- .append('svg:rect')
- .attr('width', self.width + self.margin.left + self.margin.right) // + margin.left + margin.right)
- .attr('height', self.height + self.margin.top + self.margin.bottom)
- .attr('x', -self.margin.left);
-
- self.boundary = self.svg
- .append('svg:g')
- .attr('clip-path', 'url(#timeline-boundary)')
- .attr('style', 'clip-path:url(#timeline-boundary)')
- .attr('transform', 'translate(0,1)');
-
- self.axis = self.boundary
- .append('svg:g')
- .attr('class', 'x axis')
- .attr('transform', 'translate(0,' + self.height + ')');
-
- self.axis
- .insert('line', ':first-child')
- .attr('x1', 0)
- .attr('x2', self.width); // +margin.left+margin.right);
-
- self.dataBars = self.boundary
- .insert('svg:g', '.x.axis')
- .attr('height', self.height)
- .classed('plot', true);
-
- self.verticalAxis = self.boundary
- .append('svg:g')
- .attr('class', 'y axis')
- .attr('transform', 'translate(0,0)');
- self.animboundary = self.svg
- .append('svg:g')
- .attr('clip-path', '#timeline-boundary')
- .attr('transform', 'translate(0,16)');
- self.animboundary.append('g').attr('id', 'wv-rangeselector-case');
+ // self.reactComponent = ReactDOM.render(
+ // React.createElement(Timeline, initialProps),
+ // document.getElementById('timelineContainer')
+ // );
+
+ // self.reactComponent2 = ReactDOM.render(
+ // React.createElement(DateZoomChange),
+ // document.getElementById('zoom-btn-container')
+ // );
+
+ // self.svg = d3
+ // .select('#timeline-footer')
+ // .append('svg:svg')
+ // .attr('width', self.width) // + margin.left + margin.right)
+ // .attr('height', self.height + self.margin.top + self.margin.bottom + 42)
+ // .attr('id', 'timeline-footer-svg')
+ // .attr(
+ // 'viewBox',
+ // '0 9 ' +
+ // self.width +
+ // ' ' +
+ // (self.height + self.margin.top + self.margin.bottom + 26)
+ // );
+
+ // self.svg
+ // .append('svg:defs')
+ // .append('svg:clipPath')
+ // .attr('id', 'timeline-boundary')
+ // .append('svg:rect')
+ // .attr('width', self.width) // + margin.left + margin.right)
+ // .attr('height', self.height + self.margin.top + self.margin.bottom);
+
+ // d3.select('#timeline-footer svg defs')
+ // .append('svg:clipPath')
+ // .attr('id', 'guitarpick-boundary')
+ // .append('svg:rect')
+ // .attr('width', self.width + self.margin.left + self.margin.right) // + margin.left + margin.right)
+ // .attr('height', self.height + self.margin.top + self.margin.bottom)
+ // .attr('x', -self.margin.left);
+
+ // self.boundary = self.svg
+ // .append('svg:g')
+ // .attr('clip-path', 'url(#timeline-boundary)')
+ // .attr('style', 'clip-path:url(#timeline-boundary)')
+ // .attr('transform', 'translate(0,1)');
+
+ // self.axis = self.boundary
+ // .append('svg:g')
+ // .attr('class', 'x axis')
+ // .attr('transform', 'translate(0,' + self.height + ')');
+
+ // self.axis
+ // .insert('line', ':first-child')
+ // .attr('x1', 0)
+ // .attr('x2', self.width); // +margin.left+margin.right);
+
+ // self.dataBars = self.boundary
+ // .insert('svg:g', '.x.axis')
+ // .attr('height', self.height)
+ // .classed('plot', true);
+
+ // self.verticalAxis = self.boundary
+ // .append('svg:g')
+ // .attr('class', 'y axis')
+ // .attr('transform', 'translate(0,0)');
+ // self.animboundary = self.svg
+ // .append('svg:g')
+ // .attr('clip-path', '#timeline-boundary')
+ // .attr('transform', 'translate(0,16)');
+ // self.animboundary.append('g').attr('id', 'wv-rangeselector-case');
};
var updateReactTimelineDate = function() {
@@ -268,7 +287,7 @@ export function timeline(models, config, ui) {
var updateTimeUi = function() {
updateReactTimelineDate();
self.input.update();
- self.pick.shiftView();
+ // self.pick.shiftView();
};
var onLayerUpdate = function() {
const layersContainSubdaily = models.layers.hasSubDaily();
@@ -276,7 +295,7 @@ export function timeline(models, config, ui) {
self.resize();
self.setClip();
if (subdaily !== layersContainSubdaily) {
- self.zoom.refresh();
+ // self.zoom.refresh();
self.input.update();
subdaily = layersContainSubdaily;
}
@@ -286,11 +305,11 @@ export function timeline(models, config, ui) {
models.layers.events.trigger('toggle-subdaily');
subdaily = models.layers.hasSubDaily();
drawContainers();
- let timelineCase = document.getElementById('timeline');
- timelineCase.addEventListener('wheel', function(e) {
- e.preventDefault();
- e.stopPropagation();
- });
+ // let timelineCase = document.getElementById('timeline');
+ // timelineCase.addEventListener('wheel', function(e) {
+ // e.preventDefault();
+ // e.stopPropagation();
+ // });
$('#zoom-custom').on('click', function() {
self.reactComponent.setState({
@@ -313,16 +332,16 @@ export function timeline(models, config, ui) {
self.x = d3.time.scale.utc();
- self.xAxis = d3.svg
- .axis()
- .orient('bottom')
- .tickSize(-self.height)
- .tickPadding(5);
+ // self.xAxis = d3.svg
+ // .axis()
+ // .orient('bottom')
+ // .tickSize(-self.height)
+ // .tickPadding(5);
- self.axisZoom = d3.behavior
- .zoom()
- .scale(1)
- .scaleExtent([1, 1]);
+ // self.axisZoom = d3.behavior
+ // .zoom()
+ // .scale(1)
+ // .scaleExtent([1, 1]);
self.resize();