瀑布式 区域 延迟加载

jquery.masonry.min.js



--------------------------

var $container2 = $('.waterfall-case').eq(0);
$container2.find("img").each(function(){

$(this).attr("src",$(this).attr("src1"));
});

$container2.imagesLoaded(function(){
$container2.masonry({
itemSelector : '.item',
columnWidth : 326
});
});
$container2.show();

-------------------------------------------
 
var initTop = 0;
$(window).scroll(function() {
var scrollTop = $(document).scrollTop();
if(scrollTop > initTop){
if($(window).scrollTop() > $(document).height()-1100){
fallPos= fallPos+1;
var $container = $('.waterfall-case,.waterfall-bowen').eq(fallPos);
$container.find("img").each(function(){

$(this).attr("src",$(this).attr("src1"));
});

$container.imagesLoaded(function(){
$container.masonry({
itemSelector : '.item',
columnWidth : 326
});
});
$container.show();
}
} else {

if($(".fall"+(fallPos)).length>0){
//console.log($(".fall"+(fallPos)).offset().top+" "+$(window).scrollTop());
if($(".fall"+(fallPos)).offset().top < $(window).scrollTop()+800){
if(fallPos>0)
fallPos= fallPos-1;
var $container = $('.waterfall-case,.waterfall-bowen').eq(fallPos);
$container.find("img").each(function(){

$(this).attr("src",$(this).attr("src1"));
});

$container.imagesLoaded(function(){
$container.masonry({
itemSelector : '.item',
columnWidth : 326
});
});
$container.show();
}
}
}
initTop = scrollTop;


});

你可能感兴趣的:(jquery)