]> source.dussan.org Git - jquery-ui.git/commitdiff
Sortable: calculating item positions on the fly and setting the direction variable...
authorCourthead <courtlandallen@gmail.com>
Sun, 22 Apr 2012 01:33:49 +0000 (18:33 -0700)
committerScott González <scott.gonzalez@gmail.com>
Tue, 22 May 2012 12:00:20 +0000 (08:00 -0400)
ui/jquery.ui.sortable.js

index 55a64590bbb402936c3bc920150f3165dad21937..88c8aa374b17b3f91c409dcfd69ced34e4485c5e 100644 (file)
@@ -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';
                                }
                        }