Skip to content

Instantly share code, notes, and snippets.

@adeyahya
Created September 23, 2017 10:00
Show Gist options
  • Save adeyahya/4b9018848301a734c1d16e3f11259ede to your computer and use it in GitHub Desktop.
Save adeyahya/4b9018848301a734c1d16e3f11259ede to your computer and use it in GitHub Desktop.
if ( 'IntersectionObserver' in window ) {
const observer = new IntersectionObserver(callback, options)
observer.observe($el)
} else {
import(/* webpackChunkName: "intersection-observer" */ 'intersection-observer').then(_ => {
const observer = new IntersectionObserver(callback, options)
observer.observe($el)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment