Last active
May 17, 2024 09:06
-
-
Save artemsites/bc32fa9bda72113c90250594b4fa47c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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