tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

animate.js (1280B)


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