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

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 var currentOffset = null;
michael@0 2 var maxOffset = null;
michael@0 3 var property = "left";
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
michael@0 62

mercurial