如何写一个通用的JavaScript效果库!(1/2)

2019-06-02 22:56:02王旭

         this.duration   = (this.options.duration || 2) * 1000;   //效果执行时间 
         this.fps            = this.options.fps || 40;                 //频率 
         //当前步长,注: 这个变量是递减的,当它0的时候意味着整个效果结束 
         this.steps        = Math.floor(this.duration/this.fps);    
         this.maxSteps = this.steps;             //整个效果的步长 
         this.setting     = new Object();   
         this.timer         = null;         

      if (this.options.delay){    // 延时处理 
                var _this=this; 
              setTimeout(function(){ 
                        _this.setup(_this); 
                        (_this.options.onStart || Prototype.emptyFunction)(_this); 
                        _this.run(); 
                 }, _this.options.delay*1000); 
         }else{ 
                  this.setup(this); 
                 (this.options.onStart || Prototype.emptyFunction)(this);         
                 this.run();       
         }