Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The arguments to the step function are fixed by the animation infrastructure - you can't add arguments to it as it is called by the infrastructure with a fixed set of arguments. You could make a stub function (kind of like you did) and add arguments and then call your own function.</p> <pre><code>Animator:function(obj,aniArgs,duration,aniEasArgs,delay,stepFunction,completeFunction){ // initialize angle var angle = 0; obj.stop(true,true).animate(aniArgs, {duration:parseInt(duration,10),queue:false,specialEasing:aniEasArgs, step:function(now,fx){ if($.isFunction(stepFunction)){ // convert these args into an array var args = Array.prototype.slice.call(arguments, 0); // add angle onto existing arguments args.push(angle); // call the stepFunction with new arg added on to the end stepFunction.apply(this,args); }; },complete:function(){ if($.isFunction(completeFunction)){ completeFunction.apply(this,arguments); };}}); }; } </code></pre> <p>Or, you can use <code>.data()</code> on the object begin animated to store any variable for the duration of the animation. Set the angle on the object before you start the animation and you should be able to access it and update it from within the step function by referencing <code>$(this).data()</code>. </p> <p>This keeps you from having to use global variables and supports animating multiple objects at the same time.</p> <p>As others have pointed out, a good animation calculates the next position each time based on the elapsed time, not on the number of times the step function has been called. This allows you to stay on-time even if the animation happens to fall behind a little bit due to other things going on in the browser.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload