js 判断滚动方向


var before = $(window).scrollTop();
    //滚动事件
    $(window).scroll(function() {

        var after = $(window).scrollTop();
        if (after > before) {
            console.log('下')
            before = after;

        } else {
            console.log('上')
            before = after;

        }

    })
posted @ 2020-08-17 20:16  shetoutou  阅读(744)  评论(0编辑  收藏  举报