Search code examples
css-transitions

How to Remove Delay on Css3 Slide out transition which uses max-height transition


I'm having an issue with a transition I'm using to slide a panel in and out.

Please take a look at the following jsbin http://jsbin.com/uvejuj/1/

Notice that when i click the toggle button the first time the transition occurs immediately.

However if i click the button again to close then the transition delays the amount of time of the transition before it executes.

What is causing the delay on close out and how can i get rid of it?

Thanks


Solution

  • It's because you're animating between 0 and 1000px max-height, but your content is only about 120px high. The delay is the animation happening on the 880 pixels you can't see.

    Either set max-height to the known height of your content (if you know it - example: http://jsbin.com/onihik/1/) or try a different method. Maybe something like https://stackoverflow.com/a/6486082/2619379