I have the exact same problem, all of my animations that were suppose to start with a ScrollTrigger just plays as soon as the page loads.
I am using React, GSAP and LocomotiveScroll, everything seems to work perfectly fine on build, however, when deploying to vercel the ScrollTrigger is no longer recongnized.
I've tried to add gsap.registerPlugin(ScrollTrigger) to all of my useEffects() and imported everything from "gsap/all" but to no avail.
This is the error message I get:
react_devtools_backend.js:2655 Invalid property scrollTrigger set to {trigger: div, start: 'top center', end: 'bottom bottom', scroller: '#main-container', scrub: true} Missing plugin? gsap.registerPlugin()
useLocoScroll();
const mainRef = useRef();
useEffect(() => {
gsap.registerPlugin(ScrollTrigger);
const ctx = gsap.context(() => {
gsap.fromTo('#curtainTop', {
y: "-50vh"
}, {
y: "50vh",
ease: 'none',
scrollTrigger: {
trigger : '#main',
start: 0,
end: '+=50%',
scrub: true,
scroller: "#main-container",
lazy: false
}
})
gsap.fromTo('#curtainBottom', {
y: "50vh"
},
{
y: 0,
ease: 'none',
scrollTrigger: {
trigger : '#main',
start: 0,
end: '+=50%',
scrub: true,
scroller: "#main-container",
lazy: false
}
})
gsap.to('#main', {
opacity: 0,
zIndex: -1,
ease: 'none',
scrollTrigger: {
trigger : '#main',
start: 0,
end: '+=50%',
scrub: true,
scroller: "#main-container",
lazy: false
}
})
})
return () => {
ctx.revert()
};
})