aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.draggable.js
diff options
context:
space:
mode:
authorGuillaume Gautreau <guillaume+github@ghusse.com>2011-03-08 09:32:48 -0500
committerScott González <scott.gonzalez@gmail.com>2011-03-08 09:32:48 -0500
commit3a0ec399cdd19c7e7b11934aef559cfa6b8f8258 (patch)
treecc30a4881eb17cc4bb10e107b467d3135aa56b4e /ui/jquery.ui.draggable.js
parentd7979a8b7150ac36f6f57ad0c18c49a46965797c (diff)
downloadjquery-ui-3a0ec399cdd19c7e7b11934aef559cfa6b8f8258.tar.gz
jquery-ui-3a0ec399cdd19c7e7b11934aef559cfa6b8f8258.zip
Draggable: modify margins of the containment according to the margin of the draggable element. Fixed #7084 - Draggable with parent containment and margin
Diffstat (limited to 'ui/jquery.ui.draggable.js')
-rw-r--r--ui/jquery.ui.draggable.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index 2c473d8aa..304240130 100644
--- a/ui/jquery.ui.draggable.js
+++ b/ui/jquery.ui.draggable.js
@@ -317,7 +317,9 @@ $.widget("ui.draggable", $.ui.mouse, {
_cacheMargins: function() {
this.margins = {
left: (parseInt(this.element.css("marginLeft"),10) || 0),
- top: (parseInt(this.element.css("marginTop"),10) || 0)
+ top: (parseInt(this.element.css("marginTop"),10) || 0),
+ right: (parseInt(this.element.css("marginRight"),10) || 0),
+ bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
};
},
@@ -345,10 +347,10 @@ $.widget("ui.draggable", $.ui.mouse, {
var over = ($(ce).css("overflow") != 'hidden');
this.containment = [
- co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
- co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
- co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
- co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
+ co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
+ co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
+ co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
+ co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom
];
} else if(o.containment.constructor == Array) {
this.containment = o.containment;