Skip to content

Commit c42bdce

Browse files
courtheadscottgonzalez
authored andcommitted
Sortable: calculating item positions on the fly and setting the direction variable when inserting an item into a different sortable. Fixed #8268 - Items may not be inserted into the correct position when dragged between connected sortables
1 parent 033f83f commit c42bdce

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ui/jquery.ui.sortable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,10 @@ $.widget("ui.sortable", $.ui.mouse, {
731731
var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
732732
for (var j = this.items.length - 1; j >= 0; j--) {
733733
if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
734-
var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
734+
var cur = this.containers[innermostIndex].floating ? this.items[j].item.offset().left : this.items[j].item.offset().top;
735735
if(Math.abs(cur - base) < dist) {
736736
dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
737+
this.direction = (cur - base > 0) ? 'down' : 'up';
737738
}
738739
}
739740

0 commit comments

Comments
 (0)