Skip to content

Instantly share code, notes, and snippets.

@sajadabedi
Created August 15, 2021 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sajadabedi/40761927c15c6fb89b988ed9e82762a8 to your computer and use it in GitHub Desktop.
Save sajadabedi/40761927c15c6fb89b988ed9e82762a8 to your computer and use it in GitHub Desktop.
Locomotive Scroll + NextJS
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