題目一
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標(biāo)簽,把真實(shí)的地址放入自定義屬性里,因此平時(shí)圖片不會(huì)加載
滾動(dòng)頁面時(shí),檢查所有img標(biāo)簽,是否出現(xiàn)在視野中,再判斷是否加載過,如果沒有則加載