Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

2399 zero out values for time units one step below the current interval before animation playback. this fixes a bug that caused caching to hang and also, when looping, keeps the initial playthrough in sync with the subsequent playthroughs

Jason Kent5e0044847fa5
diff --git a/web/js/components/animation-widget/play-queue.js b/web/js/components/animation-widget/play-queue.js
index 521d42a49..616f45aea 100644
--- a/web/js/components/animation-widget/play-queue.js
+++ b/web/js/components/animation-widget/play-queue.js
@@ -42,6 +42,29 @@ class PlayAnimation extends React.Component {
}
}
+ /**
+ * Clear out value for time unit one step below playback interval
+ * This essentially snaps the playback interval to the correct value so that
+ * the current datetime is properly snapped to the start datetime. This avoids
+ * issues where the first playback is not in sync with subsequent loops due to a
+ * non-snapped initial current time.
+ *
+ * @param {*} date
+ * @param {*} interval
+ */
+ zeroForInterval(date, interval) {
+ switch (interval) {
+ case 'day':
+ return new Date(date.setUTCHours(0));
+ case 'hour':
+ return new Date(date.setUTCMinutes(0));
+ case 'minute':
+ return new Date(date.setUTCSeconds(0));
+ default:
+ return date;
+ }
+ }
+
/**
* Determines whether to start at
* current date or to start at the
@@ -50,9 +73,12 @@ class PlayAnimation extends React.Component {
* @returns {string} ISO string Date
*/
getStartDate() {
- const { endDate, startDate, currentDate } = this.props;
- if (currentDate > startDate && this.nextDate(currentDate) < endDate) {
- return util.toISOStringSeconds(this.nextDate(currentDate));
+ const { endDate, startDate, currentDate, interval } = this.props;
+ const zeroedDate = this.zeroForInterval(currentDate, interval);
+ const nextDate = this.nextDate(zeroedDate);
+
+ if (currentDate > startDate && nextDate < endDate) {
+ return util.toISOStringSeconds(nextDate);
}
return util.toISOStringSeconds(startDate);
}
diff --git a/web/js/util/util.js b/web/js/util/util.js
index d97527e60..3b7b18c23 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -408,7 +408,6 @@ export default (function(self) {
date.setUTCMinutes(0);
date.setUTCSeconds(0);
date.setUTCMilliseconds(0);
-
return date;
};