Skip to main content Accessibility Feedback

The Viewport


isInViewport() is a helper method I wrote to check if any part of an element is in the viewport. It returns true if any part of the element is in the viewport, and false if it’s not.

var elem = document.querySelector('#some-element');
isInViewport(elem); // Boolean: returns true/false