diff options
author | Paul Bakaus <paul.bakaus@googlemail.com> | 2008-07-30 01:42:42 +0000 |
---|---|---|
committer | Paul Bakaus <paul.bakaus@googlemail.com> | 2008-07-30 01:42:42 +0000 |
commit | b65b5d087314436d7c1c915b2eca9121ee597ce3 (patch) | |
tree | 8efab3fdf9bb27cc332cacc36758e4d50b47c999 /ui/ui.draggable.js | |
parent | 2cd638e4a31a68dbfc4d30d67ed8ade4531855e1 (diff) | |
download | jquery-ui-b65b5d087314436d7c1c915b2eca9121ee597ce3.tar.gz jquery-ui-b65b5d087314436d7c1c915b2eca9121ee597ce3.zip |
draggable: fixed regression with convertPositionTo method and scroll offsets
Diffstat (limited to 'ui/ui.draggable.js')
-rw-r--r-- | ui/ui.draggable.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ui/ui.draggable.js b/ui/ui.draggable.js index cf1ef3acf..accacbcaa 100644 --- a/ui/ui.draggable.js +++ b/ui/ui.draggable.js @@ -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; @@ -419,14 +422,14 @@ $.ui.plugin.add("draggable", "snap", { var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, t = inst.snapElements[i].top, b = t + inst.snapElements[i].height; - + //Yes, I know, this is insane ;) if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) { if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, null, $.extend(inst.uiHash(), { snapItem: inst.snapElements[i].item }))); inst.snapElements[i].snapping = false; continue; } - + if(ui.options.snapMode != 'inner') { var ts = Math.abs(t - y2) <= 20; var bs = Math.abs(b - y1) <= 20; |