Javascript Animation Toogle
- by user1507270
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.