简体   繁体   English

防止iOS 11.3溢出弹跳

[英]Prevent iOS 11.3 overflow bouncing

I've been making use of the preventDefault technique on the touchmove event since now, when I noticed it doesn't seem to work anymore on iOS 11.3, for neither Safari, nor Chrome or Firefox: 从现在开始,我一直在touchmove事件中使用preventDefault技术,当时我注意到它在iOS 11.3上似乎不再适用,既不适用于Safari,也不适用于Chrome或Firefox:

document.ontouchmove = function(event){
    event.preventDefault();
} 

Has anything changed now in iOS? iOS现在有什么变化吗? What's the way of preventing the bouncing at the top or end of the page? 阻止页面顶部或末尾弹跳的方法是什么?

Reproduction online 在线复制

Reproduction online with jQuery 使用jQuery在线复制

Video here: 视频在这里:

在此输入图像描述

It was caused by a bug of WebKit. 它是由WebKit的一个错误引起的。 Bug 182521 错误182521

Try 尝试

window.addEventListener("touchstart", function(event) {
  event.preventDefault();
}, {passive: false});

as a workaround. 作为一种解决方法。

In addition to gluttonys answer: 除了暴食之外答案:

window.addEventListener("touchmove", function(event) {event.preventDefault();}, {passive: false} );

is for me a working solution for the safari bounce issue. 对我来说是一个解决野生动物园反弹问题的有效方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM