Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

limit custom state saving only if custom is selected at permalink creation, disabled left right arrows based on selected increment and interval to accommodate custom, cleanup debug animation draggers, minor css

Edward Platoac8e805402a0
diff --git a/web/css/dateselector.css b/web/css/dateselector.css
index 6f6097ccd..680322fb9 100644
--- a/web/css/dateselector.css
+++ b/web/css/dateselector.css
@@ -87,6 +87,10 @@
height: 10px;
}
+.zoom-level-change-arrows .date-arrows {
+ height: 13px;
+}
+
.wv-date-selector-widget .date-arrows svg, .date-arrows svg {
vertical-align: top;
display: block;
@@ -94,7 +98,7 @@
}
.wv-date-selector-widget .date-arrows svg path, .date-arrows svg path {
- fill: #444;
+ fill: #666;
}
.wv-date-selector-widget .input-wrapper:hover .date-arrows:hover svg path, .date-arrows:hover svg path {
@@ -110,7 +114,8 @@
}
.wv-date-selector-widget .date-arrows:hover,
-.wv-date-selector-widget > .button-action-group:hover {
+.wv-date-selector-widget > .button-action-group:hover,
+.zoom-level-change-arrows .date-arrows:hover {
background-color: #fff;
cursor: pointer;
}
diff --git a/web/css/timeline.css b/web/css/timeline.css
index a275841c4..231da0ad1 100644
--- a/web/css/timeline.css
+++ b/web/css/timeline.css
@@ -299,7 +299,7 @@ g.plot rect.data-bar-invisible {
}
#timeline-header .date-arrows svg path {
- fill: #444;
+ fill: #666;
}
#timeline-header .input-wrapper:hover .date-arrows:hover svg path {
@@ -437,6 +437,7 @@ g.plot rect.data-bar-invisible {
#zoom-btn-container-axis .wv-zoom-tooltip {
display: block;
/* width: 80px; */
+ width: 100%;
margin-left: auto;
margin-right: auto;
padding: 4px;
@@ -454,7 +455,7 @@ g.plot rect.data-bar-invisible {
position: absolute;
bottom: 100%;
border-bottom: 8px solid transparent;
- width: 150px;
+ width: 100px;
z-index: 10;
}
@@ -462,6 +463,7 @@ g.plot rect.data-bar-invisible {
/* display: none; */
position: absolute;
bottom: 100%;
+ width: 75px;
/* border-bottom: 8px solid transparent; */
z-index: 10;
}
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index ae4fe67aa..4fe526be0 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -1157,6 +1157,7 @@ class TimelineAxis extends React.Component {
let deltaXEnd = endLocation - this.state.animationEndLocation;
let animationEndLocationDate = this.props.animEndLocationDate;
+ // if start or end dragger has moved
if (deltaXStart !== 0 || deltaXEnd !== 0) {
let diffZeroValues = timeScaleOptions[timeScale].timeAxis.scaleMs;
// get startDate for diff calculation
@@ -1172,7 +1173,7 @@ class TimelineAxis extends React.Component {
if (deltaXStart !== 0) { // update new start date
if (!diffZeroValues) { // month or year
let startDraggerPositionRelativeToFrontDate = this.state.animationStartLocation - this.state.position - this.state.currentTransformX + deltaXStart;
- let gridWidthCoef = startDraggerPositionRelativeToFrontDate/gridWidth;
+ let gridWidthCoef = startDraggerPositionRelativeToFrontDate / gridWidth;
let draggerDateAdded = frontDate.clone().add((Math.floor(gridWidthCoef)), timeScale);
let daysCount;
if (timeScale === 'year') {
@@ -1193,7 +1194,7 @@ class TimelineAxis extends React.Component {
if (deltaXEnd !== 0) { // update new end date
if (!diffZeroValues) { // month or year
let endDraggerPositionRelativeToFrontDate = this.state.animationEndLocation - this.state.position - this.state.currentTransformX + deltaXEnd;
- let gridWidthCoef = endDraggerPositionRelativeToFrontDate/gridWidth;
+ let gridWidthCoef = endDraggerPositionRelativeToFrontDate / gridWidth;
let draggerDateAdded = frontDate.clone().add((Math.floor(gridWidthCoef)), timeScale);
let daysCount;
if (timeScale === 'year') {
@@ -1211,6 +1212,7 @@ class TimelineAxis extends React.Component {
}
}
+ // ! controlled within range-selection component using max props
// prevent draggers to be dragger BEFORE start date limit
if (moment.utc(animationEndLocationDate).isBefore(this.props.timelineStartDateLimit, timeScale)) {
endLocation = this.state.animationEndLocation;
@@ -1223,7 +1225,7 @@ class TimelineAxis extends React.Component {
// prevent draggers to be dragger AFTER end date limit
if (moment.utc(animationEndLocationDate).isAfter(this.props.timelineEndDateLimit, timeScale)) {
endLocation = this.state.animationEndLocation;
- animationEndLocationDate = this.props.timelineEndDateLimit;
+ animationEndLocationDate = this.props.animEndLocationDate;
} else if (moment.utc(animationStartLocationDate).isAfter(this.props.timelineEndDateLimit, timeScale)) {
startLocation = this.state.animationStartLocation;
animationStartLocationDate = this.props.timelineEndDateLimit;
diff --git a/web/js/components/timeline/timeline-controls/date-change-arrows.js b/web/js/components/timeline/timeline-controls/date-change-arrows.js
index 89e1bdaeb..cd30a2728 100644
--- a/web/js/components/timeline/timeline-controls/date-change-arrows.js
+++ b/web/js/components/timeline/timeline-controls/date-change-arrows.js
@@ -6,7 +6,7 @@ class DateChangeArrows extends PureComponent {
<div>
{/* LEFT ARROW */}
<div
- className="button-action-group"
+ className={`button-action-group ${this.props.leftArrowDisabled ? 'button-disabled' : ''}`}
id="left-arrow-group"
title="Click and hold to animate backwards"
onMouseDown={this.props.leftArrowDown}
@@ -22,7 +22,7 @@ class DateChangeArrows extends PureComponent {
{/* RIGHT ARROW */}
<div
- className="button-action-group"
+ className={`button-action-group ${this.props.rightArrowDisabled ? 'button-disabled' : ''}`}
id="right-arrow-group"
title="Click and hold to animate forwards"
onMouseDown={this.props.rightArrowDown}
diff --git a/web/js/components/timeline/timeline.js b/web/js/components/timeline/timeline.js
index 95019df31..74882bdc6 100644
--- a/web/js/components/timeline/timeline.js
+++ b/web/js/components/timeline/timeline.js
@@ -45,7 +45,9 @@ class Timeline extends React.Component {
timelineHidden: false,
parentOffset: '',
timelineStartDateLimit: '',
- timelineEndDateLimit: ''
+ timelineEndDateLimit: '',
+ leftArrowDisabled: '',
+ rightArrowDisabled: ''
};
}
@@ -91,6 +93,34 @@ class Timeline extends React.Component {
this.props.incrementDate(Number(delta * multiplier), this.state.timeScaleChangeUnit)
}
+ // checkLeftArrowDisabled
+ checkLeftArrowDisabled = () => {
+ let previousPastDateBasedOnIncrement;
+ if (this.state.draggerSelected === 'selected') {
+ previousPastDateBasedOnIncrement = moment.utc(this.state.dateFormatted).subtract(this.state.intervalChangeAmt, this.state.timeScaleChangeUnit);
+ } else {
+ previousPastDateBasedOnIncrement = moment.utc(this.state.dateFormattedB).subtract(this.state.intervalChangeAmt, this.state.timeScaleChangeUnit);
+ }
+ console.log(previousPastDateBasedOnIncrement.isSameOrBefore(this.state.timelineStartDateLimit))
+ this.setState({
+ leftArrowDisabled: previousPastDateBasedOnIncrement.isSameOrBefore(this.state.timelineStartDateLimit)
+ })
+ }
+
+ // checkRightArrowDisabled
+ checkRightArrowDisabled = () => {
+ let nextFutureDateBasedOnIncrement;
+ if (this.state.draggerSelected === 'selected') {
+ nextFutureDateBasedOnIncrement = moment.utc(this.state.dateFormatted).add(this.state.intervalChangeAmt, this.state.timeScaleChangeUnit);
+ } else {
+ nextFutureDateBasedOnIncrement = moment.utc(this.state.dateFormattedB).add(this.state.intervalChangeAmt, this.state.timeScaleChangeUnit);
+ }
+ console.log(nextFutureDateBasedOnIncrement.isSameOrAfter(this.state.timelineEndDateLimit))
+ this.setState({
+ rightArrowDisabled: nextFutureDateBasedOnIncrement.isSameOrAfter(this.state.timelineEndDateLimit)
+ })
+ }
+
// open animation dialog
clickAnimationButton = () => {
this.props.clickAnimationButton();
@@ -131,7 +161,9 @@ class Timeline extends React.Component {
timelineEndDateLimit: this.props.timelineEndDateLimit,
animStartLocationDate: this.props.animStartLocationDate,
animEndLocationDate: this.props.animEndLocationDate,
- isAnimationWidgetOpen: this.props.isAnimationWidgetOpen
+ isAnimationWidgetOpen: this.props.isAnimationWidgetOpen,
+ leftArrowDisabled: this.checkLeftArrowDisabled(),
+ rightArrowDisabled: this.checkRightArrowDisabled()
});
}
@@ -139,8 +171,24 @@ class Timeline extends React.Component {
// return true;
// }
- // componentDidUpdate(prevProps, prevState) {
- // }
+ componentDidUpdate(prevProps, prevState) {
+ if (this.state.intervalChangeAmt !== prevState.intervalChangeAmt || this.state.timeScaleChangeUnit !== prevState.timeScaleChangeUnit) {
+ console.log('tester')
+ this.checkLeftArrowDisabled();
+ this.checkRightArrowDisabled();
+ }
+ if (this.state.draggerSelected === 'selected') {
+ if (this.state.dateFormatted !== prevState.dateFormatted) {
+ this.checkLeftArrowDisabled();
+ this.checkRightArrowDisabled();
+ }
+ } else if (this.state.draggerSelected === 'selectedB') {
+ if (this.state.dateFormattedB !== prevState.dateFormattedB) {
+ this.checkLeftArrowDisabled();
+ this.checkRightArrowDisabled();
+ }
+ }
+ }
render() {
// console.log(this.state.selectedDate, this.state.dateFormatted)
@@ -170,8 +218,10 @@ class Timeline extends React.Component {
<DateChangeArrows
leftArrowDown={() => this.incrementDate(-1)}
leftArrowUp={this.props.stopper}
+ leftArrowDisabled={this.state.leftArrowDisabled}
rightArrowDown={() => this.incrementDate(1)}
rightArrowUp={this.props.stopper}
+ rightArrowDisabled={this.state.rightArrowDisabled}
/>
</div>
diff --git a/web/js/date/model.js b/web/js/date/model.js
index b9ac9d12d..9fbce69ce 100644
--- a/web/js/date/model.js
+++ b/web/js/date/model.js
@@ -198,18 +198,20 @@ export function dateModel(models, config, spec) {
state.t1 = dateToStringForUrl(self.selectedB);
}
}
- // custom interval delta and interval
+ // interval
if (self.interval) {
state.inti = self.interval.toString();
}
- if (self.customInterval) {
- state.intci = self.customInterval.toString();
- }
- if (self.customDelta) {
- state.intcd = self.customDelta.toString();
- }
+ // only if custom selected, save custom interval and delta state
if (self.customSelected) {
- state.intcs = self.customSelected.toString();
+ if (self.customInterval) {
+ state.intci = self.customInterval.toString();
+ }
+ // if delta is 1, then it won't be saved since this would be a default
+ if (self.customDelta && self.customDelta > 1) {
+ state.intcs = self.customSelected.toString();
+ state.intcd = self.customDelta.toString();
+ }
}
};