Skip to content

Commit f306a82

Browse files
Jason Moonmikesherov
Jason Moon
authored andcommitted
Sortable: update placeholder when axis is x or y for connected lists. Fixed #8301 - Placeholder doesn't move when using connectWith option
1 parent ae4753b commit f306a82

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

tests/unit/sortable/sortable_options.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,34 @@ test( "#8792: issues with floated items in connected lists", function() {
151151
equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" );
152152
});
153153

154+
test( "#8301: single axis with connected list", function() {
155+
expect( 1 );
156+
157+
var element = $( "#sortable" ).sortable({
158+
axis: "y",
159+
tolerance: "pointer",
160+
connectWith: ".connected"
161+
});
162+
163+
$( "<ul class='connected'><li>Item 7</li><li>Item 8</li></ul>" )
164+
.sortable({
165+
axis: "y",
166+
tolerance: "pointer",
167+
connectWith: "#sortable",
168+
receive: function() {
169+
ok( true, "connected list received item" );
170+
}
171+
})
172+
.insertAfter( element );
173+
174+
element.find( "li" ).eq( 0 ).simulate( "drag", {
175+
handle: "corner",
176+
dx: -1,
177+
dy: 114,
178+
moves: 1
179+
});
180+
});
181+
154182
/*
155183
test("{ connectWith: false }, default", function() {
156184
ok(false, "missing test - untested code is broken code.");

ui/jquery.ui.sortable.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,9 @@ $.widget("ui.sortable", $.ui.mouse, {
535535
b = t + item.height,
536536
dyClick = this.offset.click.top,
537537
dxClick = this.offset.click.left,
538-
isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
538+
isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
539+
isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
540+
isOverElement = isOverElementHeight && isOverElementWidth;
539541

540542
if ( this.options.tolerance === "pointer" ||
541543
this.options.forcePointerForContainers ||

0 commit comments

Comments
 (0)