Checks if an element is fully within the viewport.
The DOM element to check.
true if the element is completely visible in the viewport, false otherwise.
true
false
const el = document.querySelector("#myElement");if (el && isInViewport(el)) { console.log("Element is visible in viewport");} Copy
const el = document.querySelector("#myElement");if (el && isInViewport(el)) { console.log("Element is visible in viewport");}
1.1.0
Checks if an element is fully within the viewport.