Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had just read that article too and was curious to try this myself. I've taken a stab at adding a wrapper to the rAF callback in browsers that don't support high-resolution timers. It uses Paul Irish's original polyfill with the following added lines:</p> <pre><code>var hasPerformance = !!(window.performance &amp;&amp; window.performance.now); // Add new wrapper for browsers that don't have performance if (!hasPerformance) { // Store reference to existing rAF and initial startTime var rAF = window.requestAnimationFrame, startTime = +new Date; // Override window rAF to include wrapped callback window.requestAnimationFrame = function (callback, element) { // Wrap the given callback to pass in performance timestamp var wrapped = function (timestamp) { // Get performance-style timestamp var performanceTimestamp = (timestamp &lt; 1e12) ? timestamp : timestamp - startTime; return callback(performanceTimestamp); }; // Call original rAF with wrapped callback rAF(wrapped, element); } } </code></pre> <p>Here's a gist of it all combined together and an updated example using the new code: </p> <p><a href="https://gist.github.com/4078614" rel="nofollow">https://gist.github.com/4078614</a></p> <p><a href="http://jsfiddle.net/timhall/XQpzU/4351/" rel="nofollow">http://jsfiddle.net/timhall/XQpzU/4351/</a></p> <p>This approach aims at normalizing the parameter that is passed into the callback function to the high-resolution timer format. You could use a similar approach, just opposite, to convert the high-resolution timer to the old format if you have existing code expecting that, but I see that as a regression.</p> <p>I'm going to try it out in one of my projects that I'm working on right now and will update the gist if I find any issues / improvements.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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