You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an older site with a viewport meta tag like this: <meta name="viewport" content="width=1024">.
When fully pinch-zoomed out on a mobile device (and upon first loading), I would expect the visual viewport to be at minimum 1024 CSS pixels wide, matching the layout viewport. However, depending on the mobile device, that isn't always the case.
Is reporting 1023.9 (when fully pinch-zoomed out) expected/allowed behaviour? From my point of view, it's undesirable behaviour since it complicates detecting when the user has either pinch-zoomed in or refreshed the page whilst zoomed (visualViewport.width < 1024).
Thanks!
The text was updated successfully, but these errors were encountered:
This happens due to the UI scaling factor (i.e. the screen density) of the device. I believe the layout is sized to the nearest physical pixel which doesn't fall on a whole CSS pixel. We could do some rounding/ceil/min but that would likely cause other issues. Do you see consistent values from documentElement.getBoundingClientRects?
Does that still suggest the same cause to you? Given they're both doubles, I believe it's a reasonable expectation that the width and right values should match the viewport width in this scenario, wdyt?
Some alternatives to rounding the width that may be easier to implement:
Adding a second scale value to the Visual Viewport API where 1 is the size of the layout viewport, rather than the optimal device-width/height. (Assuming it would report 1.0 when fully pinch-zoomed out rather than 0.999...)
Adding offsetRight and offsetBottom values to the Visual Viewport API. (Assuming they would report 0 when fully pinch-zoomed out rather than 0.001...)
I have an older site with a viewport meta tag like this:
<meta name="viewport" content="width=1024">
.When fully pinch-zoomed out on a mobile device (and upon first loading), I would expect the visual viewport to be at minimum 1024 CSS pixels wide, matching the layout viewport. However, depending on the mobile device, that isn't always the case.
Here's my simplified test case: https://output.jsbin.com/xesolop
And here's the widths reported by the Visual Viewport API:
Is reporting 1023.9 (when fully pinch-zoomed out) expected/allowed behaviour? From my point of view, it's undesirable behaviour since it complicates detecting when the user has either pinch-zoomed in or refreshed the page whilst zoomed (
visualViewport.width < 1024
).Thanks!
The text was updated successfully, but these errors were encountered: