aboutsummaryrefslogtreecommitdiffstats
path: root/ui/ui.draggable.js
diff options
context:
space:
mode:
authorPaul Bakaus <paul.bakaus@googlemail.com>2008-06-07 23:38:03 +0000
committerPaul Bakaus <paul.bakaus@googlemail.com>2008-06-07 23:38:03 +0000
commit7539a095f66413cc7359303b8a1ef74ec98332d9 (patch)
tree7fa9e2fe21b3806a6c9032c47f06bb9fbae83996 /ui/ui.draggable.js
parent68d37568e0041290f3c957891c2c2919cd504f0f (diff)
downloadjquery-ui-7539a095f66413cc7359303b8a1ef74ec98332d9.tar.gz
jquery-ui-7539a095f66413cc7359303b8a1ef74ec98332d9.zip
draggable,sortable: fixed containment "document", added containment: "window" (fixes #2936,#2171)
Diffstat (limited to 'ui/ui.draggable.js')
-rw-r--r--ui/ui.draggable.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/ui/ui.draggable.js b/ui/ui.draggable.js
index d58e54100..12a3a6e9b 100644
--- a/ui/ui.draggable.js
+++ b/ui/ui.draggable.js
@@ -103,7 +103,13 @@ $.widget("ui.draggable", $.extend($.ui.mouse, {
if(o.containment) {
if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
- if(o.containment == 'document') this.containment = [0,0,$(document).width(), ($(document).height() || document.body.parentNode.scrollHeight)];
+ 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.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),
+ ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)
+ ];
+
if(!(/^(document|window|parent)$/).test(o.containment)) {
var ce = $(o.containment)[0];
var co = $(o.containment).offset();