Skip to content

Commit

Permalink
Revert "Draggable: Don't use computed style for top and left of posit…
Browse files Browse the repository at this point in the history
…ion:relative elements. Fixes #5537 - Draggable: position relative draggable jumps on first drag in Opera"

This reverts commit dc94bbf.
  • Loading branch information
rdworth committed Apr 23, 2010
1 parent cb7eb69 commit 670ab81
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ui/jquery.ui.draggable.js
Expand Up @@ -305,8 +305,8 @@ $.widget("ui.draggable", $.ui.mouse, {
if(this.cssPosition == "relative") {
var p = this.element.position();
return {
top: p.top - (parseInt(this.helper[0].style.top,10) || 0) + this.scrollParent.scrollTop(),
left: p.left - (parseInt(this.helper[0].style.left,10) || 0) + this.scrollParent.scrollLeft()
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()
};
} else {
return { top: 0, left: 0 };
Expand Down

1 comment on commit 670ab81

@Archipel
Copy link

Choose a reason for hiding this comment

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

I wonder why you resverted dc94bbf? Since I'm using opera as my primary browser and am using Jquery-draggable alot lately, I really needed to fix this issue. I first did this by comparing the actual position with the css position:

_getRelativeOffset: function() {

    if(this.cssPosition == "relative") {
        var p = this.element.position();

        var cssTop = this.helper.css("top");
        var cssLeft = this.helper.css("left");

        if($.browser.opera){
            if(cssTop == p.top) cssTop = 0;
            if(cssLeft == p.left) cssLeft = 0;
        }

        return {
            top: p.top - (parseInt(cssTop,10) || 0) + this.scrollParent.scrollTop(),
            left: p.left - (parseInt(cssLeft,10) || 0) + this.scrollParent.scrollLeft()
        };
    } else {
        return { top: 0, left: 0 };
    }

}

However, your solution seems to be much more elegant, and it also seems to work. What is wrong with it?

Please sign in to comment.