[perf-web] Make the exclusive-dragging behavior locking



commit c40d963ce13c4d9b28e79e9b844f401c21503700
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sun Sep 14 16:34:43 2014 -0400

    Make the exclusive-dragging behavior locking
    
    For the left pane, we use an exclusive behavior where you can
    grab-scroll left/right or up/down but not both at once. Make this
    "lock" once more than 10 pixels have been scrolled in one direction
    or the other to prevent weird jumping behavior if the user drifts
    off diagonally.

 static/main.js |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/static/main.js b/static/main.js
index e9cc479..4d6fefd 100644
--- a/static/main.js
+++ b/static/main.js
@@ -657,6 +657,7 @@ function ScrollHandler(params)
             this.updateDrag(event.clientX, event.clientY);
             $( document.body ).removeClass('panning');
             this.dragStartX = null;
+            this.dragLocked = null;
             event.preventDefault();
             event.stopPropagation();
         }
@@ -680,10 +681,20 @@ ScrollHandler.prototype.updateDrag = function(x, y) {
     var deltaY = y - this.dragStartY;
 
     if (this.exclusive) {
-        if (Math.abs(deltaX) > Math.abs(deltaY))
-            deltaY = 0;
-        else
-            deltaX = 0;
+        if (this.dragLocked != null) {
+            if (this.dragLocked == 'x')
+                deltaY = 0;
+            else
+                deltaX = 0;
+        } else {
+            if (Math.abs(deltaX) > Math.abs(deltaY))
+                deltaY = 0;
+            else
+                deltaX = 0;
+
+            if (Math.max(Math.abs(deltaX), Math.abs(deltaY)) > 10)
+                this.dragLocked = deltaX != 0 ? 'x' : 'y';
+        }
     }
 
     if (this.scrollFunctionX)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]