如果我滚动页面,jQuery Infinite Scroll 的事件将被触发两次或三次。我怎样才能避免这种情况发生?当下一页加载时,jQuery Infinite Scroll 的事件不能被触发,谢谢。
$(function(){
var speed = 1000;
var container = $('#sharelist');
container.imagesLoaded(function(){
container.masonry({
itemSelector: '.share',
singleMode: true,
columnWidth: 242,
isFitWidth: true,
animate: true,
animationOptions: {
duration: speed,
queue: false
}
});
});
container.infinitescroll({
navSelector : '.page',
nextSelector : 'a.next',
itemSelector : 'div[class=share]',
loading: {
finishedMsg: '报告,后面没有了哦.',
img: 'image/icon_waiting.gif',
msgText:'加载中'
}
},
function( newElements ) {
var newElems = $(newElements).css({ opacity: 0 });
newElems.imagesLoaded(function(){
newElems.animate({ opacity: 1 });
container.masonry( 'appended', newElems, true );
$('.namecard').floatUserInfo();
});
}
);
$("img").lazyload({
placeholder : "image/grey.gif",
effect : "fadeIn"
});
});