jQuery - iPad / iPhone - 禁用后启用滚动功能 [英] jQuery - iPad/iPhone - enable scrolling after disabling it

查看:105
本文介绍了jQuery - iPad / iPhone - 禁用后启用滚动功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已禁用iPad上的滚动:

I have disabled scrolling on the iPad using:

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

有没有办法再次启用它?

Is there a way to simply enable it again?

在以下函数中特别有用:

It would be especially helpful in a function like:

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 - 禁用后启用滚动功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆