admin管理员组文章数量:1429060
I have a html5 application with several viewports. I intend to use HammerJS for providing pinch/zoom gesture on individual viewports. Currently, whenever I pinch in Safari/OSX, the whole window is zoomed in or out, and I want to prevent that. For iOS this works:
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
But it doesn't prevent zooming in OSX. Is there any other meta, css3 or javascript that works in Safari/OSX?
I have a html5 application with several viewports. I intend to use HammerJS for providing pinch/zoom gesture on individual viewports. Currently, whenever I pinch in Safari/OSX, the whole window is zoomed in or out, and I want to prevent that. For iOS this works:
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
But it doesn't prevent zooming in OSX. Is there any other meta, css3 or javascript that works in Safari/OSX?
Share Improve this question asked Apr 6, 2016 at 18:04 JaimeJaime 5,9854 gold badges25 silver badges53 bronze badges1 Answer
Reset to default 7Since Safari 10.1+, you can hook into the GestureEvent
on macOS/OSX.
window.addEventListener('gesturestart', e => e.preventDefault());
window.addEventListener('gesturechange', e => e.preventDefault());
window.addEventListener('gestureend', e => e.preventDefault());
The above will prevent any gesture from firing (e.g. pinch to zoom). You can also handle those events, hooking into scale and rotation values.
本文标签: javascriptPrevent pinchzoom in Safari for OSXStack Overflow
版权声明:本文标题:javascript - Prevent pinchzoom in Safari for OSX - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745465670a2659523.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论