Created
August 15, 2021 09:33
-
-
Save sajadabedi/40761927c15c6fb89b988ed9e82762a8 to your computer and use it in GitHub Desktop.
Locomotive Scroll + NextJS
This file contains 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
export default function MyApp({ Component, pageProps }) { | |
useEffect(() => { | |
let scroll; | |
import('locomotive-scroll').then((locomotiveModule) => { | |
scroll = new locomotiveModule.default({ | |
el: document.querySelector('[data-scroll-container]'), | |
smooth: true, | |
smoothMobile: false, | |
resetNativeScroll: true, | |
}); | |
}); | |
// `useEffect`'s cleanup phase | |
return () => scroll.destroy(); | |
}); | |
return ( | |
<> | |
<main data-scroll-container className="container"> | |
<Component {...pageProps} /> | |
</main> | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment