Animate.prototype.start = function() { var that = this; this.startTime = new Date(); clearInterval(this.timer); this.timer = setInterval(function() { that._animate.call(that); }, 4); }
Animate.canTransition = function() { var el = document.createElement('foo'); el.style.cssText = '-webkit-transition: all .5s linear;'; return !!el.style.webkitTransitionProperty; }();
使用方法 复制代码 代码如下: // 透明度渐变 function changeOpacity() { // 透明度渐变 从1 - 0 渐变时间1000ms var fx = 'opacity', from = 1, to = 0, time = 1000; // 渐变完毕执行的回调函数 var callback = function() { from = 0; to = 1; new Animate(demo, fx, { from: from, to: to, time: time, callback: resetButton}).start(); } // 实例化渐变函数 new Animate(demo, fx, { from: from, to: to, time: time, callback: callback }).start(); }