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

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 var currentOffset = null;
     2 var maxOffset = null;
     3 var property = "top";
     5 var rfa = null;
     6 if (window.requestAnimationFrame) {
     7   rfa = requestAnimationFrame;
     8 } else if (window.mozRequestAnimationFrame) {
     9   rfa = mozRequestAnimationFrame;
    10 } else if (window.webkitRequestAnimationFrame) {
    11   rfa = webkitRequestAnimationFrame;
    12 } else if (window.msRequestAnimationFrame) {
    13   rfa = msRequestAnimationFrame;
    14 } else if (window.oRequestAnimationFrame) {
    15   rfa = oRequestAnimationFrame;
    16 }
    18 function animate(from, to, prop) {
    19   currentOffset = from;
    20   maxOffset = to;
    21   if (prop) {
    22     property = prop;
    23   }
    24   rfa(animateStep);
    25 }
    27 function animateStep() {
    28   if (currentOffset <= maxOffset) {
    29     document.getElementById("child").style[property] = currentOffset + "px";
    30     currentOffset += 10;
    31     rfa(animateStep);
    32   } else {
    33     document.documentElement.removeAttribute("class");
    34   }
    35 }
    37 function toAuto(prop) {
    38   if (prop) {
    39     property = prop;
    40   }
    41   rfa(setToAuto);
    42 }
    44 function setToAuto() {
    45   document.getElementById("child").style[property] = "auto";
    46   document.documentElement.removeAttribute("class");
    47 }
    49 function fromAuto(to, prop) {
    50   maxOffset = to;
    51   if (prop) {
    52     property = prop;
    53   }
    54   rfa(setFromAuto);
    55 }
    57 function setFromAuto() {
    58   document.getElementById("child").style[property] = maxOffset + "px";
    59   document.documentElement.removeAttribute("class");
    60 }

mercurial