Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 3a0ec39)
  • Loading branch information...
commit a067dfa8a22f9705bd062cfd651feb0bff3e3cf6 1 parent 4f9091e
Guillaume Gautreau authored March 08, 2011 scottgonzalez committed March 08, 2011

Showing 1 changed file with 7 additions and 5 deletions. Show diff stats Hide diff stats

  1. 12  ui/jquery.ui.draggable.js
12  ui/jquery.ui.draggable.js
@@ -317,7 +317,9 @@ $.widget("ui.draggable", $.ui.mouse, {
317 317
 	_cacheMargins: function() {
318 318
 		this.margins = {
319 319
 			left: (parseInt(this.element.css("marginLeft"),10) || 0),
320  
-			top: (parseInt(this.element.css("marginTop"),10) || 0)
  320
+			top: (parseInt(this.element.css("marginTop"),10) || 0),
  321
+			right: (parseInt(this.element.css("marginRight"),10) || 0),
  322
+			bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
321 323
 		};
322 324
 	},
323 325
 
@@ -345,10 +347,10 @@ $.widget("ui.draggable", $.ui.mouse, {
345 347
 			var over = ($(ce).css("overflow") != 'hidden');
346 348
 
347 349
 			this.containment = [
348  
-				co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
349  
-				co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
350  
-				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,
351  
-				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
  350
+				co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
  351
+				co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
  352
+				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,
  353
+				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
352 354
 			];
353 355
 		} else if(o.containment.constructor == Array) {
354 356
 			this.containment = o.containment;

0 notes on commit a067dfa

Please sign in to comment.
Something went wrong with that request. Please try again.