标签:
显示
元素隐藏
元素animate(params, [duration], [easing], [callback])
+=
或者-=
让元素做相对运动animate(params, options)
stop([queueName], [clearQueue], [gotoEnd])
对animate函数的总结:
动画队列总结:
fx
,但是和调用对象也是相关的。$this.is(":animated");
主要就是扩展$.fx.step对象,比如:
// jquery.path.js插件,实现贝塞尔曲线动画
jQuery.fx.step.path = function(fx) {
var css = fx.end.css( 1 - fx.pos );
if ( css.prevX != null ) {
jQuery.cssHooks.transform.set( fx.elem, "rotate(" + Math.atan2(css.prevY - css.y, css.prevX - css.x) + ")" );
}
fx.elem.style.top = css.top;
fx.elem.style.left = css.left;
};
// jQuery UI 颜色动画
jQuery.fx.step[ hook ] = function( fx ) {
if ( !fx.colorInit ) {
fx.start = color( fx.elem, hook );
fx.end = color( fx.end );
fx.colorInit = true;
}
jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
};
// animate函数可以实现size属性动画效果
jQuery.fx.step[‘size‘] = function(fx)
{
if ( !fx._sizeInit )
{
var \$el = \$(fx.elem),
c = fx.end.center || {top: 0, left: 0};
fx.start = \$el.offset();
$.extend(fx.start, {width: $el.width(), height: $el.height()});
fx._sizer = {};
fx._sizer.topDelta = c.top - (c.top * fx.end.height / fx.start.height);
fx._sizer.leftDelta = c.left - (c.left * fx.end.width / fx.start.width);
fx._sizer.widthDelta = fx.end.width - fx.start.width;
fx._sizer.heightDelta = fx.end.height - fx.start.height;
fx._sizeInit = true;
}
fx.elem.style.top = fx.start.top + Math.floor(fx._sizer.topDelta * fx.pos) + ‘px‘;
fx.elem.style.left = fx.start.left + Math.floor(fx._sizer.leftDelta * fx.pos) + ‘px‘;
fx.elem.style.width = fx.start.width + Math.floor(fx._sizer.widthDelta * fx.pos) + ‘px‘;
fx.elem.style.height = fx.start.height + Math.floor(fx._sizer.heightDelta * fx.pos) + ‘px‘;
}
标签:
原文地址:http://www.cnblogs.com/wzzl/p/4657726.html