Skip to content
Permalink
Browse files

Sortable: calculating item positions on the fly and setting the direc…

…tion 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
  • Loading branch information...
courthead authored and scottgonzalez committed Apr 22, 2012
1 parent 033f83f commit c42bdcecf825e295f483413f8d20b2079947faec
Showing with 2 additions and 1 deletion.
  1. +2 −1 ui/jquery.ui.sortable.js
@@ -731,9 +731,10 @@ $.widget("ui.sortable", $.ui.mouse, {
var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
for (var j = this.items.length - 1; j >= 0; j--) {
if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
var cur = this.containers[innermostIndex].floating ? this.items[j].item.offset().left : this.items[j].item.offset().top;
if(Math.abs(cur - base) < dist) {
dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
this.direction = (cur - base > 0) ? 'down' : 'up';
}
}

0 comments on commit c42bdce

Please sign in to comment.
You can’t perform that action at this time.