使delay()与插件一起使用
|
我有一个小插件,可根据几个可变因素来设置元素的高度。在页面加载时,我希望有一个延迟,以防止在几秒钟内设置高度。我知道延迟仅在效果上起作用,有没有办法将我的插件注册为效果,还是我需要以其他方式做到这一点?
需求启动代码:
$(\".app_advert\").delay(10000).set_height(2000);
插件代码:
//SetHeight plugin
(function($){
$.fn.extend({
set_height: function(time, callback){
scroll = $(window).scrollTop();
win_height = $(window).height();
document_height = $(document).height();
footer_height = $(\'#footer\').height();
footer_offset = (document_height-(win_height+scroll));
footer_remainder = footer_height-footer_offset;
return this.each(function(){
var x = $(this);
if(footer_height-footer_offset<=0){
height = 0;
} else {
height = footer_height-footer_offset;
}
$(x).stop(true, false).animate({bottom: height}, time, function(){
if (callback && typeof callback == \'function\') { // make sure the callback is a function
callback.call(this); // brings the scope to the callback
}
});
});
}
});
})(jQuery);
没有找到相关结果
已邀请:
2 个回复
财沟项胶
。看起来像;
您甚至可以在该构造上链接更多排队的方法。注意,默认情况下,所有
都将排队,以等待要应用到当前包装集的任何其他方法,并调用另一个
。 阅读:http://api.jquery.com/queue
辩谷变充