fn
isInView
v0.0.5testedReports whether an element is fully within the visual viewport,
accounting for on-screen keyboards via window.visualViewport. A 40px slack
is allowed at the bottom to tolerate Safari's viewport quirks. Returns false
when visualViewport is unavailable.
Example
ts
if (!isInView(focusedField)) scrollIntoView(focusedField);Signature
ts
export function isInView(element: HTMLElement): boolean{ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
element | HTMLElement | The element to test |
Returns
booleantrue if the element's rect fits inside the visual viewport