答案 0 :(得分:0)
我已将Masonry与Infinite Scroll plugin一起使用。它很容易实现。
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://dl.dropbox.com/u/33213779/jquery.masonry.min.js"></script>
<script src="http://masonry.desandro.com/js/jquery.infinitescroll.min.js"></script>
<script>
$(function(){
var $grid = $('#posts');
$grid.imagesLoaded( function(){
$grid.masonry({
itemSelector : '.item',
columnWidth: 250
});
});
$grid.infinitescroll({
navSelector : '#footer', // selector for the paged navigation
nextSelector : '#footer a', // selector for the NEXT link (to page 2)
itemSelector : '.item', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more pages to load.',
img: 'http://i.imgur.com/6RMhx.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 });
$grid.masonry( 'appended', $newElems, true );
});
}
);
});
</script>