layout/reftests/position-dynamic-changes/relative/animate.js

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 var rfa = null;
     2 if (window.requestAnimationFrame) {
     3   rfa = requestAnimationFrame;
     4 } else if (window.mozRequestAnimationFrame) {
     5   rfa = mozRequestAnimationFrame;
     6 } else if (window.webkitRequestAnimationFrame) {
     7   rfa = webkitRequestAnimationFrame;
     8 } else if (window.msRequestAnimationFrame) {
     9   rfa = msRequestAnimationFrame;
    10 } else if (window.oRequestAnimationFrame) {
    11   rfa = oRequestAnimationFrame;
    12 }
    14 function animate(params, count) {
    15   rfa(function() {
    16     animateStep(params, count);
    17   });
    18 }
    20 function animateStep(params, count) {
    21   if (!count) {
    22     document.documentElement.removeAttribute("class");
    23     return;
    24   }
    25   var rel = document.getElementById("rel");
    26   for (prop in params) {
    27     rel.style[prop] = (parseInt(rel.style[prop]) + params[prop]) + "px";
    28   }
    29   rfa(function() {
    30     animateStep(params, count - 10);
    31   });
    32 }

mercurial