Skip to content

Animating children on exit #76

Closed Answered by rick-hup
wouterlms asked this question in Q&A
Discussion options

You must be logged in to vote

you can use variants to controle chidren animation.

<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

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by wouterlms
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants