javascript 禁用 iOS Overscroll 但允许身体滚动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10546857/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 10:13:07 来源:igfitidea点击:
Disable iOS Overscroll but allow body scrolling
提问by Michael Bates
I would like to disable the iOS overscroll in a webapp but still allow the body to be scrolled.
我想在 web 应用程序中禁用 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?
有没有办法做我想做的事?
回答by Jeff
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();
});
回答by Okky
document.body.addEventListener('touchmove',function(e){
if(!$(e.target).hasClass("scrollable")) {
e.preventDefault();
}
});
Try this i just got in via google
试试这个我刚通过谷歌进入