[英]IOS mobile disable zoom
I would like to disable zoom for a progressive web application running on IOS 13.0 or higher.我想为在 IOS 13.0 或更高版本上运行的渐进式 web 应用程序禁用缩放。
I have seen quite a few similar queries, but with seemingly incomplete answers.我见过不少类似的查询,但答案似乎不完整。 I tried to find a solution using multiple event listeners like touchstart and touchmove to block the default browser event [ event.stopPropagation(), event.preventDefault()] and played around with touch-action... but to no avail.
我试图找到一个解决方案,使用多个事件侦听器(如 touchstart 和 touchmove)来阻止默认浏览器事件 [ event.stopPropagation(), event.preventDefault()] 并玩弄触摸动作......但无济于事。
Disable pinch zoom on IOS 13 safari 禁用 IOS 13 safari 上的捏合缩放
html meta viewport user-scalable=no seemed no longer working on iOS 13.3 html 元视口 user-scalable=no 似乎不再适用于 iOS 13.3
And for doubleclick zoom disabling as well, I have a similar issue对于双击缩放禁用,我也有类似的问题
Disable double tap zoom on Safari iOS 13 + 在 Safari iOS 上禁用双击缩放 13 +
Thank you in advance for your help,预先感谢您的帮助,
Stuart斯图尔特
I am doing it like this (touchmovetime is a global variable to store a timestamp when the last touch occured):我正在这样做(touchmovetime 是一个全局变量,用于存储最后一次触摸发生时的时间戳):
var touchmovetime;
// add events to inputs and disable pinchtozoom
var disablePinchToZoom = function (event) {
if (typeof event.scale !== "undefined" && event.scale !== 1) { event.preventDefault(); }
touchmovetime=event.timeStamp;
};
var myDisabledTouchmove = function (event) {
event.preventDefault();
touchmovetime=event.timeStamp;
};
var myDisabledEvent = function (event) {
event.preventDefault();
if ((event.timeStamp - touchmovetime)>200) {
event.changedTouches[0].target.click();
event.changedTouches[0].target.focus();
} // always issues single clicks but not for touchmove events
};
var ids= ["element1", "element2"];
var c;
for (var i in ids) {
c = document.getElementById(ids[i]);
c.addEventListener("touchmove", disablePinchToZoom, false);
c.addEventListener("touchmove", myDisabledTouchmove, false);
c.addEventListener("touchend", myDisabledEvent, false);
if (isAndroid) {
c.addEventListener("touchstart", function(e) { touchEvent.preventDefault(); }, false);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.