Here is jsfiddle for your problem : http://jsfiddle.net/H5g5s/22/
It involves stopping animation at the current place, and continuing on the second click.I remade your animation using jQuery to manipulate it more easily on click.
Best Regards
HTML:
<div class="divOuter" style="padding:50px;">
<div class="divInner">
hello
</div>
</div>
jQuery:
var interval,//for interval clearance
animation,//for animation freeze
start,//to determine start angle of rotation
duration;//to determine duration of animation
/*** TRANSFORM ANIMATION FUNCTION ***/
function animateDiv(startAngle){
//Determine whether animation should continue or start from 0
startAngle ? start = startAngle : start = 0;
//Determine duration in case animation continues for speed to remain same
duration = 5000/360 * (360 - start);
//Start animation
animation = $({deg: start}).animate({deg: 360}, {
duration: duration,
easing:'linear',
queue:false,
step: function(now) {
$('.divInner').css({
'-moz-transform':'rotate(' + -now + 'deg) translateX( 20px ) rotate(' + now + 'deg)',
'-webkit-transform':'rotate(' + -now + 'deg) translateX( 20px ) rotate(' + now + 'deg)',
'-o-transform':'rotate(' + -now + 'deg) translateX( 20px ) rotate(' + now + 'deg)',
'-ms-transform':'rotate(' + -now + 'deg) translateX( 20px ) rotate(' + now + 'deg)',
'transform':'rotate(' + -now + 'deg) translateX( 20px ) rotate(' + now + 'deg)'
});
}
});
}
/*** Call function ***/
animateDiv();
/*** Set interval for repeating ***/
interval = setInterval(function(){
animateDiv();
},5000);
/*** On click ***/
$(".divInner").click(function() {
/*** Determine action stop or continue ***/
//Stop
if(!$(this).hasClass('active')){
//Stop interval
clearInterval(interval);
//Freeze animation
animation.stop();
//Get current style
var style = $(this).attr('style');
//Add scale
var stylescale = style.slice(0,(style.length-1)) + ' scale(1.3)';
//attach new style
$(this).attr('style',stylescale);
}
//Continue
else {
/* get rotation value*/
var str = $(this).attr('style');
var rotate = str.search("rotate") + 8;
var deg = str.search("deg");
var angle = str.slice(rotate,deg);
/* start animation again */
animateDiv(angle);
/* sset interval again */
interval = setInterval(function(){
animateDiv();
},5000);
}
//Toggle class to determine action next time;
$(this).toggleClass('active');
});
CSS:
.divInner{
position:relative;
border:1px solid #ddd;
width:30px;
-moz-transform: rotate(0deg) translateX(20px) rotate(0deg);
-webkit-transform: rotate(0deg) translateX(20px) rotate(0deg);
-o-transform: rotate(0deg) translateX(20px) rotate(0deg);
-ms-transform: rotate(0deg) translateX(20px) rotate(0deg);
transform: rotate(0deg) translateX(20px) rotate(0deg);
cursor:pointer;
}