]> source.dussan.org Git - jquery-ui.git/commitdiff
Sortable - delta direction improved
authorEduardo Lundgren <eduardolundgren@gmail.com>
Tue, 28 Oct 2008 18:05:02 +0000 (18:05 +0000)
committerEduardo Lundgren <eduardolundgren@gmail.com>
Tue, 28 Oct 2008 18:05:02 +0000 (18:05 +0000)
ui/ui.sortable.js

index 572725529e1ed211b422a83271d14596d0814d93..5406575d0915b82b7c6acdcce6dd4ff4b893b2be 100644 (file)
@@ -128,12 +128,24 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
 
                if (this.floating) {
                        if (isOverElement) {
-                               return horizontalDirection == "right" ? 2 : 1;
+
+                               if (horizontalDirection == false) {
+                                       return false;
+                               }
+
+                               var direction = horizontalDirection == "right" ? 2 : 1;
+                               return direction;
                        }
                }
                else {
                        if (isOverElement) {
-                               return verticalDirection == "down" ? 2 : 1;
+
+                               if (verticalDirection == false) {
+                                       return false;
+                               }
+
+                               var direction = verticalDirection == "down" ? 2 : 1;
+                               return direction;
                        }
                }
 
@@ -143,14 +155,26 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
        _getDragVerticalDirection: function() {
                var helperTop = this.positionAbs.top;
                var lastTop = this.lastPositionAbs.top;
-               var direction = helperTop - lastTop > 0 ? "down" : "up";
+               var delta = helperTop - lastTop;
+
+               if (delta == 0) {
+                       return false;
+               }
+
+               var direction = delta > 0 ? "down" : "up";
                return direction;
        },
 
        _getDragHorizontalDirection: function() {
                var helperLeft = this.positionAbs.left;
                var lastLeft = this.lastPositionAbs.left;
-               var direction = helperLeft - lastLeft > 0 ? "right" : "left";
+               var delta = helperLeft - lastLeft;
+
+               if (delta == 0) {
+                       return false;
+               }
+
+               var direction = delta > 0 ? "right" : "left";
                return direction;
        },