Skip to content

Commit 3a0ec39

Browse files
ghussescottgonzalez
authored andcommitted
Draggable: modify margins of the containment according to the margin of the draggable element. Fixed #7084 - Draggable with parent containment and margin
1 parent d7979a8 commit 3a0ec39

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ui/jquery.ui.draggable.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ $.widget("ui.draggable", $.ui.mouse, {
317317
_cacheMargins: function() {
318318
this.margins = {
319319
left: (parseInt(this.element.css("marginLeft"),10) || 0),
320-
top: (parseInt(this.element.css("marginTop"),10) || 0)
320+
top: (parseInt(this.element.css("marginTop"),10) || 0),
321+
right: (parseInt(this.element.css("marginRight"),10) || 0),
322+
bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
321323
};
322324
},
323325

@@ -345,10 +347,10 @@ $.widget("ui.draggable", $.ui.mouse, {
345347
var over = ($(ce).css("overflow") != 'hidden');
346348

347349
this.containment = [
348-
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
349-
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
350-
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,
351-
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
350+
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
351+
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
352+
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,
353+
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
352354
];
353355
} else if(o.containment.constructor == Array) {
354356
this.containment = o.containment;

0 commit comments

Comments
 (0)