乐趣区

关于前端:监听html页面滚动条滚动中滚动停止

$(document).ready(function(){

let top1 = 0;
let top2 = 0;
let timer = null; // 定时器

$(document).scroll(function(){clearTimeout(timer);
    timer = setTimeout(isScrollEnd, 1000);
    top1 = document.documentElement.scrollTop || document.body.scrollTop;
    console.log("滚动中")// 滚动的时候触发
});

function isScrollEnd() {
    top2 = document.documentElement.scrollTop || document.body.scrollTop;
    if(top1 == top2){console.log('滚动完结了')
    }
}

});

退出移动版