Next Locomotive Scroll
An implementation / wrapper of locomotive-scroll for Next.JS with built in integration with GSAP
Usage
Usage is pretty straight forward:
{}
<NextLocomotiveScroll
options={{
lerp: 0.133
}}
gsap={true}
>
{}
<div>Lorem ipsum dolor sit, amet consectetur adipisicing elit.</div>
</NextLocomotiveScroll>
To use GSAP tweens with ScrollTrigger a little extra code is needed:
{}
const [loaded, __setLoaded] = useState(false);
useEffect(() => document.readyState === "complete" ? __setLoaded(true) : window.addEventListener("load", () => __setLoaded(true)), []);
useEffect(() => {
{}
const ctx = gsap.context(() => {
{}
gsap.to(polaroidsRef.current, {
x: `-${100 * polaroidsScale}%`,
scale: polaroidsScale,
scrollTrigger: {
scrub: true,
trigger: polaroidsRef.current,
end: "bottom"
}
});
});
return () => ctx.revert();
}, [
{}
loaded
]);