Skip to content
Permalink
Browse files

Revert "Draggable: Don't use computed style for top and left of posit…

…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 670ab819a9a6388393e2c1a73c1eaf7095bdc6e0
Showing with 2 additions and 2 deletions.
  1. +2 −2 ui/jquery.ui.draggable.js
@@ -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 };

1 comment on commit 670ab81

@Archipel

This comment has been minimized.

Copy link

commented on 670ab81 Oct 23, 2010

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.
You can’t perform that action at this time.