1var isInViewport = function (elem) {
2 var bounding = elem.getBoundingClientRect();
3 return (
4 bounding.top >= 0 &&
5 bounding.left >= 0 &&
6 bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
7 bounding.right <= (window.innerWidth || document.documentElement.clientWidth)
8 );
9};
10
1function isVisible (ele) {
2 const { top, bottom } = ele.getBoundingClientRect();
3 const vHeight = (window.innerHeight || document.documentElement.clientHeight);
4
5 return (
6 (top > 0 || bottom > 0) &&
7 top < vHeight
8 );
9}