Combined with the javascript preventDefault
solution in your link; you can use the following to disable pinch in and out page-wide.
<style>
html,
body {
position: fixed;
overflow: hidden;
}
</style>
And wrap everything inside <body>
in a master wrapper with the following CSS
<style>
.mainwrapper {
width: 100vw;
height: 100vh;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
</style>
<body>
<div id="master_wrap">
...content...
</div> <!-- /master wrapper -->
</body>
You in effect disable all body/html level scrolling, and then re-enable scrolling a level below inside the master wrapper, which includes elastic and momentum scrolling. When these elements scroll, the pinching is already ignored.
Drawbacks
1 - If you have fixed
or absolute
elements, then the scrolling becomes very janky.
2 - There also seems to be a strange bug where-by part of the page will be modified, and pinch becomes available again, if you scroll down from high on the page. I think it might be related to the vh
property and there's probably a JS solution to set the element height/width better.