Search and Top Navigation
#15021 closed bug (fixed)
Opened August 05, 2016 04:11AM UTC
Closed October 04, 2016 03:06PM UTC
Last modified October 04, 2016 03:06PM UTC
JQuery UI Sortable : get wrong top and left in function _getParentOffset
| Reported by: | zudar | Owned by: | scottgonzalez |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.12.2 |
| Component: | ui.sortable | Version: | 1.11.3 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
in function _getParentOffset
if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
After I sort the elements frist time. "this.cssPosition" always equals "absolute",When I sort the elements next time , get wrong top and left.
I update with follow code.The "helper" get the right position.
if(this.helper.css("position", "absolute") === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
Attachments (0)
Change History (3)
Changed September 23, 2016 11:31AM UTC by comment:1
Changed October 04, 2016 03:06PM UTC by comment:2
| owner: | → scottgonzalez |
|---|---|
| resolution: | → fixed |
| status: | new → closed |
In [changeset:"1d409528a164c550e4e167c367f33ab3b7ad0e66" 1d40952]:
#!CommitTicketReference repository="" revision="1d409528a164c550e4e167c367f33ab3b7ad0e66" Sortable: Fix parent offset detection Fixes #15021 Closes gh-1749
Changed October 04, 2016 03:06PM UTC by comment:3
| milestone: | none → 1.12.2 |
|---|
another option might be to move the assignment of this.cssPosition in _mouseStart above the code that calls the _getParentOffset method. I imagine this might solve some potential issues with _getRelativeOffset which also makes use of this.cssPosition which is currently undefined the first time you drag.
//The element's absolute position on the page minus margins this.offset = this.currentItem.offset(); this.offset = { top: this.offset.top - this.margins.top, 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() } );