Im implementing animations in my react app to enhance the user experience. I am trying to achieve a slide-in effect for a div to appear and a slide-out effect for it to disappear.
My current tech stack includes bootstrap 5.1.0
and react-bootstrap 1.6.1
.
One solution I have come up with is wrapping the content within a div and toggling its maxHeight
property between window.innerHeight
and 0
as needed. Additionally, I applied a custom CSS class:
.transition-height{
transition: max-height 0.5s ease-in-out;
}
The issue I am facing is that when I close the div, there is a delay due to the animation starting from a high value of maxHeight. Since the height target is dynamic based on the content length, I used window.innerHeight
.
You can view the code behavior on codesandbox.
Any suggestions on how to resolve this issue?