Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

added rangeslector boundary calculator

Benjamin7e1f2480a215
diff --git a/web/js/animation/wv.anim.rangeselect.js b/web/js/animation/wv.anim.rangeselect.js
index 71b83a096..6eb8fc960 100644
--- a/web/js/animation/wv.anim.rangeselect.js
+++ b/web/js/animation/wv.anim.rangeselect.js
@@ -19,10 +19,11 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
var self = {};
var model;
var timeline = ui.timeline;
- var widgetOptions = ui.anim.options
+ var widgetOptions = ui.anim.options;
var rangeSelectionFactory = React.createFactory(Animate.RangeSelector);
var $mountLocation = $('#wv-rangeselector-case')[0];
var reactGlobal = {};
+ var $footer = $('#timeline-footer');
ui.anim.rangeOptions = ui.anim.rangeOptions || {};
@@ -45,14 +46,14 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
endLocation = self.getLocationFromStringDate(model.rangeState.endDate);
} else {
startLocation = animEndLocation - 100;
- endLocation = animEndLocation
+ endLocation = animEndLocation;
self.updateRange(startLocation, endLocation);
}
self.options = {
startLocation: startLocation, // or zero
endLocation: endLocation,
- max: timeline.x(timeline.data.end()),
+ max: self.getMaxWidth(),
startColor: '#40a9db',
endColor: '#295f92',
rangeColor: '#45bdff',
@@ -63,32 +64,41 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
onDragStop: self.updateRange
};
model.events.on('timeline-change', self.update);
- model.events.on('change', self.update)
+ model.events.on('change', self.update);
self.render(self.options);
};
self.render = function(options) {
self.reactComponent = ReactDOM.render(rangeSelectionFactory(options), $mountLocation);
- }
+ };
self.getLocationFromStringDate = function(date) {
return timeline.x(new Date(date));
- }
+ };
self.showDateOnDrag = function(firstLocation, secondLocation) {
var date = timeline.x.invert(firstLocation);
- timeline.pick.hoverDate(date)
-
- }
+ timeline.pick.hoverDate(date);
+ };
self.update = function() { // being called from timeline.config.js
var props = self.updateOptions();
self.reactComponent.setState(props);
+ };
+ self.getMaxWidth = function() {
+ var $elWidth = $footer.width();
+ var $dataWidth = timeline.x(timeline.data.end());
+ if($elWidth > $dataWidth) {
+ return $dataWidth;
+ }
+ return $elWidth;
}
self.updateOptions = function() {
+ var max;
var state = model.rangeState;
var props = {};
props.startLocation = self.getLocationFromStringDate(state.startDate);
props.endLocation = self.getLocationFromStringDate(state.endDate);
- props.max = timeline.x(timeline.data.end());
+ props.max = self.getMaxWidth();
+
return props;
- }
+ };
self.updateRange = function(startLocation, EndLocation) {
var startDate = timeline.x.invert(startLocation);
var endDate = timeline.x.invert(EndLocation);
@@ -98,8 +108,7 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
timeline.ticks.label.remove();
model.events.trigger('change');
- }
-
+ };
self.init();
return self;
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/web/js/animation/wv.anim.widget.js b/web/js/animation/wv.anim.widget.js
index 4894cd47a..05650cd80 100644
--- a/web/js/animation/wv.anim.widget.js
+++ b/web/js/animation/wv.anim.widget.js
@@ -16,7 +16,7 @@ var wv = wv || {};
wv.anim = wv.anim || {};
wv.anim.widget = wv.anim.widget || function(models, config, ui) {
- var zooms = ['yearly', 'monthly', 'daily']
+ var zooms = ['yearly', 'monthly', 'daily'];
var self = {};
var timeline = ui.timeline;
var model = models.anim;
@@ -59,13 +59,13 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
header: 'Animate Map in ' + zooms[timeline.config.currentZoom - 1] + ' Increments' // config.currentZoom is a number: 1,2,3
});
model.rangeState.playIndex = null;
- }
+ };
self.dateUpdate = function(startDate, endDate) {
model.rangeState.startDate = wv.util.toISOStringDate(startDate) || 0;
model.rangeState.endDate = wv.util.toISOStringDate(endDate);
model.events.trigger('change');
model.events.trigger('datechange');
- }
+ };
self.toggleAnimationWidget = function() {
return $timelineFooter.toggleClass('wv-anim-active');
};
@@ -76,12 +76,12 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
self.onRateChange = function(speed) {
model.rangeState.speed = speed;
model.events.trigger('change');
- }
+ };
self.onPressPause = function() {
var state = model.rangeState;
state.playing = false;
model.events.trigger('change');
- }
+ };
/*
* adjust state when loop is pressed
*/
@@ -89,10 +89,10 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
var state = model.rangeState;
state.loop = loop;
model.events.trigger('change');
- }
+ };
self.onPressGIF = function() {
model.events.trigger('gif-click');
- }
+ };
self.init();
return self;
-}
\ No newline at end of file
+};
\ No newline at end of file