Skip to content

Instantly share code, notes, and snippets.

@honsa
Last active October 2, 2018 18:37
Show Gist options
  • Save honsa/4599439d0afa4b5f4bedfc3c32a8a96f to your computer and use it in GitHub Desktop.
Save honsa/4599439d0afa4b5f4bedfc3c32a8a96f to your computer and use it in GitHub Desktop.
Simple example implementation of the famous javascript intersection observer.
let element = document.querySelector('.element');
observer = new IntersectionObserver(callback);
observer.observe(element);
function callback(entry, observer){
if(entry[0].isIntersecting){
console.log(entry[0]);
}
}
@honsa
Copy link
Author

honsa commented Jul 10, 2018

The answer my friend, MutationObserver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment