-
I have the following structure, is there a way to animate the exit of "B"? <AnimatePresence>
<Motion v-if="...">
A
<Motion :exit="{...}">
B
</Motion>
</Motion>
</AnimatePresence> |
Beta Was this translation helpful? Give feedback.
Answered by
rick-hup
Feb 23, 2025
Replies: 2 comments
-
you can use <script setup lang="ts">
import { ref } from 'vue';
import { motion, AnimatePresence } from 'motion-v';
const isShow = ref(true);
</script>
<template>
<button @click="isShow = !isShow">Toggle</button>
<AnimatePresence>
<motion.div
v-if="isShow"
initial="hidden"
animate="visible"
exit="exit"
style="width: 200px; height: 200px; background-color: rgb(239, 68, 68)"
>
<motion.div
:variants="{
hidden: { opacity: 0, y: 100 },
visible: { opacity: 1, y: 0 },
exit: { opacity: 0, y: -100 },
}"
style="width: 100px; height: 100px; background-color: rgb(68, 114, 239)"
>
</motion.div>
</motion.div>
</AnimatePresence>
</template>
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
wouterlms
-
Thank you very much! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can use
variants
to controle chidren animation.