I'm facing an issue with adding an exit animation to my components in next js. Despite setting an initial animation, the exit animation doesn't seem to work as expected.
Could someone please help me figure out what I'm doing wrong here?
Below is a snippet of my code for reference:
<AnimatePresence >
<motion.div key="modalBackground" className={styles['auth-modal-layout']} key="modalBackground" initial="hidden" animate="visible" variants={
{
hidden:{
opacity:0
},
visible:{
opacity:1,
transition:{
duration:.4,
}
},
}
} >
<motion.div key="modalForm" className={styles['auth-modal-form']} initial="hidden" exit="pageExit" animate="visible" exit="hidden" variants={{
hidden:{
translateY:100,
opacity:0
},
visible:{
translateY:0,
opacity:1,
transition:{
duration:.4
}
},
pageExit:{
opacity:0,
transition:{
when:"afterChildren",
duration:.4
}
}
}} >
{modal()}
</motion.div>
</motion.div>
</AnimatePresence>