admin管理员组

文章数量:1279247

I am using a library to highlight an image, and this image has the property touch-action: auto;. However, when clicking the close button to close the highlighted image, the zoom applied by the "pinch to zoom" gesture remains. I would like to reset this zoom on mobile.

I tried something like this, but it didn't work on iOS devices (Safari), and it also ends up limiting the zoom after the afterZoomOut function is called:

const viewportMetaTag = document.querySelector("meta[name=viewport]");

afterZoomIn={()=>viewportMetaTag?.setAttribute("content", "width=device-width, initial-scale=1.0, maximum-scale=10.0")}
afterZoomOut={()=>viewportMetaTag?.setAttribute("content", "width=device-width, initial-scale=1.0, maximum-scale=1.0")}

I also tried, but it didn't have any effect on mobile:

document.body.style.scale = "1"

I am using a library to highlight an image, and this image has the property touch-action: auto;. However, when clicking the close button to close the highlighted image, the zoom applied by the "pinch to zoom" gesture remains. I would like to reset this zoom on mobile.

I tried something like this, but it didn't work on iOS devices (Safari), and it also ends up limiting the zoom after the afterZoomOut function is called:

const viewportMetaTag = document.querySelector("meta[name=viewport]");

afterZoomIn={()=>viewportMetaTag?.setAttribute("content", "width=device-width, initial-scale=1.0, maximum-scale=10.0")}
afterZoomOut={()=>viewportMetaTag?.setAttribute("content", "width=device-width, initial-scale=1.0, maximum-scale=1.0")}

I also tried, but it didn't have any effect on mobile:

document.body.style.scale = "1"
Share Improve this question edited Feb 24 at 17:09 Guilherme Andeglieri asked Feb 24 at 17:04 Guilherme AndeglieriGuilherme Andeglieri 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Currently, Safari does not support editing metatags once they have been created. Nothing worked for me, so I will have to create a component with a custom pinch or use a library that can help me.

本文标签: javascriptHow to reset the zoom given by the pinch to zoom gestureStack Overflow