MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getViewportSize

Function getViewportSize

packages/react-aria/src/utils/useViewportSize.ts:103–116  ·  view source on GitHub ↗

* Get the viewport size without the scrollbar.

()

Source from the content-addressed store, hash-verified

101 * Get the viewport size without the scrollbar.
102 */
103function 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}

Callers 2

useViewportSizeFunction · 0.85
onResizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected