Since I've been experimenting with Nuxt3 and animation libraries, I came across an issue for which I need help finding a solution for.
I want to do an easy transition with some Javascript hooks no CSS/basic transitions. When a page loads (onEnter), I want to reduce the height of a fixed black rectangle but for example sake, I'm just going to use the Nuxt example:
<script setup lang="ts">
definePageMeta({
pageTransition: {
name: 'custom-flip',
mode: 'out-in',
onBeforeEnter: (el) => {
console.log('Before enter...')
},
onEnter: (el, done) => {},
onAfterEnter: (el) => {}
}
})
</script>
Everything working fine till you want to add an onBeforeLeave, onLeave or onAfterLeave hook.:
<script setup lang="ts">
definePageMeta({
pageTransition: {
name: 'custom-flip',
mode: 'out-in',
onBeforeEnter: (el) => {
console.log('Before enter...')
},
onEnter: (el, done) => {},
onAfterEnter: (el) => {},
//nothings is logging underneath this
onBeforeLeave: (el) => {},
onLeave: (el, done) => {
console.log('this is not logging to the console...')
},
onAfterLeave: (el) => {}
}
})
</script>
Someone who experienced the same issue?
It is because you need to call the
done()
function for the hook to move forward. Fortunately, Vue official documentation is more explicit about it:https://vuejs.org/guide/built-ins/transition.html#javascript-hooks