Last active
October 2, 2018 18:37
-
-
Save honsa/4599439d0afa4b5f4bedfc3c32a8a96f to your computer and use it in GitHub Desktop.
Simple example implementation of the famous javascript intersection observer.
This file contains hidden or 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
let element = document.querySelector('.element'); | |
observer = new IntersectionObserver(callback); | |
observer.observe(element); | |
function callback(entry, observer){ | |
if(entry[0].isIntersecting){ | |
console.log(entry[0]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The answer my friend, MutationObserver