Bug 607657 - Don't pan from one sidebar to the other in a single swipe [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 23 Feb 2011 08:29:03 -0800
changeset 67420 de3d3f4c8a4b5461ee913a8d3114a79fd8e648da
parent 67419 a73283998e2cea6a31304057d1c9a2d10ca46663
child 67421 c98fad60f33b8b3d5646ea9fb8842ef34b12b9ed
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs607657
Bug 607657 - Don't pan from one sidebar to the other in a single swipe [r=mfinkle]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -1120,42 +1120,53 @@ Browser.MainDragger.prototype = {
   isDraggable: function isDraggable(target, scroller) {
     return { x: true, y: true };
   },
 
   dragStart: function dragStart(clientX, clientY, target, scroller) {
     let browser = getBrowser();
     let bcr = browser.getBoundingClientRect();
     this._contentView = browser.getViewAt(clientX - bcr.left, clientY - bcr.top);
+    this._stopAtSidebar = 0;
   },
 
   dragStop: function dragStop(dx, dy, scroller) {
     this._contentView = null;
     this.dragMove(Browser.snapSidebars(), 0, scroller);
     Browser.tryUnfloatToolbar();
   },
 
   dragMove: function dragMove(dx, dy, scroller) {
     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)
+      this._stopAtSidebar = panOffset.x; // negative: stop at left; positive: stop at right
+
     if (this._contentView && !this._contentView.isRoot()) {
       this._panContentView(this._contentView, doffset);
       // XXX we may need to have "escape borders" for iframe panning
       // XXX does not deal with scrollables within scrollables
     }
 
     // Do content panning
     this._panContentView(getBrowser().getRootView(), doffset);
 
     // Any leftover panning in doffset would bring controls into view. Add to sidebar
     // away panning for the total scroll offset.
-    doffset.add(panOffset);
+    if (this._stopAtSidebar > 0 && doffset.x > 0)
+      doffset.x = panOffset.x;
+    else if (this._stopAtSidebar < 0 && doffset.x < 0)
+      doffset.x = panOffset.x;
+    else
+      doffset.add(panOffset);
+
     Browser.tryFloatToolbar(doffset.x, 0);
     this._panScroller(Browser.controlsScrollboxScroller, doffset);
     this._panScroller(Browser.pageScrollboxScroller, doffset);
     this._updateScrollbars();
 
     return !doffset.equals(dx, dy);
   },