diff options
author | Scott González <scott.gonzalez@gmail.com> | 2013-03-12 22:44:43 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2013-03-13 11:31:54 -0400 |
commit | 054449e214449ec5578fe71bb67b9a670adac828 (patch) | |
tree | 16267d217039f3bdd0b8298a5b14895085a3f4d3 | |
parent | 5dca601bc6b396f2d722be1ab817126aa7e8a58c (diff) | |
download | jquery-ui-054449e214449ec5578fe71bb67b9a670adac828.tar.gz jquery-ui-054449e214449ec5578fe71bb67b9a670adac828.zip |
Sortable: Only animate along the specified axis when reverting. Fixes #7415 - Sortable: Incorrect revert animation with axis: 'y'.
-rw-r--r-- | ui/jquery.ui.sortable.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 99bc23bdb..642d5d947 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -417,14 +417,18 @@ $.widget("ui.sortable", $.ui.mouse, { if(this.options.revert) { var that = this, - cur = this.placeholder.offset(); + cur = this.placeholder.offset(), + axis = this.options.axis, + animation = {}; + if ( !axis || axis === "x" ) { + animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft); + } + if ( !axis || axis === "y" ) { + animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop); + } this.reverting = true; - - $(this.helper).animate({ - left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft), - top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop) - }, parseInt(this.options.revert, 10) || 500, function() { + $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() { that._clear(event); }); } else { |