Skip to content

1681-engine / react / useFitToViewport

Function: useFitToViewport() ​

ts
function useFitToViewport(ref, target): void;

Defined in: src/react/useFitToViewport.ts:24

Keeps a window or dialog inside the viewport (windowStyle → fitToViewport): measured after every render, on a resize and when its content changes size, written straight onto the element's style so a placement never costs a render. The natural height is the element's plus what its scrolling body (.e1681-scroll) hides, so the cap never has to be lifted to measure, which would throw the body's scroll back to the top.

Parameters ​

ParameterType
refRefObject<HTMLElement | null>
targetFitTarget

Returns ​

void

Released under the MIT License.