javascript scroll event for iPhone/iPad?

后端 未结 5 1716
不知归路
不知归路 2020-11-22 15:38

I can\'t seem to capture the scroll event on an iPad. None of these work, what I am doing wrong?

window.onscroll=myFunction;

document.onscroll=myFunction;

         


        
5条回答
  •  旧巷少年郎
    2020-11-22 16:43

    For iOS you need to use the touchmove event as well as the scroll event like this:

    document.addEventListener("touchmove", ScrollStart, false);
    document.addEventListener("scroll", Scroll, false);
    
    function ScrollStart() {
        //start of scroll event for iOS
    }
    
    function Scroll() {
        //end of scroll event for iOS
        //and
        //start/end of scroll event for other browsers
    }
    

提交回复
热议问题