Phi: nicer scroll animation for METAR widget
This commit is contained in:
parent
78edadf935
commit
52966c8ee3
1 changed files with 14 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue