diff --git a/ui/widgets/sortable.js b/ui/widgets/sortable.js index fcb33ace145..35740815632 100644 --- a/ui/widgets/sortable.js +++ b/ui/widgets/sortable.js @@ -219,6 +219,15 @@ return $.widget( "ui.sortable", $.ui.mouse, { left: this.offset.left - this.margins.left }; + // After we get the helper offset, but before we get the parent offset we can + // change the helper's position to absolute + // TODO: Still need to figure out a way to make relative sorting possible + this.helper.css( "position", "absolute" ); + + //both _getRelativeOffset() and _getParentOffset() depend on cssPosition, so it should be set + //before calling these functions to avoid strange positioning on the first sorting action + this.cssPosition = this.helper.css( "position" ); + $.extend( this.offset, { click: { //Where the click happened, relative to the element left: event.pageX - this.offset.left, @@ -227,16 +236,8 @@ return $.widget( "ui.sortable", $.ui.mouse, { // This is a relative to absolute position minus the actual position calculation - // only used for relative positioned helper - relative: this._getRelativeOffset() - } ); - - // After we get the helper offset, but before we get the parent offset we can - // change the helper's position to absolute - // TODO: Still need to figure out a way to make relative sorting possible - this.helper.css( "position", "absolute" ); - this.cssPosition = this.helper.css( "position" ); - - $.extend( this.offset, { + relative: this._getRelativeOffset(), + parent: this._getParentOffset() } );