-
-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Description
I am trying to implement a leave transition using the transition element like in your demo so that I can show and hide an element with nice transitions
I'm using Nuxt 3.0.0-rc.10 and @vueuse/motion 2.0.0-beta.22
Here is a simple example below.
<template>
<div class="p-8">
<div class="flex">
<button class="px-2 py-4 mr-4 bg-blue-500 text-white" @click="toggle=true">
Show
</button>
<button class="px-2 py-4 bg-blue-500 text-white" @click="toggle=false">
Hide
</button>
<div>{{ toggle }}</div>
</div>
<transition
:css="false"
@leave="(_, done) => motions.transition.leave(done)"
>
<div
v-if="toggle"
v-motion="'transition'"
:initial="{ opacity: 0, y: -200 }"
:enter="{ opacity: 1, y: 0 }"
:leave="{ opacity: 0, y: -200 }"
style="width: 200px; height: 200px"
class="m-6 bg-green-900"
>
</div>
</transition>
</div>
</template>
<script setup>
import { useMotions } from '@vueuse/motion'
const toggle = useState('toggle', () => false)
definePageMeta({
layout: 'empty'
});
const motions = useMotions()
</script>
If I remove the element then it works as expected with the div animating in when I click show and then disappearing instantly by clicking hide.
I can't see what I am doing wrong here, if there is a bug or perhaps incompatability with the version I am using.
fgeierst and PatrikBird
Metadata
Metadata
Assignees
Labels
No labels