題目一
function isVisible($node){
if($node.offset().top<$(window).height+$(window).scrollTop()
&& $node.offset().top>$(window).scrollTop()){
return true
}
return false
}
題目二
$(window).on('scroll',function(){
if($node.offset().top<$(window).height+$(window).scrollTop()
&& $node.offset().top>$(window).scrollTop()){
console.log(true)
}
})
題目三
$(window).on('scroll',function(){
if($node.offset().top<$(window).height+$(window).scrollTop()
&& $node.offset().top>$(window).scrollTop()){
if(!$node.attr('loaded'){
console.log(true)
$node.addClass('loaded')
})
}
})
題目四
對于所有的Img標簽,把真實的地址放入自定義屬性里,因此平時圖片不會加載
滾動頁面時,檢查所有img標簽,是否出現在視野中,再判斷是否加載過,如果沒有則加載