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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/reftests/position-dynamic-changes/horizontal/animate.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +var currentOffset = null;
     1.5 +var maxOffset = null;
     1.6 +var property = "left";
     1.7 +
     1.8 +var rfa = null;
     1.9 +if (window.requestAnimationFrame) {
    1.10 +  rfa = requestAnimationFrame;
    1.11 +} else if (window.mozRequestAnimationFrame) {
    1.12 +  rfa = mozRequestAnimationFrame;
    1.13 +} else if (window.webkitRequestAnimationFrame) {
    1.14 +  rfa = webkitRequestAnimationFrame;
    1.15 +} else if (window.msRequestAnimationFrame) {
    1.16 +  rfa = msRequestAnimationFrame;
    1.17 +} else if (window.oRequestAnimationFrame) {
    1.18 +  rfa = oRequestAnimationFrame;
    1.19 +}
    1.20 +
    1.21 +function animate(from, to, prop) {
    1.22 +  currentOffset = from;
    1.23 +  maxOffset = to;
    1.24 +  if (prop) {
    1.25 +    property = prop;
    1.26 +  }
    1.27 +  rfa(animateStep);
    1.28 +}
    1.29 +
    1.30 +function animateStep() {
    1.31 +  if (currentOffset <= maxOffset) {
    1.32 +    document.getElementById("child").style[property] = currentOffset + "px";
    1.33 +    currentOffset += 10;
    1.34 +    rfa(animateStep);
    1.35 +  } else {
    1.36 +    document.documentElement.removeAttribute("class");
    1.37 +  }
    1.38 +}
    1.39 +
    1.40 +function toAuto(prop) {
    1.41 +  if (prop) {
    1.42 +    property = prop;
    1.43 +  }
    1.44 +  rfa(setToAuto);
    1.45 +}
    1.46 +
    1.47 +function setToAuto() {
    1.48 +  document.getElementById("child").style[property] = "auto";
    1.49 +  document.documentElement.removeAttribute("class");
    1.50 +}
    1.51 +
    1.52 +function fromAuto(to, prop) {
    1.53 +  maxOffset = to;
    1.54 +  if (prop) {
    1.55 +    property = prop;
    1.56 +  }
    1.57 +  rfa(setFromAuto);
    1.58 +}
    1.59 +
    1.60 +function setFromAuto() {
    1.61 +  document.getElementById("child").style[property] = maxOffset + "px";
    1.62 +  document.documentElement.removeAttribute("class");
    1.63 +}
    1.64 +
    1.65 +

mercurial