mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
draggable: fixed regression with convertPositionTo method and scroll offsets
This commit is contained in:
parent
2cd638e4a3
commit
b65b5d0873
@ -139,14 +139,16 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
|
||||
return true;
|
||||
},
|
||||
convertPositionTo: function(d, pos) {
|
||||
|
||||
if(!pos) pos = this.position;
|
||||
var mod = d == "absolute" ? 1 : -1;
|
||||
|
||||
return {
|
||||
top: (
|
||||
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" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.scrollTopParent[0].scrollTop) * mod // The offsetParent's scroll position, not if the element is fixed
|
||||
- (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : (this.scrollTopParent[0].scrollTop || 0)) * mod // The offsetParent's scroll position, not if the element is fixed
|
||||
+ (this.cssPosition == "fixed" ? $(document).scrollTop() : 0) * mod
|
||||
+ this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods)
|
||||
),
|
||||
@ -154,7 +156,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
|
||||
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" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.scrollLeftParent[0].scrollLeft) * mod // The offsetParent's scroll position, not if the element is fixed
|
||||
- (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : (this.scrollLeftParent[0].scrollLeft || 0)) * mod // The offsetParent's scroll position, not if the element is fixed
|
||||
+ (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0) * mod
|
||||
+ this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods)
|
||||
)
|
||||
@ -412,6 +414,7 @@ $.ui.plugin.add("draggable", "snap", {
|
||||
|
||||
var inst = $(this).data("draggable");
|
||||
var d = ui.options.snapTolerance || 20;
|
||||
|
||||
var x1 = ui.absolutePosition.left, x2 = x1 + inst.helperProportions.width,
|
||||
y1 = ui.absolutePosition.top, y2 = y1 + inst.helperProportions.height;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user