Skip to content

Instantly share code, notes, and snippets.

@arijitMondal
Last active March 17, 2021 16:27
Show Gist options
  • Save arijitMondal/215cc04436856f63a8375161ce5089dc to your computer and use it in GitHub Desktop.
Save arijitMondal/215cc04436856f63a8375161ce5089dc to your computer and use it in GitHub Desktop.
if (
typeof window !== 'undefined' &&
'IntersectionObserver' in window &&
'IntersectionObserverEntry' in window &&
'intersectionRatio' in window.IntersectionObserverEntry.prototype
) {
let observer = new IntersectionObserver()
//rest of the code
} else {
import('intersection-observer').then(() => {
let observer = new IntersectionObserver()
//rest of code
})
}
@renzo01
Copy link

renzo01 commented Mar 17, 2021

I put this code in each page or I use only in _app,js?

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