0
我有一個使用砌體和無限滾動的頁面。一切似乎都按照它應該的方式工作,但我希望我的訪問者使用按鈕觸發無限滾動效果,而不是觸發器被自動激活。像Google的圖片搜索。這是代碼,我相信某種...如何將自定義觸發器添加到砌體無限滾動
$("#load-more-button").click(function(){});
...可以放在某處...
<script type="text/javascript">
jQuery(document).ready(function($){ var $container = $('#posts');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector: '.post',
isFitWindow: true
});
});
$container.infinitescroll({
navSelector : '#page-nav', // selector for the paged navigation
nextSelector : '#page-nav a', // selector for the NEXT link (to page 2)
itemSelector : '.post', // selector for all items you'll retrieve
loading: {
finishedMsg: 'Nothing more',
img: 'images/ajax-loader.gif'
}
},
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);
});
}
);
});