jQuery - iPad/iPhone - enable scrolling after disabling it

前端 未结 1 1753
别跟我提以往
别跟我提以往 2021-02-11 02:51

I have disabled scrolling on the iPad using:

function disableScrolling() {
    document.ontouchmove = function(e){
            e.preventDefault();
    }
}
         


        
1条回答
  •  执念已碎
    2021-02-11 03:19

    This should work,

    var disableScroll = false;
    
    function disableScrolling() {
        disableScroll = true;
    }
    
    
    function enableScrolling() {
        disableScroll = false;
    }
    
    document.ontouchmove = function(e){
       if(disableScroll){
         e.preventDefault();
       } 
    }
    

    0 讨论(0)
提交回复
热议问题