Bug 607657 (followup) - Allow sidebar panning again after a short delay [r=stechz]

--HG--
extra : rebase_source : 2a43992878cada515d417d56777afd1a42e74d09
This commit is contained in:
Matt Brubeck 2011-02-25 11:42:21 -08:00
parent 240e35e20a
commit df0b0a6745
2 changed files with 25 additions and 10 deletions

View File

@ -1122,6 +1122,11 @@ Browser.MainDragger.prototype = {
let bcr = browser.getBoundingClientRect();
this._contentView = browser.getViewAt(clientX - bcr.left, clientY - bcr.top);
this._stopAtSidebar = 0;
this._hitSidebar = false;
if (this._sidebarTimeout) {
clearTimeout(this._sidebarTimeout);
this._sidebarTimeout = null;
}
},
dragStop: function dragStop(dx, dy, scroller) {
@ -1130,15 +1135,20 @@ Browser.MainDragger.prototype = {
Browser.tryUnfloatToolbar();
},
dragMove: function dragMove(dx, dy, scroller) {
dragMove: function dragMove(dx, dy, scroller, aIsKinetic) {
let doffset = new Point(dx, dy);
// First calculate any panning to take sidebars out of view
let panOffset = this._panControlsAwayOffset(doffset);
// If we started at one sidebar, stop when we get to the other.
if (panOffset.x != 0 && !this._stopAtSidebar)
if (panOffset.x != 0 && !this._stopAtSidebar) {
this._stopAtSidebar = panOffset.x; // negative: stop at left; positive: stop at right
this._sidebarTimeout = setTimeout(function(self) {
self._stopAtSidebar = 0;
self._sidebarTimeout = null;
}, 350, this);
}
if (this._contentView && !this._contentView.isRoot()) {
this._panContentView(this._contentView, doffset);
@ -1149,14 +1159,19 @@ Browser.MainDragger.prototype = {
// Do content panning
this._panContentView(getBrowser().getRootView(), doffset);
if (this._hitSidebar && aIsKinetic)
return; // No kinetic panning after we've stopped at the sidebar.
// Any leftover panning in doffset would bring controls into view. Add to sidebar
// away panning for the total scroll offset.
if (this._stopAtSidebar > 0 && doffset.x > 0)
if ((this._stopAtSidebar > 0 && doffset.x > 0) ||
(this._stopAtSidebar < 0 && doffset.x < 0)) {
if (doffset.x != panOffset.x)
this._hitSidebar = true;
doffset.x = panOffset.x;
else if (this._stopAtSidebar < 0 && doffset.x < 0)
doffset.x = panOffset.x;
else
} else {
doffset.add(panOffset);
}
Browser.tryFloatToolbar(doffset.x, 0);
this._panScroller(Browser.controlsScrollboxScroller, doffset);

View File

@ -84,7 +84,7 @@ const kStateActive = 0x00000001;
* Signals the end of a drag. The dx, dy parameters may be non-zero to
* indicate one last drag movement.
*
* dragMove(dx, dy, scroller)
* dragMove(dx, dy, scroller, isKinetic)
* Signals an input attempt to drag by dx, dy.
*
* There is a default dragger in case a scrollable element is dragged --- see
@ -393,9 +393,9 @@ MouseModule.prototype = {
* but then KineticController would be adding to its own data as it signals
* the dragger of dragMove()s.
*/
_dragBy: function _dragBy(dX, dY) {
_dragBy: function _dragBy(dX, dY, aIsKinetic) {
let dragData = this._dragData;
let dragged = this._dragger.dragMove(dX, dY, this._targetScrollInterface);
let dragged = this._dragger.dragMove(dX, dY, this._targetScrollInterface, aIsKinetic);
if (dragged && !this._waitingForPaint) {
this._waitingForPaint = true;
mozRequestAnimationFrame(this);
@ -901,7 +901,7 @@ KineticController.prototype = {
}
let panned = false;
try { panned = self._panBy(Math.round(-dx), Math.round(-dy)); } catch (e) {}
try { panned = self._panBy(Math.round(-dx), Math.round(-dy), true); } catch (e) {}
if (!panned)
self.end();
else