Check if element is visible in browser viewport
const isElementInViewport = (el) => {
const rect = el.getBoundingClientRect();
return rect.bottom > 0 && rect.right > 0 &&
rect.left < (window.innerWidth || document.documentElement.clientWidth) &&
rect.top < (window.innerHeight || document.documentElement.clientHeight);
}