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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial