Hi @Skrypt — I've got an implementation working when navigating across pages — you have to declare the animation in the script setup, not bound to a ref, and then activate it on the onMounted hook, eg
<scriptsetup>import{ gsap } from "gsap";import{ScrollTrigger} from "gsap/ScrollTrigger";
gsap.registerPlugin(ScrollTrigger);const animation = gsap.timeline({
scrollTrigger:{
start:"top top",
end:"center top",
scrub:1,},});const logo = ref(null);
onMounted(()=>{
animation.to(logo.value,{ yPercent:-100, opacity:0, duration:1});});</script>
GSAP ScrollTrigger with Nuxt 3 not working as expected
in GSAP
Posted
Hi @Skrypt — I've got an implementation working when navigating across pages — you have to declare the animation in the script setup, not bound to a ref, and then activate it on the onMounted hook, eg