(function(window,undefined){ window.Timeline=function(){ this.callbacks=[]; this.anims=[]; this.isPaused = false; var that=this; var tick=function(){ that.tick(); setTimeout(tick,10); }; tick(); } window.Timeline.prototype.loop=true; window.Timeline.prototype.length=10000; window.Timeline.prototype.started=0; /* starts the timeline */ window.Timeline.prototype.start=function(time){ if(!time) time=+new Date; this.started=time; this.lastTime=0; return this; } window.Timeline.prototype.pause=function(){ if (!this.isPaused) { this.pausetime=+new Date; this.started=false; } else { this.started+=+new Date-this.pausetime; this.started=true; } this.isPaused = !this.isPaused; } /* sets the lengh of the timeline in s */ window.Timeline.prototype.length=function(time){ this.length=time*1000; return this; } /* loop the timeline */ window.Timeline.prototype.looptimeline=function(loop){ this.loop=loop; return this; } /* Function execuate call back at position(0-1 ) through animation */ window.Timeline.prototype.at=function(position,callback){ this.callbacks.push({position:position,callback:callback}); return this; } /* check for callbacks to execute */ window.Timeline.prototype.tick=function(){ if(this.started){ var now=(+new Date-this.started); if((now-this.lastTime)>200) { this.started=+new Date-this.lastTime; return; } if(this.lastTime>0 && now=this.lastTime && time<=now) callback.callback(); if((time>=this.lastTime || time<=now) && now=this.lastTime && time<=now) this.animate(anim,now); if((time>=this.lastTime || time<=now) && now1) fraction=1; fraction=this.easing(fraction); switch(anim.action){ case "fade": var reqdistmoved=Math.round(((anim.endpos-anim.startpos)*fraction+anim.startpos)*1000)/1000; anim.element.style.opacity=reqdistmoved; anim.element.style.filter = "alpha(opacity="+Math.floor(reqdistmoved*100)+")"; anim.element.style.MozOpacity=reqdistmoved; anim.element.style.WebkitOpacity=reqdistmoved; break; case "scale": var reqdistmoved=Math.round(((anim.endpos-anim.startpos)*fraction+anim.startpos)*1000)/1000; anim.element.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11='"+reqdistmoved+"', M22='"+reqdistmoved+"', Dx='"+(-anim.xvalue*reqdistmoved+anim.xvalue)+"', Dy='"+(-anim.yvalue*reqdistmoved+anim.yvalue)+"')"; anim.element.style.MozTransform="scale("+reqdistmoved+")"; anim.element.style.WebkitTransform="scale("+reqdistmoved+")"; break; default: var reqdistmoved=Math.floor((anim.endpos-anim.startpos)*fraction+anim.startpos); anim.element.style[anim.action]=reqdistmoved+"px"; } if(fraction===1){ anim.active=false; } } window.Timeline.prototype.easing=function(t) { return t*t*(3-2*t); } })(window);