有人可以告诉我如何为此插件添加缓动。我知道有一个缓动插件,yada yada,我只是希望这个插件可以选择在使用它时添加缓动和回调。我尝试在easing
之后添加speed,
这个词,所以它看起来像speed, easing, callback
,但由于某种原因它不起作用?
jQuery.fn.animateAuto = function(prop, speed, callback){
var elem, height, width;
return this.each(function(i, el){
el = jQuery(el), elem = el.clone().css({"height":"auto","width":"auto"}).appendTo("body");
height = elem.css("height"),
width = elem.css("width"),
elem.remove();
if(prop === "height")
el.animate({"height":height}, speed, callback);
else if(prop === "width")
el.animate({"width":width}, speed, callback);
else if(prop === "both")
el.animate({"width":width,"height":height}, speed, callback);
});
}
答案 0 :(得分:1)
应该是这样的:
el.animate(
{height:your_height_value},
speed,
'swing', //example easing here
complete: function() { //your callback, just an example
//do something
}
);
你的意思是什么