michael@0: var currentOffset = null; michael@0: var maxOffset = null; michael@0: var property = "top"; michael@0: michael@0: var rfa = null; michael@0: if (window.requestAnimationFrame) { michael@0: rfa = requestAnimationFrame; michael@0: } else if (window.mozRequestAnimationFrame) { michael@0: rfa = mozRequestAnimationFrame; michael@0: } else if (window.webkitRequestAnimationFrame) { michael@0: rfa = webkitRequestAnimationFrame; michael@0: } else if (window.msRequestAnimationFrame) { michael@0: rfa = msRequestAnimationFrame; michael@0: } else if (window.oRequestAnimationFrame) { michael@0: rfa = oRequestAnimationFrame; michael@0: } michael@0: michael@0: function animate(from, to, prop) { michael@0: currentOffset = from; michael@0: maxOffset = to; michael@0: if (prop) { michael@0: property = prop; michael@0: } michael@0: rfa(animateStep); michael@0: } michael@0: michael@0: function animateStep() { michael@0: if (currentOffset <= maxOffset) { michael@0: document.getElementById("child").style[property] = currentOffset + "px"; michael@0: currentOffset += 10; michael@0: rfa(animateStep); michael@0: } else { michael@0: document.documentElement.removeAttribute("class"); michael@0: } michael@0: } michael@0: michael@0: function toAuto(prop) { michael@0: if (prop) { michael@0: property = prop; michael@0: } michael@0: rfa(setToAuto); michael@0: } michael@0: michael@0: function setToAuto() { michael@0: document.getElementById("child").style[property] = "auto"; michael@0: document.documentElement.removeAttribute("class"); michael@0: } michael@0: michael@0: function fromAuto(to, prop) { michael@0: maxOffset = to; michael@0: if (prop) { michael@0: property = prop; michael@0: } michael@0: rfa(setFromAuto); michael@0: } michael@0: michael@0: function setFromAuto() { michael@0: document.getElementById("child").style[property] = maxOffset + "px"; michael@0: document.documentElement.removeAttribute("class"); michael@0: } michael@0: