Skip to content

Commit bcda57c

Browse files
author
Paul Bakaus
committed
draggable: fixed using Array for containment option (fixes #3877)
1 parent 59c6f97 commit bcda57c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

ui/ui.draggable.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
266266
($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
267267
];
268268

269-
if(!(/^(document|window|parent)$/).test(o.containment)) {
270-
var ce = $(o.containment)[0];
269+
if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
270+
var ce = $(o.containment)[0]; if(!ce) return;
271271
var co = $(o.containment).offset();
272272
var over = ($(ce).css("overflow") != 'hidden');
273273

@@ -277,6 +277,8 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
277277
co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.helperProportions.width - this.margins.left,
278278
co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.helperProportions.height - this.margins.top
279279
];
280+
} else if(o.containment.constructor == Array) {
281+
this.containment = o.containment;
280282
}
281283

282284
},

0 commit comments

Comments
 (0)