jQuery - iPad/iPhone - 禁用滚动后启用滚动

标签 jquery ios ipad scroll dom-events

我使用以下方法禁用了 iPad 上的滚动:

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

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

这对于以下功能特别有用:

function enableScrolling() {
    // enable scrolling
}

最佳答案

这应该有效,

var disableScroll = false;

function disableScrolling() {
    disableScroll = true;
}


function enableScrolling() {
    disableScroll = false;
}

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

关于jQuery - iPad/iPhone - 禁用滚动后启用滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10803000/

相关文章:

jquery - 从变量中移动具有相同源名称的 img

ios - Swift:UIScrollView 和 UIControl - 添加目标 | addGestureRecognizer - 未按预期工作

ios - 注册本地通知

iphone - iOS - 使用自定义加密 key 保护文件?

ios 8 方向问题

iphone - AVFoundation 点击​​聚焦反馈矩形

javascript - 如何验证输入类型 ="text"元素只接受特定内容?

javascript - 将类添加到包含 Dog 1 及其之间的行的表行

jquery - 替换元素中的内容而不替换 HTML

ios - Swift - 快照尚未呈现的 View 会导致空快照