Interactive interface for browsing global, full-resolution satellite imagery
backend functionality for animation is done, ready to work on UI
IamTechknowbbda5e797b54
diff --git a/web/js/date/wv.date.anim.js b/web/js/date/wv.date.anim.jsindex 2e0098242..c7181f88b 100644--- a/web/js/date/wv.date.anim.js+++ b/web/js/date/wv.date.anim.js@@ -61,29 +61,42 @@};var prepareFrame = function() {- if ( !self.active ) {+ if ( !self.active )return;- }+notify("prepare", self);var amount = ( self.direction === "forward" ) ?self.delta : -self.delta;var newDate = wv.util.dateAdd(model.selected, self.interval, amount);ui.preload(newDate);- timer = setTimeout(function() { //this function is called once after 500 ms++ //control animation if enabled. set before next imagery load+ if(doAnimation) days++;++ //if custom animation, change delay here+ self.delay = doAnimation ? animSpeed : self.delay;++ timer = setTimeout(function() { //this function is called once either after 500 ms or animation delayadvance(newDate);}, self.delay);- days++;};var advance = function(newDate) {notify("advance");var updated = model.select(newDate);- if ( !updated || days >= 4 ) { //do this 5 times- days = 0;++ //determine if animation should stop+ if(doAnimation && days >= animDuration - 1 ) {+ days = animDuration = 0;+ doAnimation = false;+ self.delay = 500;self.stop();- } else {- prepareFrame();}++ if (!updated)+ self.stop();+ else+ prepareFrame();};var notify = ( options.debug ) ? console.log : function() {};diff --git a/web/js/date/wv.date.timeline.input.js b/web/js/date/wv.date.timeline.input.jsindex 6eb08ab42..c9c34ff4e 100644--- a/web/js/date/wv.date.timeline.input.js+++ b/web/js/date/wv.date.timeline.input.js@@ -16,6 +16,10 @@ var wv = wv || {};wv.date = wv.date || {};wv.date.timeline = wv.date.timeline || {};+var doAnimation = false; //global variable to control animation+var animDuration = 0; //control how long animation is+var animSpeed = 0; //control how fast animation is in milliseconds+/*** Implements the date input*@@ -29,8 +33,6 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)var self = {};var timer, rollingDate;-- var daysCount = 0;var $incrementBtn = $("#right-arrow-group");var $decrementBtn = $("#left-arrow-group");@@ -281,13 +283,20 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)break;case wv.util.key.UP://Start an animation that repeats every sec but resets after 5 times. We need global variable to keep track- //var myVar = setInterval(function(){- animateReverse("day");+ doAnimation = true; //set a flag+ animDuration = 10;+ animSpeed = 100;+ animateReverse("day");event.preventDefault();- //}, 1000);-break;-+ case wv.util.key.DOWN:+ //Start animation to go forward+ doAnimation = true;+ animDuration = 10;+ animSpeed = 250;+ animateForward("day");+ event.preventDefault();+ break;}}).keyup(function(event) {@@ -297,7 +306,6 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)switch ( event.keyCode ) {case wv.util.key.LEFT:case wv.util.key.RIGHT:- console.log("Animation stopped");animateEnd();event.preventDefault();break;