Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Adjust timeline styles to work with subdaily toggle - Adjusted timeline CSS to always be flexible and animate correctly when timeline is hidden or shown - Created `subdailyCheck` method to detect if there is a subdaily layer in the active layer list - Created a `toggleSubdaily` method to hide add/remove the `.subdaily` class in the timeline if `subdailyCheck` returns true - Registered event listened for `subdailyCheck` method - Added a trigger event on timeline init to set subdaily class on timeline (adjusts the width of the time select area) - Added check if zoom level parameter is within bounds, if not set zoom to 3 by default

ZachTRice9bf47fee1fea
diff --git a/web/css/timeline.css b/web/css/timeline.css
index ec5de945c..5cae37a60 100644
--- a/web/css/timeline.css
+++ b/web/css/timeline.css
@@ -3,13 +3,12 @@
}
#timeline {
+ background: transparent;
position: absolute;
bottom: 10px;
left: 0;
right: 0;
width: 100%;
- background: transparent;
- min-width: 286px;
}
.timeline-inner {
@@ -17,6 +16,7 @@
border: 1px solid #333;
background: rgba(40, 40, 40, 0.9);
border-radius: 5px;
+ display: inline-block;
margin-left: 10px;
margin-right: 10px;
}
@@ -374,7 +374,6 @@ g.plot rect.data-bar-invisible {
display: inline-block;
position: absolute;
bottom: 65px;
- z-index: 9999;
vertical-align: middle;
overflow-y: hidden;
height: 54px;
diff --git a/web/js/date/config.js b/web/js/date/config.js
index 235d608dd..aa60b910e 100644
--- a/web/js/date/config.js
+++ b/web/js/date/config.js
@@ -31,9 +31,9 @@ export function timelineConfig(models, config, ui) {
var altEnd;
var paddedRange;
+ // Needs reworked. Repeated from layers/active/toggleSubdaily
var activeLayers = models.layers.active;
var subdailyFound = false;
-
for (var i = 0; i < activeLayers.length; i++) {
switch (activeLayers[i].period) {
case 'subdaily':
@@ -42,15 +42,9 @@ export function timelineConfig(models, config, ui) {
}
}
- if (!subdailyFound) {
- document.getElementById('zoom-minutes').style.display = 'none';
- document.getElementById('input-wrapper-hour').style.display = 'none';
- document.getElementById('input-wrapper-minute').style.display = 'none';
- document.getElementById('timeline-header').classList.remove('subdaily');
- self.currentZoom = 3;
- } else {
- document.getElementById('timeline-header').classList.add('subdaily');
- }
+ // If zoom is not within range, set it to level 3 (daily)
+ if (level > 4 || level < 0) level = 3;
+ if (!subdailyFound && (level > 3 || level < 0)) level = 3;
switch (level) {
case 1: // Year
diff --git a/web/js/date/timeline.js b/web/js/date/timeline.js
index 2b01fbc33..50de21070 100644
--- a/web/js/date/timeline.js
+++ b/web/js/date/timeline.js
@@ -10,7 +10,7 @@ export function timeline(models, config, ui) {
self.margin = {
top: 0,
- right: 30,
+ right: 50,
bottom: 20,
left: 30
};
@@ -27,7 +27,7 @@ export function timeline(models, config, ui) {
.outerWidth(true) -
$('#timeline-hide')
.outerWidth(true) -
- self.margin.left - self.margin.right - 22;
+ self.margin.left - self.margin.right - 2;
return self.width;
};
@@ -51,13 +51,13 @@ export function timeline(models, config, ui) {
tl.show('slow', afterShow);
}
$('#timeline')
- .css('right', '10px').css('width', '100%');
+ .removeClass('closed');
} else {
tlg.attr('style', 'clip-path:none');
gp.attr('style', 'display:none;clip-path:none');
tl.hide('slow');
$('#timeline')
- .css('right', 'auto').css('width', 'auto');
+ .addClass('closed');
}
};
@@ -128,21 +128,6 @@ export function timeline(models, config, ui) {
};
var drawContainers = function () {
- var activeLayers = models.layers.active;
- var subdailyFound = false;
-
- for (var i = 0; i < activeLayers.length; i++) {
- switch (activeLayers[i].period) {
- case 'subdaily':
- subdailyFound = true;
- break;
- }
- }
- if (!subdailyFound) {
- document.getElementById('timeline-header').classList.remove('subdaily');
- } else {
- document.getElementById('timeline-header').classList.add('subdaily');
- }
self.getWidth();
self.svg = d3.select('#timeline-footer')
@@ -199,6 +184,7 @@ export function timeline(models, config, ui) {
var init = function () {
var $timelineFooter = $('#timeline-footer');
+ models.layers.events.trigger('toggle-subdaily');
drawContainers();
if (!models.anim) { // Hack: margin if anim is present
@@ -249,6 +235,9 @@ export function timeline(models, config, ui) {
models.layers.events.on('change', function () {
self.data.set();
+ self.resize();
+ self.zoom.refresh();
+ self.setClip();
});
};
diff --git a/web/js/layers/active.js b/web/js/layers/active.js
index b11abe792..0b0d18834 100644
--- a/web/js/layers/active.js
+++ b/web/js/layers/active.js
@@ -11,7 +11,6 @@ import lodashEach from 'lodash/each';
import lodashEachRight from 'lodash/eachRight';
import util from '../util/util';
import wvui from '../ui/ui';
-import { timeline } from '../date/timeline';
import { layersInfo } from './info';
import { layersOptions } from './options';
import { palettesLegend } from '../palettes/legend';
@@ -30,7 +29,8 @@ export function layersActive(models, ui, config) {
.on('add', onLayerAdded)
.on('remove', onLayerRemoved)
.on('update', onLayerUpdate)
- .on('visibility', onLayerVisibility);
+ .on('visibility', onLayerVisibility)
+ .on('toggle-subdaily', toggleSubdaily);
models.proj.events
.on('select', onProjectionChanged);
models.palettes.events
@@ -393,7 +393,7 @@ export function layersActive(models, ui, config) {
if (legends[layer.id]) {
delete legends[layer.id];
}
- toggleSubdailyZoom();
+ toggleSubdaily();
sizeProductsTab();
};
@@ -404,36 +404,36 @@ export function layersActive(models, ui, config) {
if (layer.palette) {
renderLegendCanvas(layer);
}
- toggleSubdailyZoom();
+ toggleSubdaily();
model.events.trigger('timeline-change');
sizeProductsTab();
};
- var toggleSubdailyZoom = function () {
+ var subdailyCheck = function () {
var activeLayers = models.layers.active;
- var subdailyFound = false;
for (var i = 0; i < activeLayers.length; i++) {
switch (activeLayers[i].period) {
case 'subdaily':
- subdailyFound = true;
- break;
+ return true;
+ default:
+ return false;
}
}
+ };
- if (!subdailyFound) {
+ var toggleSubdaily = function () {
+ if (subdailyCheck()) {
+ document.getElementById('zoom-minutes').style.display = null;
+ document.getElementById('input-wrapper-hour').style.display = null;
+ document.getElementById('input-wrapper-minute').style.display = null;
+ document.getElementById('timeline-header').classList.add('subdaily');
+ } else {
document.getElementById('zoom-minutes').style.display = 'none';
document.getElementById('input-wrapper-hour').style.display = 'none';
document.getElementById('input-wrapper-minute').style.display = 'none';
document.getElementById('timeline-header').classList.remove('subdaily');
document.getElementById('zoom-days').click(); // Switch back to 'Days' view
- models.date.events.trigger('resize');
- } else {
- document.getElementById('zoom-minutes').style.display = null;
- document.getElementById('input-wrapper-hour').style.display = null;
- document.getElementById('input-wrapper-minute').style.display = null;
- document.getElementById('timeline-header').classList.add('subdaily');
- models.date.events.trigger('resize');
}
};