Interactive interface for browsing global, full-resolution satellite imagery
Set min/max for increment buttons based on zoom level
ZachTRicec5d668b064ad
diff --git a/web/js/app.js b/web/js/app.jsindex 4d3ade8f2..fedb3884e 100644--- a/web/js/app.js+++ b/web/js/app.js@@ -378,7 +378,7 @@ class App extends React.Component {models.proj = projectionModel(config);models.palettes = palettesModel(models, config);- models.layers = layersModel(models, config);+ models.layers = layersModel(models, config, ui);models.date = dateModel(models, config, {initial: initialDate});@@ -457,8 +457,8 @@ class App extends React.Component {ui.timeline.ticks = timelineTicks(models, config, ui);ui.timeline.pick = timelinePick(models, config, ui);ui.timeline.pan = timelinePan(models, config, ui);- ui.timeline.config = timelineConfig(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 WIDGETdiff --git a/web/js/date/config.js b/web/js/date/config.jsindex d0a6ead6d..4f57d191a 100644--- a/web/js/date/config.js+++ b/web/js/date/config.js@@ -1097,6 +1097,7 @@ export function timelineConfig(models, config, ui) {model.selectedZoom = level;model.events.trigger('zoom-change');model.events.trigger('timeline-change');+ ui.timeline.input.update();};var switchZoom = function(zoomLevel) {diff --git a/web/js/date/timeline-input.js b/web/js/date/timeline-input.jsindex 97a4bf35d..93309cb9b 100644--- a/web/js/date/timeline-input.js+++ b/web/js/date/timeline-input.js@@ -182,12 +182,19 @@ export function timelineInput(models, config, ui) {* @return {void}*/var animateByIncrement = function(delta, increment) {- var endDate = models.layers.lastDate();+ var endTime = models.layers.lastDate();+ var endDate = util.today();self.delta = Math.abs(delta);function animate() {var nextTime = getNextTimeSelection(delta, increment);- if (tl.data.start() <= nextTime <= endDate) {- models.date.add(increment, delta);+ if (ui.timeline.config.currentZoom >= 4) {+ if ((tl.data.start() <= nextTime) && (nextTime <= endTime)) {+ models.date.add(increment, delta);+ }+ } else {+ if ((tl.data.start() <= nextTime) && (nextTime <= endDate)) {+ models.date.add(increment, delta);+ }}animator = setTimeout(animate, self.delay);}@@ -209,29 +216,31 @@ export function timelineInput(models, config, ui) {* @return {Object} JS Date Object*/var getNextTimeSelection = function(delta, increment) {+ var prevDate = model.selected;+switch (increment) {case 'year':return new Date(- new Date(model.selected).setUTCFullYear(- model.selected.getUTCFullYear() + increment+ new Date(prevDate).setUTCFullYear(+ prevDate.getUTCFullYear() + delta));case 'month':return new Date(- new Date(model.selected).setUTCMonth(- model.selected.getUTCMonth() + increment+ new Date(prevDate).setUTCMonth(+ prevDate.getUTCMonth() + delta));case 'day':return new Date(- new Date(model.selected).setUTCDate(- model.selected.getUTCDate() + increment+ new Date(prevDate).setUTCDate(+ prevDate.getUTCDate() + delta));case 'minute':return new Date(- new Date(model.selected).setUTCMinutes(- model.selected.getUTCMinutes() + increment+ new Date(prevDate).setUTCMinutes(+ prevDate.getUTCMinutes() + delta));}diff --git a/web/js/layers/model.js b/web/js/layers/model.jsindex 7158f6ca4..3ceaec5a4 100644--- a/web/js/layers/model.js+++ b/web/js/layers/model.js@@ -8,7 +8,7 @@ import lodashCloneDeep from 'lodash/cloneDeep';import util from '../util/util';import googleTagManager from 'googleTagManager';-export function layersModel(models, config) {+export function layersModel(models, config, ui) {var self = {};self.activeLayers = 'active';self.loaded = false;@@ -200,11 +200,11 @@ export function layersModel(models, config) {self.lastDate = function () {var endDate;var layersDateRange = self.dateRange();- var now = util.today();+ var now = util.now();if (layersDateRange && layersDateRange.end > now) {endDate = layersDateRange.end;} else {- endDate = util.today();+ endDate = now;}return endDate;};