要素の高さを設定するための小さなプラグインが、いくつかの可変要因に基づいて用意されています。ページの読み込みでは、高さが数秒間設定されないようにするために遅延が必要でした。私は遅延がエフェクトでのみ動作することを知っています。プラグインをエフェクトとして登録する方法はありますか?これを別の方法で行う必要がありますか?プラグインで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);
これをプラグインコードに追加できますか?もしそうなら、どのようにポインタを –
@MildFuzz:もちろんもちろんできます。ちょうどそれのようにそこに入れてください。 – jAndy
私はちょうど私のプラグインのアニメーションの周りにキューメソッドをラップし、遅延(外部でトリガーされる)はうまくいくようです。ありがとう!! –