mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Draggable: modify margins of the containment according to the margin of the draggable element. Fixed #7084 - Draggable with parent containment and margin
(cherry picked from commit 3a0ec399cd
)
This commit is contained in:
parent
4f9091efdc
commit
a067dfa8a2
12
ui/jquery.ui.draggable.js
vendored
12
ui/jquery.ui.draggable.js
vendored
@ -317,7 +317,9 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
_cacheMargins: function() {
|
_cacheMargins: function() {
|
||||||
this.margins = {
|
this.margins = {
|
||||||
left: (parseInt(this.element.css("marginLeft"),10) || 0),
|
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');
|
var over = ($(ce).css("overflow") != 'hidden');
|
||||||
|
|
||||||
this.containment = [
|
this.containment = [
|
||||||
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
|
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) - this.margins.top,
|
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,
|
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
|
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) {
|
} else if(o.containment.constructor == Array) {
|
||||||
this.containment = o.containment;
|
this.containment = o.containment;
|
||||||
|
Loading…
Reference in New Issue
Block a user