Bug 589114 - Use frame scheduling for animated Fullscreen toolbar hiding. r=dietrich

--HG--
extra : rebase_source : b2f78bd02073c0fe7710d6171302783ee8d42bc6
This commit is contained in:
Dão Gottwald 2012-01-06 20:03:57 +01:00
parent b23f5a055e
commit bf6b01bf96

View File

@ -3905,7 +3905,8 @@ var FullScreen = {
}
else {
// The user may quit fullscreen during an animation
clearInterval(this._animationInterval);
window.mozCancelAnimationFrame(this._animationHandle);
this._animationHandle = 0;
clearTimeout(this._animationTimeout);
gNavToolbox.style.marginTop = "";
if (this._isChromeCollapsed)
@ -4096,33 +4097,40 @@ var FullScreen = {
// Animate the toolbars disappearing
_shouldAnimate: true,
_isAnimating: false,
_animationTimeout: null,
_animationInterval: null,
_animateUp: function()
{
_animationTimeout: 0,
_animationHandle: 0,
_animateUp: function() {
// check again, the user may have done something before the animation was due to start
if (!window.fullScreen || !FullScreen._safeToCollapse(false)) {
FullScreen._isAnimating = false;
FullScreen._shouldAnimate = true;
if (!window.fullScreen || !this._safeToCollapse(false)) {
this._isAnimating = false;
this._shouldAnimate = true;
return;
}
var animateFrameAmount = 2;
function animateUpFrame() {
animateFrameAmount *= 2;
if (animateFrameAmount >= gNavToolbox.boxObject.height) {
this._animateStartTime = window.mozAnimationStartTime;
if (!this._animationHandle)
this._animationHandle = window.mozRequestAnimationFrame(this);
},
sample: function (timeStamp) {
const duration = 1500;
const timePassed = timeStamp - this._animateStartTime;
const pos = timePassed >= duration ? 1 :
1 - Math.pow(1 - timePassed / duration, 4);
if (pos >= 1) {
// We've animated enough
clearInterval(FullScreen._animationInterval);
window.mozCancelAnimationFrame(this._animationHandle);
gNavToolbox.style.marginTop = "";
FullScreen._isAnimating = false;
FullScreen._shouldAnimate = false; // Just to make sure
FullScreen.mouseoverToggle(false);
this._animationHandle = 0;
this._isAnimating = false;
this._shouldAnimate = false; // Just to make sure
this.mouseoverToggle(false);
return;
}
gNavToolbox.style.marginTop = (animateFrameAmount * -1) + "px";
}
FullScreen._animationInterval = setInterval(animateUpFrame, 70);
gNavToolbox.style.marginTop = (gNavToolbox.boxObject.height * pos * -1) + "px";
this._animationHandle = window.mozRequestAnimationFrame(this);
},
cancelWarning: function(event) {
@ -4223,7 +4231,7 @@ var FullScreen = {
if (!aShow && this._shouldAnimate) {
this._isAnimating = true;
this._shouldAnimate = false;
this._animationTimeout = setTimeout(this._animateUp, 800);
this._animationTimeout = setTimeout(this._animateUp.bind(this), 800);
return;
}