I'm trying to set an exit animation to my components in next js but I'm only able to give an initial animation.
Can someone tell me what is going wrong here??
Here is my sample code:
<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>