Hello everyone,
I would like to start by mentioning that I am a beginner with GSAP as well as with React.js
And my problem is the fallowing :
I am using ScrollTrigger with a create-react-app the problem is that works very well on local env but once the app is deployed the ScrollTrigger doesn't get triggered anymore. But my function does, being checked by a console.log.
I should mention that this function seats into an external file which is imported inside of the rendered component and executed by a useEffect hook once the component is mounted.
I got no errors inside deploying console, everything looks well.
Thanks in advance.
The react component!
import {
landing2Animation,
animateArrow,
} from "../../components/animationScripts";
function LandingPage2(props) {
const [width] = useWindowSize();
useEffect(() => {
animateArrow();
landing2Animation();
}, []);
return (...)
External File! The function contains gsap.from methods!
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
gsap.registerPlugin(ScrollTrigger);
const widthIn = window.innerWidth;
/// Landing 2 animation //////////////
export const landing2Animation = () => {
gsap.from(".visible", {
scrollTrigger: {
trigger: ".visible",
start: "center bottom",
end: "center bottom",
toggleActions: "restart none reverse none",
},
x: -200,
opacity: 0,
duration: 1,
});
gsap.from(".easyer", {
scrollTrigger: {
trigger: ".easyer",
start: "center bottom",
end: "center bottom",
toggleActions: "play none reverse none",
},
x: -100,
opacity: 0,
duration: 1,
});
gsap.from(".simple", {
scrollTrigger: {
trigger: ".easyer",
start: "center bottom",
end: "center bottom",
toggleActions: "play none reverse none",
},
x: 100,
opacity: 0,
duration: 1,
});
gsap.from(".noLimit", {
scrollTrigger: {
trigger: ".easyer",
start: "center bottom",
end: "center bottom",
toggleActions: "play none reverse none",
},
x: 200,
opacity: 0,
duration: 1,
});
};