Slow down animation jquery?
<p>Basically, I've got a working function that I'd like to tweak a little but I can't quite figure it out. This toggles the animation of the div once pressed, although instead of just "stopping" or clearing the timer, I'd like it to slowly rotate back to 0 then clear the timer... Is this possible? </p>

<pre><code>var $elem = $('#optionBtn'),
    degree = 0,
    timer;

function rotate() {
    $elem.css({
        WebkitTransform: 'rotate(' + degree + 'deg)'
    });
    $elem.css({
        '-moz-transform': 'rotate(' + degree + 'deg)'
    });
    timer = setTimeout(function() {
        ++degree;
        rotate();
    }, 5);
}
$("#optionBtn").toggle(

function(e) {
    rotate();
},

function() {
    clearTimeout(timer);
});
</code></pre>

<p>Thankyou! </p>
