aboutsummaryrefslogtreecommitdiffstats
path: root/ui/draggable.js
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2014-08-14 09:50:02 -0400
committerMike Sherov <mike.sherov@gmail.com>2014-08-14 09:50:02 -0400
commit2d03839c07a33d14ec7b31b2d4290a8ce6fc0cef (patch)
tree4c47f2e6265699da29ad3d8f8696fbb02b5ac292 /ui/draggable.js
parent54004c85d02ba5688549736e0fb8f883c88b668b (diff)
downloadjquery-ui-2d03839c07a33d14ec7b31b2d4290a8ce6fc0cef.tar.gz
jquery-ui-2d03839c07a33d14ec7b31b2d4290a8ce6fc0cef.zip
Draggable: Account for margins when snapping
Fixes #9724
Diffstat (limited to 'ui/draggable.js')
-rw-r--r--ui/draggable.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/ui/draggable.js b/ui/draggable.js
index a6de2889c..b96fca0d2 100644
--- a/ui/draggable.js
+++ b/ui/draggable.js
@@ -916,9 +916,9 @@ $.ui.plugin.add("draggable", "snap", {
for (i = inst.snapElements.length - 1; i >= 0; i--){
- l = inst.snapElements[i].left;
+ l = inst.snapElements[i].left - inst.margins.left;
r = l + inst.snapElements[i].width;
- t = inst.snapElements[i].top;
+ t = inst.snapElements[i].top - inst.margins.top;
b = t + inst.snapElements[i].height;
if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
@@ -935,16 +935,16 @@ $.ui.plugin.add("draggable", "snap", {
ls = Math.abs(l - x2) <= d;
rs = Math.abs(r - x1) <= d;
if (ts) {
- ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
+ 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 - inst.margins.top;
+ 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 - inst.margins.left;
+ 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 - inst.margins.left;
+ ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
}
}
@@ -956,16 +956,16 @@ $.ui.plugin.add("draggable", "snap", {
ls = Math.abs(l - x1) <= d;
rs = Math.abs(r - x2) <= d;
if (ts) {
- ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
+ 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 - inst.margins.top;
+ 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 - inst.margins.left;
+ 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 - inst.margins.left;
+ ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
}
}