1
0
Fork 0

Phi: nicer scroll animation for METAR widget

This commit is contained in:
Torsten Dreyer 2015-03-06 09:36:09 +01:00
parent 78edadf935
commit 52966c8ee3

View file

@ -22,20 +22,30 @@ define([
});
self.textLength = 20;
self.timeout = 300;
self.timerId = setInterval(function() {
self.timerId = 0;
self.longTimeout = 1500;
self.shortTimeout = 50;
function scrollText ( id ){
if( id != self.timerId )
return;
var t = self.metar() + " " + self.metar();
var a = self.textStart;
var b = a+self.textLength;
self.scrolledMetar( t.substring(a,b) );
var timeout = t.charAt(a) == ' ' ? self.longTimeout : self.shortTimeout;
if( ++a >= self.metar().length )
a = 0;
self.textStart = a;
}, self.timeout );
setTimeout(function() { scrollText(id); }, timeout );
}
scrollText( ++self.timerId );
}
ViewModel.prototype.dispose = function() {
clearInterval( self.timerId );
self.timerId++;
}
// Return component definition