diff options
author | Kris Borchers <kris.borchers@gmail.com> | 2013-10-30 00:00:18 -0500 |
---|---|---|
committer | Kris Borchers <kris.borchers@gmail.com> | 2013-11-01 15:17:05 -0500 |
commit | 601ad962e0a417bb369378ed7704a0b493eac365 (patch) | |
tree | 8e5616798d12831701a1f8ca442c3dc2a2bb3d20 /ui | |
parent | 61d16ec939c11f63419cae5bc2aa990134f6c0ff (diff) | |
download | jquery-ui-601ad962e0a417bb369378ed7704a0b493eac365.tar.gz jquery-ui-601ad962e0a417bb369378ed7704a0b493eac365.zip |
Sortable: Adjust itemWithLeastDistance algorithm in _contactContainers to properly handle dragging items to the beginning and ends of lists. Fixes #9314 - Sortable: Items cannot be dragged directly into bottom position. Fixes #9381 - Sortable: Connected list placeholders have an inaccurate initial position
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.sortable.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 9553da5dc..4ba2576c1 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -799,7 +799,7 @@ $.widget("ui.sortable", $.ui.mouse, { }, _contactContainers: function(event) { - var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating, + var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis, innermostContainer = null, innermostIndex = null; @@ -850,7 +850,8 @@ $.widget("ui.sortable", $.ui.mouse, { floating = innermostContainer.floating || this._isFloating(this.currentItem); posProperty = floating ? "left" : "top"; sizeProperty = floating ? "width" : "height"; - base = this.positionAbs[posProperty] + this.offset.click[posProperty]; + axis = floating ? "clientX" : "clientY"; + for (j = this.items.length - 1; j >= 0; j--) { if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) { continue; @@ -858,18 +859,16 @@ $.widget("ui.sortable", $.ui.mouse, { if(this.items[j].item[0] === this.currentItem[0]) { continue; } - if (floating && !this._isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) { - continue; - } + cur = this.items[j].item.offset()[posProperty]; nearBottom = false; - if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){ + if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) { nearBottom = true; - cur += this.items[j][sizeProperty]; } - if(Math.abs(cur - base) < dist) { - dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j]; + if ( Math.abs( event[ axis ] - cur ) < dist ) { + dist = Math.abs( event[ axis ] - cur ); + itemWithLeastDistance = this.items[ j ]; this.direction = nearBottom ? "up": "down"; } } |