Skip to content

Function: isInViewport() ​

ts
function isInViewport(element): boolean;

Checks whether an element is within the viewport.

Parameters ​

ParameterTypeDescription
elementElementThe target element.

Returns ​

boolean

true when the element intersects the viewport.

Example ​

ts
const el = document.createElement('div')
document.body.appendChild(el)
console.log(isInViewport(el))

Since ​

1.0.0

Released under the MIT License.