0
假设这是我的插件:如何在我自己的jQuery插件中实现beforeAnimte和afterAnimate回调?
// writing the plugin
(function($){
$.fn.myPlugIn = function(options){
defaults = {
beforeAnimate : function(){},
afterAnimate : function(){}
}
options = $.extend(defaults, options);
//here is where I need help
options.beforeAnimate();
$(this).animate({'width':'1000px'},1000);
options.afterAnimate();
}
})(jQuery);
//using the plugin
$('#art2').myPlugIn({
beforeAnimate: function(){
$('#art1').animate({'width':'1000px'},1000);
},
afterAnimate: function(){
$('#art3').animate({'width':'1000px'},1000);
}
});
我应该如何改写这个部分:
options.beforeAnimate();
$(this).animate({'width':'1000px'},1000);
options.afterAnimate();
为了得到3动画调用另一个之后。 (即等待前一个已完成)