1. 程式人生 > >jQuery 判斷頁面上下滾動

jQuery 判斷頁面上下滾動

set con else ons lse 滾動 this window query

var t = 0, 
    b = 0;
$(window).scroll(function(){
    t = $(this).scrollTop();
    if(b < t){
        console.log('向下滾動中...')
    }else{
        console.log('向上滾動中...')
    }
    setTimeout(function(){
        b = t
    }, 0)
})

jQuery 判斷頁面上下滾動