/*
定义的tween内的动画效果属性都为缓动算法,他们都接受以下 4 个参数。
t:动画已消耗的时间。
b: 小球原始位置。
c: 小球目标位置。
d: 动画持续的总时间。
返回的值则是动画元素应该处在的当前位置
*/var tween ={
linear:function( t, b, c, d ){return c*t/d + b;},
easeIn:function( t, b, c, d ){return c *( t /= d )* t + b;},
strongEaseIn:function(t, b, c, d){return c *( t /= d )* t * t * t * t + b;},
strongEaseOut:function(t, b, c, d){return c *(( t = t / d -1)* t * t * t * t +1)+ b;},
sineaseIn:function( t, b, c, d ){return c *( t /= d)* t * t + b;},
sineaseOut:function(t,b,c,d){return c *(( t = t / d -1)* t * t +1)+ b;}};
定义Animate动画类
// 定义Animate类varAnimate=function( dom ){this.dom = dom;// 进行运动的 dom 节点this.startTime =0;// 动画开始时间this.startPos =0;// 动画开始时,dom 节点的位置,即 dom 的初始位置this.endPos =0;// 动画结束时,dom 节点的位置,即 dom 的目标位置this.propertyName =null;// dom 节点需要被改变的 css 属性名this.easing =null;// 缓动算法this.duration =null;// 动画持续时间};