添加缓动到一个简单的小 jquery 插件?不工作
有人可以告诉我如何向这个插件添加缓动。我知道有一个缓动插件,yada yada,我只是希望这个插件在使用它时可以选择添加缓动和回调。我尝试在 speed,
之后添加单词 easing
,所以它看起来像 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);
});
}
Can someone tell me how to add easing to this plugin. I understand there's an easing plugin, yada yada, I just want this plugin to have the option of adding easing AND a callback when using it. I tried adding the word easing
after speed,
, so it looked like speed, easing, callback
, but for some reason it didn't work?
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);
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该是这样的:
你的意思是这样吗
It should be like:
Did you mean something like this