Skip to content

Commit 054449e

Browse files
committed
Sortable: Only animate along the specified axis when reverting. Fixes #7415 - Sortable: Incorrect revert animation with axis: 'y'.
1 parent 5dca601 commit 054449e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ui/jquery.ui.sortable.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,18 @@ $.widget("ui.sortable", $.ui.mouse, {
417417

418418
if(this.options.revert) {
419419
var that = this,
420-
cur = this.placeholder.offset();
420+
cur = this.placeholder.offset(),
421+
axis = this.options.axis,
422+
animation = {};
421423

424+
if ( !axis || axis === "x" ) {
425+
animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
426+
}
427+
if ( !axis || axis === "y" ) {
428+
animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
429+
}
422430
this.reverting = true;
423-
424-
$(this.helper).animate({
425-
left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft),
426-
top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop)
427-
}, parseInt(this.options.revert, 10) || 500, function() {
431+
$(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
428432
that._clear(event);
429433
});
430434
} else {

0 commit comments

Comments
 (0)