好吧,我正在尝试使 Masonry 使用无限滚动,我找到了官方appended
方法(http://desandro.github.io/masonry/demos/infinite-scroll.html)并试图让它在我的代码上工作. 但我需要更改一些$
to jQuery
,现在它可以像砖石一样工作,但无限滚动仍然无法工作,我想知道我是否忘记了jQuery
要从我的代码中更改为的美元符号,请帮助我
<script >
jQuery(function(){
var $container = jQuery('ul.products');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector: 'li.product',
columnWidth : 295,
isFitWidth: true,
gutterWidth : 2
});
});
$container.infinitescroll({
navSelector : '#page-nav-woo', // selector for the paged navigation
nextSelector : '.next', // selector for the NEXT link (to page 2)
itemSelector : 'li.product', // 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 = jQuery( 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 );
});
}
);
});
</script>