Opened 8 years ago

Closed 7 years ago

Last modified 5 years ago

#7198 closed bug (fixed)

Relative draggable helper offset incorrectly in Firefox when page is scrolled

Reported by: GForster Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.draggable Version: 1.8.11
Keywords: Cc:
Blocked by: Blocking:

Description

When dragging an element with the style position:relative, the helper is offset from the mouse cursor by the amount the page is scrolled, when viewing the page in Firefox 3.6.16. IE8 and Chrome 10.0.648.151 have no problems.

I was eventually able to temporarily solve my problem by making the following change to the _getRelativeOffset function: Instead of returning:

return {
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
};

I check browser version and return without the scrollparent offsets:

if ($.browser.mozilla)
{
return {
top: p.top - (parseInt(this.helper.css("top"),10) || 0),
left: p.left - (parseInt(this.helper.css("left"),10) || 0)
};
}
else
{
return {
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()

};
}

Change History (9)

comment:1 Changed 8 years ago by woodzu123

Any chances to have that implemented in 1.8.12 as its bug?

comment:2 Changed 8 years ago by Scott González

If someone provides a pull request that conforms to our coding standards (which includes not using browser sniffing), then it can land in 1.8.12. The jQuery UI team is not actively working on any interactions as we're focusing on the 1.9 release.

comment:3 Changed 7 years ago by tomprogers

Has there been any movement on this? It's still a defect in the most recent builds I've seen.

comment:4 Changed 7 years ago by Scott González

Milestone: 1.9.02.0.0

comment:5 Changed 7 years ago by GForster

I did some quick testing and it would appear the latest version of firefox (16.0.1) with Jquery UI 1.9.0, does not suffer from this issue.

Curiously I did note that the Jquery UI code does contain a number of instances of browser sniffing. Have the code standards changed over the course of nearly two years?

comment:6 Changed 7 years ago by Scott González

Milestone: 2.0.01.9.0
Resolution: fixed
Status: newclosed

Curiously I did note that the Jquery UI code does contain a number of instances of browser sniffing. Have the code standards changed over the course of nearly two years?

No, but the code hasn't changed in even longer. All interaction plugins are being rewritten from scratch.

comment:7 Changed 5 years ago by leonjanzen

As of 1.10.4 I'm still experiencing this issue.

The problem seems to be in jquery.ui.core.js, line 68 (https://github.com/jquery/jquery-ui/blob/1-10-stable/ui/jquery.ui.core.js), where static and relative properties are being grouped together. Relative positioning has the same effect on child element positioning as absolute positioning, so it should not be grouped with static positioning, which has a completely different effect on child element positioning.

I changed it in my copy of jQueryUI, removing "|relative" from "/static|relative/", and adding it to "/absolute/" (making it "/absolute|relative/"). It is now working great in my copy, although I'm only using the Sortable interaction, and haven't done any testing with any of the other interactions.

I went to fork the source code, but it has changed considerably since 1.10.4, so I'll wait until the new version is released so I can test it out before changing the code and making a pull request.

comment:8 in reply to:  7 ; Changed 5 years ago by tj.vantoll

Replying to leonjanzen:

As of 1.10.4 I'm still experiencing this issue.

The problem seems to be in jquery.ui.core.js, line 68 (https://github.com/jquery/jquery-ui/blob/1-10-stable/ui/jquery.ui.core.js), where static and relative properties are being grouped together. Relative positioning has the same effect on child element positioning as absolute positioning, so it should not be grouped with static positioning, which has a completely different effect on child element positioning.

I changed it in my copy of jQueryUI, removing "|relative" from "/static|relative/", and adding it to "/absolute/" (making it "/absolute|relative/"). It is now working great in my copy, although I'm only using the Sortable interaction, and haven't done any testing with any of the other interactions.

I went to fork the source code, but it has changed considerably since 1.10.4, so I'll wait until the new version is released so I can test it out before changing the code and making a pull request.

Hi leonjanzen,

If you would like us to look into this could you please create a test case that shows this bug. You can use this as a starting point: http://jsfiddle.net/tj_vantoll/fwk8R/.

comment:9 in reply to:  8 Changed 5 years ago by Harshala

Thank you for the solution, it worked exactly as required.

Note: See TracTickets for help on using tickets.