スクロールしてから画像を読み込む機能
準備中
準備中
準備中
ライブラリを導入する前に
none
function LazyLoad(wst){
$('img[lz] , video[lz]').each(function(){
var lz = $(this).attr('lz');
if(wst + $win.height() > $(this).offset().top - 200){
$(this).attr('src',lz).removeAttr('lz');
$(this).on('load', function(){$(this).removeClass('lz');});
}
if(lz != undefined){$(this).addClass('lz');}
});
}
$win.load(function(){
LazyLoad($win.scrollTop());
});
$win.scroll(function(){
LazyLoad($win.scrollTop());
});