我使用desandro进行砌筑布局并且工作正常。虽然在加载图像时,布局已经完成。它会在所有图像加载后重新排列,但在加载时会叠加在一起。
Flickr似乎是我瞄准布局的那个。在flickr照片流中,瓷砖已经布局了灰色背景,并直接在其中加载图像。我怎样才能实现这样的目标呢?
这是我正在使用的脚本:
var $container = $('#wall');
$container.imagesLoaded(function(){
$container.masonry({
"columnWidth": ".grid-sizer",
"gutter": ".gutter-sizer",
"itemSelector" : '.item'
});
});
值得注意的是,我在我为博客实施的WordPress主题中使用Paul无限加载。
$container.infinitescroll({
navSelector : '.pagination ', // selector for the paged navigation
nextSelector : '.next.page-numbers', // selector for the NEXT link (to page 2)
itemSelector : '.item', // selector for all items you'll retrieve
loading: {
msg: null,
msgText: "<small>loading content...",
finishedMsg: "<small>End of line.</small>",
speed: 'fast',
img: 'http://i.imgur.com/Ky3zbSs.gif'
}
},
// trigger Masonry as a callback
function( newElements ) {
// hide new items while they are loading
var $newElems = $( newElements ).css({ opacity: 0 });
// ensure that images load before adding to masonry layout
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$container.masonry( 'appended', $newElems, true );
});
}
);