bug 468729. make sidebars pop open or closed. r=vlad

This commit is contained in:
Stuart Parmenter 2008-12-13 06:22:02 -08:00
parent 7493ac4c25
commit 0f6e657405
2 changed files with 56 additions and 0 deletions

View File

@ -356,6 +356,26 @@ KineticPanningModule.prototype = {
this._owner.ungrab(this);
this._dragData.reset();
this._kineticData.reset();
// Make sure that sidebars don't stay partially open
// XXX this might should live somewhere else
let [leftVis,] = ws.getWidgetVisibility("tabs-container", false);
if (leftVis != 0 && leftVis != 1) {
let w = document.getElementById("tabs-container").getBoundingClientRect().width;
if (leftVis >= 0.6666)
ws.panBy(w, 0, true);
else
ws.panBy(-leftVis * w, 0, true); // XXX don't hardcode the width
} else {
let [rightVis,] = ws.getWidgetVisibility("browser-controls", false);
if (rightVis != 0 && rightVis != 1) {
let w = document.getElementById("browser-controls").getBoundingClientRect().width;
if (rightVis >= 0.6666)
ws.panBy(-w, 0, true);
else
ws.panBy(rightVis * w, 0, true); // XXX don't hardcode the width
}
}
},
};

View File

@ -232,6 +232,30 @@ wsRect.prototype = {
other._b <= this._b);
},
intersect: function(r2) {
let xmost1 = this.x + this.width;
let ymost1 = this.y + this.height;
let xmost2 = r2.x + r2.width;
let ymost2 = r2.y + r2.height;
let x = Math.max(this.x, r2.x);
let y = Math.max(this.y, r2.y);
let temp = Math.min(xmost1, xmost2);
if (temp <= x)
return null;
let width = temp - x;
temp = Math.min(ymost1, ymost2);
if (temp <= y)
return null;
let height = temp - y;
return new wsRect(x, y, width, height);
},
intersects: function(other) {
let xok = (other._l > this._l && other._l < this._r) ||
(other._r > this._l && other._r < this._r) ||
@ -456,6 +480,18 @@ WidgetStack.prototype = {
return visibleStackRect.intersects(state.rect);
},
// getWidgetVisibility: returns the percentage that the widget is visible
getWidgetVisibility: function (wid) {
let state = this._getState(wid);
let visibleStackRect = new wsRect(0, 0, this._viewingRect.width, this._viewingRect.height);
let visibleRect = visibleStackRect.intersect(state.rect);
if (visibleRect)
return [visibleRect.width / state.rect.width, visibleRect.height / state.rect.height]
return [0, 0];
},
// offsetAll: add an offset to all widgets
offsetAll: function (x, y) {
this.globalOffsetX += x;