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動畫調用另一個之後。 (即等待前一個已完成)