]> source.dussan.org Git - jquery-ui.git/commitdiff
Sortable: update placeholder when axis is x or y for connected lists. Fixed #8301...
authorJason Moon <jmoon@socialcast.com>
Thu, 21 Mar 2013 14:56:39 +0000 (09:56 -0500)
committerScott González <scott.gonzalez@gmail.com>
Wed, 17 Apr 2013 18:50:11 +0000 (14:50 -0400)
(cherry picked from commit f306a826a4d3b4c36c3f86cb5feeee23bb0db4c3)

tests/unit/sortable/sortable_options.js
ui/jquery.ui.sortable.js

index 8dcf0e82fa4561382bf5c93471392b75444e29c4..a499c01c1fc7d3e3b306fbed023d9f3d25154a8c 100644 (file)
@@ -151,6 +151,34 @@ test( "#8792: issues with floated items in connected lists", function() {
        equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" );
 });
 
+test( "#8301: single axis with connected list", function() {
+       expect( 1 );
+
+       var element = $( "#sortable" ).sortable({
+               axis: "y",
+               tolerance: "pointer",
+               connectWith: ".connected"
+       });
+
+       $( "<ul class='connected'><li>Item 7</li><li>Item 8</li></ul>" )
+               .sortable({
+                       axis: "y",
+                       tolerance: "pointer",
+                       connectWith: "#sortable",
+                       receive: function() {
+                               ok( true, "connected list received item" );
+                       }
+               })
+               .insertAfter( element );
+
+       element.find( "li" ).eq( 0 ).simulate( "drag", {
+               handle: "corner",
+               dx: -1,
+               dy: 114,
+               moves: 1
+       });
+});
+
 /*
 test("{ connectWith: false }, default", function() {
        ok(false, "missing test - untested code is broken code.");
index efc83f3d5931fc4175617aceb0fb9004312635bd..865632db4bb37301e7e6c7e1adb17c1764030567 100644 (file)
@@ -546,7 +546,9 @@ $.widget("ui.sortable", $.ui.mouse, {
                        b = t + item.height,
                        dyClick = this.offset.click.top,
                        dxClick = this.offset.click.left,
-                       isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
+                       isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
+                       isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
+                       isOverElement = isOverElementHeight && isOverElementWidth;
 
                if ( this.options.tolerance === "pointer" ||
                        this.options.forcePointerForContainers ||