]> source.dussan.org Git - jquery-ui.git/commitdiff
Draggable: Handle scrolled windows. Fixes #6181 - Draggable: issue with containment...
authorJean-Francois Remy <jfremy@virtuoz.com>
Wed, 1 Dec 2010 20:31:59 +0000 (15:31 -0500)
committerScott González <scott.gonzalez@gmail.com>
Wed, 1 Dec 2010 20:31:59 +0000 (15:31 -0500)
ui/jquery.ui.draggable.js

index 71698a85db2c80b857bcde667a8a3d40929be964..8eeaf6120ece44243b6206a158624a648895a0a4 100644 (file)
@@ -333,10 +333,10 @@ $.widget("ui.draggable", $.ui.mouse, {
                var o = this.options;
                if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
                if(o.containment == 'document' || o.containment == 'window') this.containment = [
-                       0 - this.offset.relative.left - this.offset.parent.left,
-                       0 - this.offset.relative.top - this.offset.parent.top,
-                       $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
-                       ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
+                       (o.containment == 'document' ? 0 : $(window).scrollLeft()) - this.offset.relative.left - this.offset.parent.left,
+                       (o.containment == 'document' ? 0 : $(window).scrollTop()) - this.offset.relative.top - this.offset.parent.top,
+                       (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
+                       (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
                ];
 
                if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {