jQuery has a .stop()
method that halts animations. You would need to listen for clicks, and then start/stop the animation accordingly using .stop()
. I'm thinking you would need to use the true flag to clear your animation queue, so the stop doesn't just "pause" the animation, but that's up to you. You would then use a closure to keep track of the "toggle status" and start the animation back up when your div is toggled the other way.
$('#animation').stop(false);
jQuery .stop documentation: http://api.jquery.com/stop/