MCPcopy Create free account
hub / github.com/dailydotdev/apps / getVisualViewport

Function getVisualViewport

packages/shared/src/hooks/utils/useVisualViewport.ts:11–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9}
10
11const getVisualViewport = (): VisualViewportResult => ({
12 width: globalThis?.window?.visualViewport?.width ?? 0,
13 height: globalThis?.window?.visualViewport?.height ?? 0,
14 // iOS scrolls the layout viewport under the keyboard rather than resizing it,
15 // so a fixed overlay has to be pushed down by this much to stay on screen.
16 offsetTop: globalThis?.window?.visualViewport?.offsetTop ?? 0,
17 // Pinch-zoom shrinks the visual viewport too; only scale tells it apart
18 // from a keyboard.
19 scale: globalThis?.window?.visualViewport?.scale ?? 1,
20});
21
22/**
23 * @param enabled subscribe to viewport changes. Pass `false` from consumers

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected