jQuery - iPad/iPhone - enable scrolling after disabling it

前端 未结 1 1218
时光取名叫无心
时光取名叫无心 2021-02-11 02:46

I have disabled scrolling on the iPad using:

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


        
1条回答
  •  清酒与你
    2021-02-11 03:13

    This should work,

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

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