Thank you both for your answers! Removing the extra watcher results into a working example, but sadly not in my project. I added the main reference to the watcher, because sometimes (especially on page refresh) the main.value is undefined, which results into not animating the nodes that I want at all. I'm not sure how that differs from the example project.
For example in a component I have the following:
watch(
() => transitionState.transitionComplete,
(isTransitionComplete) => {
if (isTransitionComplete) {
ctx.value = gsap.context((self) => {
console.log('homepageRef', homepageVideoRef.value)
const text = self.selector?.('.homepage-video__cta')
gsap.set(text, {
x: -100,
opacity: 0,
duration: 2,
})
gsap.to(text, {
x: 0,
opacity: 1,
ease: 'Power4.easeOut',
scrollTrigger: {
trigger: text,
start: '-=200 50%',
end: 'bottom 50%',
scrub: 1,
},
})
}, homepageVideoRef.value)
}
}
)
onUnmounted(() => {
ctx.value?.revert()
})
I'm logging the homepageRef to the console. I'm seeing the following:
Do you have any experience with this issue before? The reference is available in the onMounted state, but then the page transition doesn't work anymore.
Edit: Not sure if it will help in any way, but I made a screen recording of the issue that I am facing. It can be watched here: https://streamable.com/wadxn2
Edit 2: I managed to solve the issues. There were two problems, one where the reference is undefined. I fixed that with the not so elegant setTimeout option (but it works for now). The other issue that the animation was not starting correctly, because I was using a stacked effect with CSS display sticky. I replaced it with the pin option of ScrollTrigger for the same effect.
Thank you for your support, time and warm welcome to the forum!