jQuery how to detect when animation has finished - :animate does not toggle off on completion
<p>When does Jquery consider that an animation is complete?</p>

<p>I ask this because I want to stop an element from being animated when it is already being animated.</p>

<p>SO posts state that the pseudo-selector :animate allows us to detect when an element is in motion. Well I have to disagree with that assertion. </p>

<p>My understanding is that :</p>

<pre><code>if ($(".menu_Bar.level_2").is(':animated')){.....
</code></pre>

<p>is set true as soon as an animation starts and and remains true through to element's animated position and indeed remains true when it is returned to it's original position.</p>

<p>From the description of :animated ...</p>

<blockquote>
  <p>Select all elements that are in the progress of an animation at the
  time the selector is run.</p>
</blockquote>

<p>I was expecting this to toggle off when the animation reached it's target. This does not appear to be the case.</p>

<p>I am therefore assuming that this should read</p>

<blockquote>
  <p>Select all elements that have been in a state of animation or are in a state of animation at the
  time the selector is run.</p>
</blockquote>

<p>I cannot find any means of toggling this on/off.</p>

<p>Am I therefore correct in my approach of using step: function?</p>

<p>I have tried the suggested the syntax on the jquery example but this fails for me.</p>

<p>I have taken a guess and tried to suppress subsequent animation based on:</p>

<pre><code>if (fx.prop: end == now;){ // animate has reached it's destination
</code></pre>

<p>This isn't working so I am lost. Could some someone please confirm that I need to be using step and if so how can we flag up that the animation is complete.</p>

<p>================================================================================ </p>

<p><strong>EDIT</strong></p>

<p>Ok I have seen the error of my ways!</p>

<p>I have simply set a flag in the completed function. This is working fine.</p>

<p>However I still do not understand how to get the step part working. I would like know how this is meant to work.</p>

<p>Also I am sure that this should be this difficult. I feel sure that I am missing something obvious here.</p>
