Closed theres-waldo closed 5 years ago
There's a bit of context here in #19
window.innerWidth in Chrome refers to the layout viewport and has the same semantics regarding scrollbars. Although the scrollbar doesn't zoom and sticks to the visual viewport, the layout space taken by it on the layout viewport remains the same so I think this makes sense. So the summary:
Layout Viewport Including Scrollbars: window.innerWidth Layout Viewport Excluding Scrollbars: documentElement.clientWidth Visual Viewport Excluding Scrollbars: visualViewport.width Visual Viewport Including Scrollbars: N/A (this was #19 but I haven't heard of any pressing use cases here - it seems excluding scrollbar is the useful dimension).
Interesting -- so the scrollbar width can still be computed as window.innerWidth - documentElement.clientWidth
if those return layout viewport metrics. That's good enough for me, thanks.
The size returned by the Visual Viewport API excludes any space taken up by scrollbars.
What if a web page wants to know the size including the scrollbars? In Firefox, it can currently use
window.innerWidth
. However, if we switchwindow.innerWidth
to report the size of the layout viewport instead as Chrome has done, that will no longer work; is there a replacement?cc @mstange @bokand