【问题标题】:jQuery - iPad/iPhone - enable scrolling after disabling itjQuery - iPad/iPhone - 禁用后启用滚动
【发布时间】:2012-06-03 21:41:48
【问题描述】:

我在 iPad 上禁用了滚动功能:

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

有没有办法简单地再次启用它?

这在以下功能中特别有用:

function enableScrolling() {
    // enable scrolling
}

【问题讨论】:

    标签: jquery ios ipad scroll dom-events


    【解决方案1】:

    这应该可行,

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

    【讨论】:

    • 这很好用!我将它与this 答案结合起来,在触摸设备和桌面浏览器上禁用/启用。
    • 这太完美了!干净整洁。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2011-05-06
    • 1970-01-01
    • 1970-01-01
    • 2015-10-26
    • 2014-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多