Skip to content

Commit e01664a

Browse files
Jean-Francois Remyscottgonzalez
Jean-Francois Remy
authored andcommitted
Draggable: Handle scrolled windows. Fixes #6181 - Draggable: issue with containment on position:fixed elements.
1 parent eac910f commit e01664a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ui/jquery.ui.draggable.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ $.widget("ui.draggable", $.ui.mouse, {
333333
var o = this.options;
334334
if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
335335
if(o.containment == 'document' || o.containment == 'window') this.containment = [
336-
0 - this.offset.relative.left - this.offset.parent.left,
337-
0 - this.offset.relative.top - this.offset.parent.top,
338-
$(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
339-
($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
336+
(o.containment == 'document' ? 0 : $(window).scrollLeft()) - this.offset.relative.left - this.offset.parent.left,
337+
(o.containment == 'document' ? 0 : $(window).scrollTop()) - this.offset.relative.top - this.offset.parent.top,
338+
(o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
339+
(o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
340340
];
341341

342342
if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {

0 commit comments

Comments
 (0)