title: Disable a link for some time or during animation in jQuery
body: <p>I would like to disable a link during animation, I animate using backgroundPosition and when I click while the first animation is still on, it breaks the background. so to prevent that I have two questions actually:</p>
  
  <p>How to disable 'click' event on link while the element is animating (animation always lasts 4000, so it could be either while the animation is on, or by set amount of time)</p>
  
  <pre><code>$("#arrows a").on("click", function () {  
  
  var newPos = ....   
  
          $("#bg").stop().animate({
              backgroundPosition: newPos
          }, 4000) 
  });
  </code></pre>
  
  <p>And the next question is: how to actually determine if element is animated and when is not? Does it have to be stopped somehow to actually be set as on and off? I tried various options, nothing works, when I tried this code then it always displays class 'animated' - so it means it  never stops until next click? </p>
  
  <pre><code>if ($("#bg").is(":animated") ) {
              $("#game").addClass("animated");
  } else {
              $("#game").addClass("stopped");
  }
  </code></pre>
  
  <p>If I could find solution how to add those classes, it would solve the first issue with the link, cause I could then simply remove the links with css</p>
  
  <p>UPDATE:
  After 'caramba' comment with tip what to look for I moved further, animate complete was the answer, before that I was googling for couple of hours and had never stumbled upon this. Anyway, this is my code now:</p>
  
  <pre><code> $("#bg").stop().animate({
              backgroundPosition: newPos
          }, {
              queue: false,
              duration: 4000,
              complete: function() {
                  console.log("ok");
                  $("#game").addClass("completed")
                  // setTimeout(function() {
                      // $("#arrows a").unbind();
                  // }, 4000);
             }
         });
  </code></pre>
  
  <p>It adds the class nicely, but I was also trying to fit there setTimeout to disable the link for the time animation lasts, but it disabled it complete, where is the problem?</p>
  
  <p><em>PS. How do I vote the comments? I can't see any options to add votes, and I would like to thank for the comment, is it not available for newbies, or am I just blind?</em></p>