Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To help you better understand how you can use the <code>step</code> function [as posted by <em>gdoron</em>]<br> I created an example using the <em>step</em> function to get the remaining time:</p> <p>(click the <code>get state!</code> button to stop the animation and retrieve the remaining time!)</p> <p><strong><a href="http://jsbin.com/akebaz/2/edit" rel="nofollow">demo with distance</a></strong><br> <strong><a href="http://jsbin.com/akebaz/3/edit" rel="nofollow">demo with opacity</a></strong></p> <p>Distance example jQuery:</p> <pre><code>var time = 4000; var distance = 300; var currentTime = 0; $('#ball').animate({ left: distance }, { duration: time, step: function (now, fx) { currentTime = Math.round((now * time) / distance); var data = fx.prop + ' ' + Math.round(now) + '; &lt;b&gt;' + currentTime + 'ms&lt;/b&gt; '; $('body').append('&lt;p&gt;' + data + '&lt;/p&gt;'); }, easing: 'linear' }); $('#getTime').click(function () { $('#ball').stop(); $('body').prepend('&lt;p&gt;currentTime is:' + currentTime + ' ms; REMAINING: ' + (time - currentTime) + 'ms&lt;/p&gt;'); }); </code></pre> <ul> <li>You can see how I used the <code>fx.prop</code> inside the <code>animation step</code> to get the (<code>left</code>) property that is currently animated. <br></li> <li>You can see how: knowing the animation time and the distance (opacity, whatever...) we can easily retrieve the 'stopped/paused' state by some simple math (<code>(now*time)/distance</code>) and thanks to the returned <code>now</code> value.</li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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