Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sortable: fix wrong initial helper position in scrolled container (#15021) #1749

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update sortable.js
don't change position until relative offsets defined
  • Loading branch information
typytype committed Oct 3, 2016
commit e53ce4cb78bef56d6a9f501d97492fada6c70bf1
17 changes: 10 additions & 7 deletions ui/widgets/sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,26 @@ return $.widget( "ui.sortable", $.ui.mouse, {
left: this.offset.left - this.margins.left
};

// Only after we got the 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, {
click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left,
top: event.pageY - this.offset.top
},
parent: this._getParentOffset(),

// This is a relative to absolute position minus the actual position calculation -
// only used for relative positioned helper
relative: this._getRelativeOffset()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this now broken for relative positioned elements?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah my bad. not sure how the relative position works since we're always setting it to absolute. but i've moved it around so relative offset is set before the position is changed to absolute.

} );

// 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, {
parent: this._getParentOffset()
} );

//Generate the original position
this.originalPosition = this._generatePosition( event );
this.originalPageX = event.pageX;
Expand Down