* Get the viewport size without the scrollbar.
()
| 101 | * Get the viewport size without the scrollbar. |
| 102 | */ |
| 103 | function getViewportSize(): ViewportSize { |
| 104 | return { |
| 105 | // Multiply by the visualViewport scale to get the "natural" size, unaffected by pinch zooming. |
| 106 | width: visualViewport |
| 107 | ? // The visual viewport width may include the scrollbar gutter. We should use the minimum width between |
| 108 | // the visual viewport and the document element to ensure that the scrollbar width is always excluded. |
| 109 | // See: https://github.com/w3c/csswg-drafts/issues/8099 |
| 110 | Math.min(visualViewport.width * visualViewport.scale, document.documentElement.clientWidth) |
| 111 | : document.documentElement.clientWidth, |
| 112 | height: visualViewport |
| 113 | ? visualViewport.height * visualViewport.scale |
| 114 | : document.documentElement.clientHeight |
| 115 | }; |
| 116 | } |
no outgoing calls
no test coverage detected