Team:Grenoble/script

From 2012.igem.org

(Difference between revisions)
Line 79: Line 79:
var e=this.elem.style;
var e=this.elem.style;
         this.from=(b===undefined?(parseFloat(e.opacity)):b);
         this.from=(b===undefined?(parseFloat(e.opacity)):b);
-
        d=d||{};
+
        d=d||{};
-
    this.duration=d.duration||500;
+
this.duration=d.duration||500;
-
    this.frameRate=d.frameRate||30;
+
        this.frameRate=d.frameRate||30;
-
    this.onFinish=d.onFinish;
+
        this.onFinish=d.onFinish;
-
    this.totalFrames=Math.ceil(this.duration/1000*this.frameRate);
+
this.totalFrames=Math.ceil(this.duration/1000*this.frameRate);
-
    this.perFrame=(this.to-this.from)/this.totalFrames;
+
this.perFrame=(this.to-this.from)/this.totalFrames;
-
    this.frameNb=0;var f=this;
+
this.frameNb=0;var f=this;
-
    this.next=function(){
+
this.next=function(){
-
this.prog=setTimeout(function(){f.frame()},1000/this.frameRate)};
+
this.prog=setTimeout(function(){f.frame()},1000/this.frameRate)};
 +
        this.frame=function(){
 +
    p(this.elem,this.from+this.perFrame*this.frameNb);
 +
    if(this.frameNb===this.totalFrames){
 +
p(this.elem,this.to);
 +
if(typeof this.onFinish=='function'){
 +
    setTimeout(this.onFinish,1)
 +
}
 +
    }else{}
     }
     }

Revision as of 16:37, 11 July 2012