滑到底部时,处理一些事件

function addScrollEvent() {
        let canScroll = true;
        function isScrollToPageBottom() {
            let docHeight = document.documentElement.offsetHeight;
            let viewHeight = window.innerHeight;
            let scrollHeight = window.pageYOffset;
            return docHeight - viewHeight - scrollHeight < 20;
        }
        document.onscroll = function () {
            // console.log(isScrollToPageBottom());// true 为底部
            if (canScroll && isScrollToPageBottom()) {// 滑到底部
                canScroll = false;
                if (arr.length > 5) {
                    document.getElementsByClassName('content')[0].innerHTML = '1000'; // 处理一些事件
                }
                else {
                    canScroll = true;
                }
            }
        }.bind(this);
    }

 

posted on 2018-08-08 15:19  郭“老师"  阅读(105)  评论(0编辑  收藏  举报

导航