]> source.dussan.org Git - jquery-ui.git/commitdiff
draggable: draggable should not scroll when constrained in one axis (fixes #3868)
authorPaul Bakaus <paul.bakaus@googlemail.com>
Fri, 23 Jan 2009 13:10:17 +0000 (13:10 +0000)
committerPaul Bakaus <paul.bakaus@googlemail.com>
Fri, 23 Jan 2009 13:10:17 +0000 (13:10 +0000)
ui/ui.draggable.js

index aca441b5b8cf129b3e0ec9eecf8a9c4f85cd34ed..71cebbc48c82e8e0d209f21eda3489b36c25f7f0 100644 (file)
@@ -606,28 +606,36 @@ $.ui.plugin.add("draggable", "scroll", {
 
                if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
 
-                       if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
-                               i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
-                       else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
-                               i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
-
-                       if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
-                               i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
-                       else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
-                               i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
+                       if(!o.axis || o.axis != 'x') {
+                               if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
+                                       i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
+                               else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
+                                       i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
+                       }
+                       
+                       if(!o.axis || o.axis != 'y') {
+                               if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
+                                       i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
+                               else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
+                                       i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
+                       }
 
                } else {
-
-                       if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
-                               scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
-                       else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
-                               scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
-
-                       if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
-                               scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
-                       else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
-                               scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
-
+                       
+                       if(!o.axis || o.axis != 'x') {
+                               if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
+                                       scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
+                               else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
+                                       scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
+                       }
+                       
+                       if(!o.axis || o.axis != 'y') {
+                               if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
+                                       scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
+                               else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
+                                       scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
+                       }
+                       
                }
 
                if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)