]> source.dussan.org Git - jquery-ui.git/commitdiff
draggable: fixed margin inclusion in snap option (fixes #3853)
authorPaul Bakaus <paul.bakaus@googlemail.com>
Mon, 19 Jan 2009 15:22:56 +0000 (15:22 +0000)
committerPaul Bakaus <paul.bakaus@googlemail.com>
Mon, 19 Jan 2009 15:22:56 +0000 (15:22 +0000)
ui/ui.draggable.js

index b70435e7722a30049d606012cd333eb3e2001439..469949199a695777325e015d761175e5a52ae53b 100644 (file)
@@ -678,10 +678,10 @@ $.ui.plugin.add("draggable", "snap", {
                                var bs = Math.abs(b - y1) <= d;
                                var ls = Math.abs(l - x2) <= d;
                                var rs = Math.abs(r - x1) <= d;
-                               if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
-                               if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
-                               if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
-                               if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
+                               if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
+                               if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
+                               if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
+                               if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
                        }
 
                        var first = (ts || bs || ls || rs);
@@ -691,10 +691,10 @@ $.ui.plugin.add("draggable", "snap", {
                                var bs = Math.abs(b - y2) <= d;
                                var ls = Math.abs(l - x1) <= d;
                                var rs = Math.abs(r - x2) <= d;
-                               if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
-                               if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
-                               if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
-                               if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
+                               if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
+                               if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
+                               if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
+                               if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
                        }
 
                        if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))