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

Function getViewportSize

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

* Get the viewport size without the scrollbar.

()

Source from the content-addressed store, hash-verified

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

Callers 2

useViewportSizeFunction · 0.85
onResizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected