Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

added anim widget annotation

Benjamin2ec850b2452c
diff --git a/web/js/animation/wv.anim.widget.js b/web/js/animation/wv.anim.widget.js
index e2dec6145..78eb1ec71 100644
--- a/web/js/animation/wv.anim.widget.js
+++ b/web/js/animation/wv.anim.widget.js
@@ -23,6 +23,16 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
var widgetFactory = React.createFactory(WVTC.AnimationWidget);
var $timelineFooter;
var $animateButton;
+ /*
+ * set listeners and initiate
+ * widget
+ *
+ * @method init
+ * @static
+ *
+ * @returns {void}
+ *
+ */
self.init = function() {
var speed = Number(model.rangeState.speed) || 5;
var Widget = widgetFactory({
@@ -106,6 +116,17 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
return;
}
};
+
+ /*
+ * Updates the state of the
+ * widget react component
+ *
+ * @method update
+ * @static
+ *
+ * @returns {void}
+ *
+ */
self.update = function() {
var state = model.rangeState;
self.reactComponent.setState({
@@ -116,13 +137,53 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
incrementArray: _.without(zooms, self.getIncrements()) // array of zooms without current zoom
});
};
+
+ /*
+ * Gets zoom increment
+ *
+ * @method getIncrements
+ * @static
+ *
+ * @returns {string} timeline interval
+ *
+ */
self.getIncrements = function() {
return zooms[timeline.config.currentZoom - 1];
};
+
+ /*
+ * A handler that responds to
+ * a zoom change and triggers
+ * the proper change
+ *
+ * @method onZoomSelect
+ * @static
+ *
+ * @param increment {number} Timeline zoom
+ * level number
+ *
+ * @returns {string} timeline interval
+ *
+ */
self.onZoomSelect = function(increment) {
var zoomLevel = _.indexOf(zooms, increment);
return timeline.config.zoom(zoomLevel + 1);
};
+
+ /*
+ * Updates the state and triggers
+ * change events.
+ *
+ * @method dateUpdate
+ * @static
+ *
+ * @param startDate {obj} Start Date
+ *
+ * @param endDate {obj} End Date
+ *
+ * @returns {void}
+ *
+ */
self.dateUpdate = function(startDate, endDate) {
model.rangeState.startDate = wv.util.toISOStringDate(startDate) || 0;
model.rangeState.endDate = wv.util.toISOStringDate(endDate);
@@ -130,6 +191,17 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
model.events.trigger('change');
model.events.trigger('datechange');
};
+
+ /*
+ * Toggles the visibility of the
+ * widget
+ *
+ * @method toggleAnimationWidget
+ * @static
+ *
+ * @returns {void}
+ *
+ */
self.toggleAnimationWidget = function() {
if(model.rangeState.state === 'off' && models.data.active) {
return; // Keep animation off when data-download is active.
@@ -139,35 +211,116 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
model.events.trigger('toggle-widget');
return $timelineFooter.toggleClass('wv-anim-active');
};
+
+ /*
+ * Press play button event handler
+ *
+ * @method onPressPlay
+ * @static
+ *
+ * @returns {void}
+ *
+ */
self.onPressPlay = function() {
model.rangeState.playing = true;
model.events.trigger('play');
};
+
+ /*
+ * Play button event handler
+ *
+ * @method onPressPlay
+ *
+ * @param speed {number} speed in frames
+ * per second
+ *
+ * @static
+ *
+ * @returns {void}
+ *
+ */
self.onRateChange = function(speed) {
model.rangeState.speed = speed;
model.events.trigger('change');
};
+
+ /*
+ * Pause button event handler
+ *
+ * @method onPressPause
+ *
+ * @static
+ *
+ * @returns {void}
+ *
+ */
self.onPressPause = function() {
var state = model.rangeState;
state.playing = false;
model.events.trigger('change');
};
+
+ /*
+ * Deactivate widget when data download
+ * is active
+ *
+ * @method onDataActivate
+ *
+ * @static
+ *
+ * @returns {void}
+ *
+ */
self.onDataActivate = function() {
$animateButton.addClass('wv-disabled-button');
$animateButton.prop('title', 'Animation feature is deactivated when data download feature is active');
};
+
+ /*
+ * reActivate widget when data download
+ * is deactivated
+ *
+ * @method onDataDeactivate
+ *
+ * @static
+ *
+ * @returns {void}
+ *
+ */
self.onDataDeactivate = function() {
$animateButton.removeClass('wv-disabled-button');
$animateButton.prop('title', 'Setup animation');
};
+
/*
- * adjust state when loop is pressed
+ * Adjusts state when loop is triggered
+ *
+ * @method onPressLoop
+ *
+ * @static
+ *
+ * @param loop {boolean}
+ *
+ * @returns {void}
+ *
*/
self.onPressLoop = function(loop) {
var state = model.rangeState;
state.loop = loop;
model.events.trigger('change');
};
+
+ /*
+ * Gif icon event handler: Triggers
+ * gif area selection
+ *
+ * @method onPressGIF
+ *
+ * @static
+ *
+ * @returns {void}
+ *
+ */
self.onPressGIF = function() {
model.events.trigger('gif-click');
};