禁用 iOS Overscroll 但允许身体滚动 [英] Disable iOS Overscroll but allow body scrolling

查看:35
本文介绍了禁用 iOS Overscroll 但允许身体滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 web 应用程序中禁用 iOS 过度滚动,但仍允许滚动正文.

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

$(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?

推荐答案

我有很多 同样的问题.这应该可以帮助您:

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();
 });

这篇关于禁用 iOS Overscroll 但允许身体滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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