Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Fix ipad dragger bug #1286

Benjamin King4dc6a1b0d7bb
diff --git a/web/js/components/range-selection/dragger.js b/web/js/components/range-selection/dragger.js
index 84a4c81c6..370f98315 100644
--- a/web/js/components/range-selection/dragger.js
+++ b/web/js/components/range-selection/dragger.js
@@ -154,7 +154,8 @@ class TimelineDragger extends React.Component {
handleDrag(e, d) {
e.stopPropagation();
e.preventDefault();
- var position = this.state.position + e.movementX;
+ var deltaX = e.movementX || d.deltaX;
+ var position = this.state.position + deltaX;
this.props.onDrag(d.deltaX, this.props.id, d.x);
this.setState({ position: position });
}
diff --git a/web/js/date/compare-picks.js b/web/js/date/compare-picks.js
index 6da113392..b64dfb095 100644
--- a/web/js/date/compare-picks.js
+++ b/web/js/date/compare-picks.js
@@ -143,15 +143,18 @@ export function timelineCompare(models, config, ui) {
return timeline.x(util.roundTimeTenMinute(date));
};
var dateSelect = function(e, id, offsetX) {
+ const padding = 10;
var position = offsetX;
- if (position > max - 5) {
- position = max - 5;
- } else if (position <= 5) {
- position = 5;
+ if (position > max - padding) {
+ position = max - padding;
+ } else if (position <= padding) {
+ position = padding;
}
var date = timeline.x.invert(position);
- if (models.date[id] !== date) {
+ if (models.date[id] !== date && util.isValidDate(date)) {
models.date.select(date, id);
+ } else {
+ models.date.select(models.date[id], id);
}
};
var debounceDateSelect = lodashDebounce(dateSelect, DEBOUNCE_TIME);
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 34844ce6a..79c476b5b 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -222,7 +222,13 @@ export default (function (self) {
}
return date;
};
-
+ /**
+ * Test if is valid Date
+ * @param {Object} d | Date object
+ */
+ self.isValidDate = function(d) {
+ return d instanceof Date && !isNaN(d);
+ };
/**
* Parses a UTC ISO 8601 date to a non UTC date
*