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

Function useVisualViewport

packages/shared/src/hooks/utils/useVisualViewport.ts:27–35  ·  view source on GitHub ↗
(enabled = true)

Source from the content-addressed store, hash-verified

25 * while the keyboard is open, and each event re-renders the whole subtree.
26 */
27export const useVisualViewport = (enabled = true): VisualViewportResult => {
28 const [viewPort, setViewPort] = useState(getVisualViewport); // <- only calls the function 1 time this way - performance improvement
29 const update = () => setViewPort(getVisualViewport);
30 const target = enabled ? globalThis?.window?.visualViewport : undefined;
31 useEventListener(target, 'resize', update);
32 useEventListener(target, 'scroll', update);
33
34 return viewPort;
35};

Callers 5

ShellFieldFunction · 0.90
BaseDrawerFunction · 0.90
useKeyboardFitFunction · 0.90
ViewportFunction · 0.90

Calls 1

useEventListenerFunction · 0.90

Tested by 1

ViewportFunction · 0.72