Javascript Animation Toogle

Posted by user1507270 on Stack Overflow See other posts from Stack Overflow or by user1507270
Published on 2012-07-07T09:13:21Z Indexed on 2012/07/07 9:15 UTC
Read the original article Hit count: 145

Filed under:
|

I am new to JavaScript (I had some lessons in school but those were basically basics of all basics :) ) and I am seeking for help with this animation made from scratch.

Here is a code that I wrote: http://jsfiddle.net/bPZeH/1/.

What it basically does is that it animates height of one div. What I would like to know is, how to write the function startAnimation(), so that if I click on the div while it is being animated, it will reverse animation (for instance: instead of animating height from 150px to 400px it will stop at the current value and then animate back to 150px). I basically want to make toogle from one value to the other. It would also be okay if it were able to toogle only after the animation has finished, but I would prefer the first option.

Thanky you very much.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about animation