JS monitors the distance between the scroll wheel sliding up and down and the distance from the upper part of the scroll wheel (from the network)

    windowAddMouseWheel();  
    function windowAddMouseWheel() {  
        var scrollFunc = function (e) {  
            e = e || window.event;  
            if (e.wheelDelta) { //Determine browser IE, Google wheel events  
                if (e.wheelDelta > 0) { //When the wheel scrolls down  
                    alert("The wheel scrolls up");  
                }  
                if (e.wheelDelta < 0) { //When the wheel rolls up  
                    alert("The wheel scrolls down");  
                }  
            } else if (e.detail) { //Firefox wheel event  
                if (e.detail> 0) { //When the wheel scrolls down  
                    alert("The wheel scrolls up");  
                }  
                if (e.detail< 0) { //When the wheel scrolls up  
                    alert("The wheel scrolls down");  
                }  
            }  
        };  
        / / Bind the wheel scroll event to the page  
        if (document.addEventListener) {  
            document.addEventListener('DOMMouseScroll', scrollFunc, false);  
        }  
    //The scroll wheel triggers the scrollFunc method  
        window.onmousewheel = document.onmousewheel = scrollFunc;  
    }  

 

window.onscroll=function(){

//The variable t is the distance to the top when the scroll bar scrolls
var t =document.documentElement.scrollTop||document.body.scrollTop;
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324973390&siteId=291194637