The .animate()
method doesn't stop the script execution. What happens is that it starts the animation and script execution continues, and busy
is immediately set to false.
What you need is to set the flag only after the animation has finished using a callback function:
if(rFormula > 168){
busy = true;
$(".block").animate({"left": "-=168px"}, "slow", function() { busy = false });
}
(Note that I also moved setting the flag here because there's no benefit in setting it before the animation begins.)
Demo: http://jsfiddle.net/pGHrP/1/ (I updated only the right button.)