Hello Forum,
I am new to GSAP and Vue and I am trying to achieve transition like this:
https://tympanus.net/Development/PageTransitions/ -> Choose a transition -> Move -> Move to Bottom/From Top
using GSAP in Vue 3 project.
<router-view v-slot="{ Component }">
<transition mode="out-in" @before-enter="beforeEnter" @enter="enter" @before-leave="beforeLeave" @leave="leave">
<component :is="Component" class="component-wrapper"></component>
</transition>
</router-view>
setup() {
const beforeEnter = (el) => {
console.log('before enter');
el.style.transform = 'translateY(-100vh)';
};
const enter = (el) => {
console.log('enter');
gsap.to(el, {
duration: 1,
opacity: 1,
translateY: '0vh',
ease: 'power1.inOut',
});
};
const beforeLeave = (el) => {
console.log('before leave');
el.style.transform = 'translateY(0vh)';
};
const leave = (el, done) => {
console.log('leave');
gsap.to(el, {
duration: 1,
opacity: 1,
translateY: '100vh',
ease: 'power1.inOut',
onComplete: done,
});
};
return { beforeEnter, enter, beforeLeave, leave };
}
With this code I get almost what I want to achieve, which is:
before leaving - leaving: the entire content of the current route moves to bottom from top;
As mode property in the transition tag is set to "out-in", I see the white page during transition stages mentioned above
before entering - entering: the entire content of the new current route moves to bottom from top;
The problem is that the next router content should move synchronously without waiting until the leaving of previous content completes.
So mode property should not be set at all (I guess)
But removing it leads to transition mix because I don't know exactly what should I change in the hooks methods.
Hope you got the idea of what I am trying to do.
Best regards,
Daniel