Hello,
I am working on a wordpress website and incorporated Gsap to create a nice animation but all of a sudden the Gsap animation doesn't work until the user clicks on the screen. This seems to be for both Mobile and Desktop. I was wondering why this may be happening and how I can fix the issue.
Website: lisapalmer.me ]
My JS Code:
let tl = gsap.timeline({ defaults: { ease: "sine.ease" } }),
current = window.location.pathname,
mediaQuery = window.matchMedia("(max-width: 921px)");
mediaQuery.matches
? tl
.from(".text", { duration: 1, y: -150, delay: 0.25, stagger: 0.1 })
.fromTo(
".astra-logo-svg",
{ duration: 1, opacity: 0 },
{ duration: 1, delay: 0.8, opacity: 1 },
"<"
)
.from("#heading_wave", { duration: 1.5, opacity: 0 }, "<.6")
.to(".header-hide", { duration: 1, opacity: 1, stagger: 0.2 }, "<")
: "/" == current
? tl
.from(".text", { duration: 1, y: -150, delay: 0.25, stagger: 0.1 })
.fromTo(
".menu-link",
{ y: 25 },
{ duration: 1, y: 0, opacity: 1, stagger: 0.2 }
)
.fromTo(
".astra-logo-svg",
{ duration: 1, opacity: 0 },
{ duration: 1, delay: 0.8, opacity: 1 },
"<"
)
.from("#heading_wave", { duration: 1.5, opacity: 0 }, "<.6")
.to(".header-hide", { duration: 1, opacity: 1, stagger: 0.2 }, "<")
: tl
.to(".menu-link", { duration: 1, y: 0, opacity: 1, stagger: 0.2 })
.fromTo(
".astra-logo-svg",
{ duration: 1, opacity: 0 },
{ duration: 1, opacity: 1 },
"<.9"
);
Thanks,
Andrew Rivera