I'm trying to make an animated countdown clock using framer motion.
I understand that any child of <AnimatePresence/> with a unique key should animate into and out of the parent. However, I just can't get the exit to work. Is it the way I'm injecting/replacing the spans?
<AnimatePresence>
<div>
{timeString.split("").map((val, i) => (
<motion.span
key={val + i}
initial={{ y: 50, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
exit={{ y: -50, opacity: 0 }} <--- this doesn't seem to work
transition={{
x: { duration: 1, type: "spring", stiffness: 300, damping: 30 },
opacity: { duration: 0.5 }
}}
>
{val}
</motion.span>
))}
</div>
</AnimatePresence>
EDIT: to clarify, i'm trying to get the numbers to enter from the bottom and leave via the top. Currently, they only enter from the bottom and there is no exit animation.