禁用iOS Overscroll但允许正文滚动

时间:2022-08-24 10:42:28

I would like to disable the iOS overscroll in a webapp but still allow the body to be scrolled.

我想在webapp中禁用iOS过度滚动但仍然允许滚动主体。

$(document).on('touchmove', function(e) {
    e.preventDefault();
});

disables scrolling altogether (as one would expect).

完全禁用滚动(正如人们所期望的那样)。

Is there a way to do what I want to do?

有办法做我想做的事吗?

2 个解决方案

#1


7  

I had pretty much the same issue. This should help you:

我有同样的问题。这应该可以帮到你:

// Disable overscroll / viewport moving on everything but scrollable divs
 $('body').on('touchmove', function (e) {
         if (!$('.scrollable').has($(e.target)).length) e.preventDefault();
 });

#2


2  

document.body.addEventListener('touchmove',function(e){
     if(!$(e.target).hasClass("scrollable")) {
       e.preventDefault();
     }
 });

Try this i just got in via google

尝试这个我刚进入谷歌

#1


7  

I had pretty much the same issue. This should help you:

我有同样的问题。这应该可以帮到你:

// Disable overscroll / viewport moving on everything but scrollable divs
 $('body').on('touchmove', function (e) {
         if (!$('.scrollable').has($(e.target)).length) e.preventDefault();
 });

#2


2  

document.body.addEventListener('touchmove',function(e){
     if(!$(e.target).hasClass("scrollable")) {
       e.preventDefault();
     }
 });

Try this i just got in via google

尝试这个我刚进入谷歌