私は現在、Masonryを使用しており、お客様のニーズに合っていると思います。私は異なる幅の&の高さの画像を持っています。固定幅の最大幅(ページ幅に合わせて固定幅)で読み込んだ後、空白を避けて画像のアスペクト比を維持するためにレイアウトを並べ替えます。私がページの一番下に来ると、私は(手動で)より多くのアイテムを読み込みます。これはここで、すべての画像にLazyLoadを追加するのは簡単ですあなたが次に
(ベータ版ページがある)http://pintevent.comで結果を確認することができます私のコード
//Load the first page
loadMore(1);
function loadMore(page){
var div = "";
var html = "";
var item_num = 1 + ((page-1)*10);
$('.loader').show();
$('#container').hide();
$.post("loadMore.php", {'page':page }, function(data) {
data=JSON.parse(data);
$.each(data, function (key,value) {
//here create the div with the data
html = html + div;
item_num++;
});
$("#container").append(html).each(function(){
$('#container').masonry().masonry('reloadItems');
});
var $container = $('#container');
$container.imagesLoaded(function(){
$('#container').masonry();
});
$('.loader').fadeOut('fast',function(){
$(this).remove().delay(1500);
});
$('#container').show();
});
}
//On bottom page, load more images
$(window).scroll(function() {
if (ready && $(document).height() <= $(window).scrollTop() + $(window).height()) {
ready = false; //Set the flag here
setTimeout(function(){
loadMore(page);
page++;
},1000);
ready = true; //Set the flag here
}
});
ある実施例である: http://jsfiddle.net/nathando/s3KPn/4/(から抽出します同様の質問:それはないあなたのために働く場合Combining LazyLoad and Jquery Masonry)も
は、ここのギャラリーのためのjQueryのLazyLoadライブラリの束は、あなたがチェックすることができます:http://www.jqueryrain.com/demo/jquery-lazy-load/
あなたに役立つことを願っています!
徹底したサンプルコードをお読みいただきありがとうございます。また、実際のサンプルと関連するサンプルへのリンクをお読みください。非常に高品質の答え!ところで、$ containerを一番上に定義し、常に$ containerを参照する代わりに、$( 'container')で新しいクエリを実行する代わりに、loadMore関数を最適化することができます。 – CodeToad
ありがとう!私は将来このようにします:) –