]> source.dussan.org Git - jquery-ui.git/commitdiff
Sortable: Only animate along the specified axis when reverting. Fixes #7415 - Sortabl...
authorScott González <scott.gonzalez@gmail.com>
Wed, 13 Mar 2013 02:44:43 +0000 (22:44 -0400)
committerScott González <scott.gonzalez@gmail.com>
Wed, 13 Mar 2013 15:31:54 +0000 (11:31 -0400)
ui/jquery.ui.sortable.js

index 99bc23bdb9387d937ff262b9e473bf4621fa9714..642d5d9479c156875f9d927fedb4efec62f8510c 100644 (file)
@@ -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 {