This works in ionic 4+. Tested on ionic 5.
Pinch to zoom on the entire page or specific div or on image.
You can do following.
<ion-content scrollX="true" scrollY="true">
...your content.
<ion-content>
Above method enables pinch to zoom on entire page on web. Not for mobile platforms.
For Mobile platforms.
Install pinch to zoom from - http://ivylab.space/pinch-zoom
or
npm i ngx-pinch-zoom
follow @AliGhassan Solution for remaining setup.
Now to enable pinch to zoom on entire web page,
Set the html tags for ionic content as follows in your page.html file
<ion-content scrollX="true" scrollY="true">
<pinch-zoom [properties]="zoomProperties">
<ion-grid>
....contents..
</ion-grid>
</pinch-zoom>
</ion-content>
Create a variable for zoom properties as follows in page.ts file
zoomProperties = {
"double-tap": true, // double tap to zoom in and out.
"overflow": "hidden",// Am not sure. But Documentation says, it will not render elements outside the container.
"wheel": false, // Disables mouse - To enable scrolling. Else mouse scrolling will be used to zoom in and out on web.
"disableZoomControl": "disable", // stops showing zoom + and zoom - images.
"backgroundColor": "rgba(0,0,0,0)" // Makes the pinch zoom container color to transparent. So that ionic themes can be applied without issues.
}
Now, You should be able to pinch to zoom on mobile platforms as well.
If you are further interested, You can implement the same concept on an image or a div etc.
Thank you :)