js check if element into view

Solutions on MaxInterview for js check if element into view by the best coders in the world

showing results for - "js check if element into view"
Thiago
09 Aug 2017
1function isInViewport(element) {
2    const rect = element.getBoundingClientRect();
3    return (
4        rect.top >= 0 &&
5        rect.left >= 0 &&
6        rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
7        rect.right <= (window.innerWidth || document.documentElement.clientWidth)
8    );
9}