[Regression] Panning can be locked on the X axis while the UI is only scrollable on Y [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Wed, 03 Nov 2010 14:46:23 +0100
changeset 66947 1988636edcc1e74e626481b059dbf73205493126
parent 66946 5cd1a037b0dde012f102c06cee0318eb1af6fec7
child 66948 98999850ba120f797d49e28dfb3d5062f7fa13ad
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
[Regression] Panning can be locked on the X axis while the UI is only scrollable on Y [r=mfinkle]
mobile/chrome/content/input.js
--- a/mobile/chrome/content/input.js
+++ b/mobile/chrome/content/input.js
@@ -208,17 +208,17 @@ MouseModule.prototype = {
     }
 
     // Do pan
     if (dragger) {
       let draggable = dragger.isDraggable(targetScrollbox, targetScrollInterface);
       dragData.locked = !draggable.x || !draggable.y;
       if (draggable.x || draggable.y) {
         this._dragger = dragger;
-        this._doDragStart(aEvent);
+        this._doDragStart(aEvent, draggable);
       }
     }
 
     // When panning starts over an input field, focus should not change
     let inputField = this._getTargetInputField(aEvent.originalTarget);
     if (inputField && this._dragger) {
       this._inputField = inputField;
       aEvent.preventDefault();
@@ -306,22 +306,22 @@ MouseModule.prototype = {
       if (dragData.isPan())
         this._longClickTimeout.clear();
     }
   },
 
   /**
    * Inform our dragger of a dragStart.
    */
-  _doDragStart: function _doDragStart(event) {
+  _doDragStart: function _doDragStart(aEvent, aDraggable) {
     let dragData = this._dragData;
-    dragData.setDragStart(event.screenX, event.screenY);
+    dragData.setDragStart(aEvent.screenX, aEvent.screenY, aDraggable);
     this._kinetic.addData(0, 0);
     if (!this._kinetic.isActive())
-      this._dragger.dragStart(event.clientX, event.clientY, event.target, this._targetScrollInterface);
+      this._dragger.dragStart(aEvent.clientX, aEvent.clientY, aEvent.target, this._targetScrollInterface);
   },
 
   /** Finish a drag. */
   _doDragStop: function _doDragStop() {
     let dragData = this._dragData;
     if (!dragData.dragging)
       return;
 
@@ -683,22 +683,27 @@ DragData.prototype = {
       this.prevPanX = prevX;
       this.prevPanY = prevY;
     }
 
     this.sX = sX;
     this.sY = sY;
   },
 
-  setDragStart: function setDragStart(screenX, screenY) {
+  setDragStart: function setDragStart(screenX, screenY, aDraggable) {
     this.sX = this._originX = screenX;
     this.sY = this._originY = screenY;
     this.dragging = true;
-    this.locked = false;
-    this.stayLocked = false;
+
+    // If the target area is pannable only in one direction lock it early
+    // on the right axis
+    this.lockedX = !aDraggable.x ? screenX : null;
+    this.lockedY = !aDraggable.y ? screenY : null;
+    this.stayLocked = this.lockedX || this.lockedY;
+    this.locked = this.stayLocked;
   },
 
   endDrag: function endDrag() {
     this._resetActive();
     this.dragging = false;
   },
 
   /** Returns true if drag should pan scrollboxes.*/