Skip to content

Instantly share code, notes, and snippets.

@NetanelBasal
Created December 3, 2015 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NetanelBasal/b552bd8e9020efa97f2d to your computer and use it in GitHub Desktop.
Save NetanelBasal/b552bd8e9020efa97f2d to your computer and use it in GitHub Desktop.
let p = document.querySelector('p');
let pHeight = parseInt(window.getComputedStyle(p).height) * -1;
// console.log(p.clientHeight )
document.addEventListener('scroll', (e) => {
if(p.getBoundingClientRect().top === 0) {
console.log('arrive to this ele');
}
if(p.getBoundingClientRect().top === pHeight) {
console.log('leave ele');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment