下拉加载

2020-03-20  本文已影响0人  嵩鼠

window.addEventListener('scroll', function() {

    // 获取页面滚动距离顶部的高度,  window.pageYOffse 兼容苹果

    let top = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop,

     // 获取页面的可视高度

     scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight, //总高度

     clientHeight = document.documentElement.clientHeight || document.body.clientHeight;

    if ((top + clientHeight + 1) >= scrollHeight) {

        console.log('到底了')

    }

})

上一篇 下一篇

猜你喜欢

热点阅读