draggable: fixed #2919

This commit is contained in:
Paul Bakaus 2008-05-25 15:39:24 +00:00
parent 620ed33295
commit 074bd8d1ab

View File

@ -21,12 +21,12 @@
//Initialize needed constants
var o = this.options;
this.mouseInit();
//Position the node
if(o.helper == 'original' && !(/(relative|absolute|fixed)/).test(this.element.css('position')))
this.element.css('position', 'relative');
this.mouseInit();
},
mouseStart: function(e) {
var o = this.options;
@ -128,14 +128,16 @@
pos.top // the calculated relative position
+ this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
- (this.cssPosition == "fixed" ? 0 : this.offsetParent[0].scrollTop) * mod // The offsetParent's scroll position, not if the element is fixed
- (this.cssPosition == "fixed" || this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) * mod // The offsetParent's scroll position, not if the element is fixed
+ (this.cssPosition == "fixed" ? this.offsetParent[0].scrollTop : 0) * mod
+ this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods)
),
left: (
pos.left // the calculated relative position
+ this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
- (this.cssPosition == "fixed" ? 0 : this.offsetParent[0].scrollLeft) * mod // The offsetParent's scroll position, not if the element is fixed
- (this.cssPosition == "fixed" || this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) * mod // The offsetParent's scroll position, not if the element is fixed
+ (this.cssPosition == "fixed" ? this.offsetParent[0].scrollLeft : 0) * mod
+ this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods)
)
};
@ -149,14 +151,16 @@
- this.offset.click.top // Click offset (relative to the element)
- this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.parent.top // The offsetParent's offset without borders (offset + border)
+ (this.cssPosition == "fixed" ? 0 : this.offsetParent[0].scrollTop) // The offsetParent's scroll position, not if the element is fixed
+ (this.cssPosition == "fixed" || this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) // The offsetParent's scroll position, not if the element is fixed
- (this.cssPosition == "fixed" ? this.offsetParent[0].scrollTop : 0)
),
left: (
e.pageX // The absolute mouse position
- this.offset.click.left // Click offset (relative to the element)
- this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.parent.left // The offsetParent's offset without borders (offset + border)
+ (this.cssPosition == "fixed" ? 0 : this.offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed
+ (this.cssPosition == "fixed" || this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed
- (this.cssPosition == "fixed" ? this.offsetParent[0].scrollLeft : 0)
)
};