Skip to content

Instantly share code, notes, and snippets.

@artemsites
Last active May 17, 2024 09:06
Show Gist options
  • Save artemsites/bc32fa9bda72113c90250594b4fa47c2 to your computer and use it in GitHub Desktop.
Save artemsites/bc32fa9bda72113c90250594b4fa47c2 to your computer and use it in GitHub Desktop.
/**
* @author https://t.me/artemsites
*/
export default function isElementInViewportByAxisY(target) {
let el = (typeof target === 'string') ? document.querySelector(target) : target
const rect = el.getBoundingClientRect()
return (
rect.top <= 0
|| rect.bottom >= (window.innerHeight || document.documentElement.clientHeight)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment