Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 447
Tim Avatar asked Aug 06 '13 17:08

Tim


2 Answers

Fixed JS Bin

Fix delay solution:

Put cubic-bezier(0, 1, 0, 1) transition function for element.

.text {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.5s cubic-bezier(0, 1, 0, 1);
  &.full {
    max-height: 1000px;
    transition: max-height 1s ease-in-out;
}
like image 103
egor.xyz Avatar answered Oct 14 '22 15:10

egor.xyz


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 that 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

like image 21
Jay Rafferty Avatar answered Oct 14 '22 15:10

Jay Rafferty