1
我寫了一個小環形滾動腳本,以磚石爲佈局, 一些Ajax調用瀏覽器被越來越慢(凍結)後...磚石或一段時間後,我的滾動腳本凍結火狐
var $container = jQuery('#container');
$container.masonry({
itemSelector: '.box',
columnWidth: 100,
isAnimated : true,
isFitWidth : false
}).imagesLoaded(function() {
$container.masonry('reload');
});
var isLoading = false;
var endofdata = false;
var page=1;
$(window).scroll(function() {
if ($(window).scrollTop()+1 >= ($(document).height() - $(window).height()))
{
if (endofdata)
return false;
if (isLoading) {
return false; // don't make another request, let the current one complete, or
// ajax.abort(); // stop the current request, let it run again
}
isLoading =true;
ajaxLoadActivity('bottom', true);
}
});
var box;
function ajaxLoadActivity(one, two) {
page=page+1;
$.post('api.php', {'action' : "next", 'next' : page },
function(data){
if(data == null)
endofdata=true;
jQuery.each(data, function(index, value){
box+="<div class=\"box\"><a href=\"page/"+value.id +"\">#" +value.id + "</a> " +value.data+"</div>";
});
boxes = $(box);
$container.append(boxes);
var $newElems = $(boxes).css({ opacity: 0 });
$newElems.imagesLoaded(function(){
$newElems.animate({ opacity: 1 });
$container.masonry('appended', $newElems, true);
});
box="";
isLoading=false;
}
);
}
工作示例 http://www.dasmerkendienie.com/
任何形式的幫助,將不勝感激
問候(滾動了一段時間後發生錯誤)個安德烈亞斯
BTW:在Firefox出現錯誤,而不是谷歌chrome