问题
Is there an easy way to check whether the user scaled the page (using pinch on mobile devices)?
Thought verge.js would help, but I don't know what I can compare viewportH
with.
回答1:
You can compare the screen.width to the window.innerWidth. If the value is anything other than 1, the viewport has been zoomed.
viewportScale = screen.width / window.innerWidth;
alert(viewportScale);
References: https://developer.mozilla.org/en-US/docs/Web/API/Window.screen
https://developer.mozilla.org/en-US/docs/Web/API/window.innerWidth
回答2:
(
document.documentElement.clientWidth
/ window.innerWidth
)
>
1
Only for mobile devices, though!
来源:https://stackoverflow.com/questions/19888098/check-if-viewport-zoomed