Skip to content

Instantly share code, notes, and snippets.

@mrmartineau
Created April 15, 2018 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrmartineau/7ff20214dcef8474060ba4502b514b8a to your computer and use it in GitHub Desktop.
Save mrmartineau/7ff20214dcef8474060ba4502b514b8a to your computer and use it in GitHub Desktop.
var callback = (entries, observer) => {
entries.forEach(entry => {
console.log('entry', entry)
// Each entry describes an intersection change for one observed
// target element:
// entry.boundingClientRect
// entry.intersectionRatio
// entry.intersectionRect
// entry.isIntersecting
// entry.rootBounds
// entry.target
// entry.time
if (entry.intersectionRatio > 0.8) {
this.skippy.classList.add('is-inactive')
}
else {
this.skippy.classList.remove('is-inactive')
}
});
};
var observer = new IntersectionObserver(callback, {
root: document.querySelector('body'),
rootMargin: '0px',
threshold: [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
});
observer.observe(this.bigType)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment