From c2f1ed51076acede948d520a4c4dbf03a38fcbe8 Mon Sep 17 00:00:00 2001 From: lorenzos Date: Wed, 25 Jul 2012 10:45:07 +0200 Subject: [PATCH 1/3] Added setContainer() method for Drag.Move --- Docs/Drag/Drag.Move.md | 14 ++++++++++++++ Source/Drag/Drag.Move.js | 14 ++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Docs/Drag/Drag.Move.md b/Docs/Drag/Drag.Move.md index e088428f..1692ac65 100644 --- a/Docs/Drag/Drag.Move.md +++ b/Docs/Drag/Drag.Move.md @@ -102,6 +102,20 @@ Fires the 'drop' event and calls the Drag Class stop method. - [Drag:stop][] +Drag.Move Method: setContainer {#Drag-Move:setContainer} +------------------------------------------------- + +Limits drag to an Element's size and position. +This is equivalent to specify the *container* option in Drag.Move constructor. + +### Syntax + + myMove.setContainer(container); + +### Arguments + +1. container - (*element*) Sets the container Element, drag will be limited to this Element's size and position. + Type: Element {#Element} ========================== diff --git a/Source/Drag/Drag.Move.js b/Source/Drag/Drag.Move.js index cad754ea..dbfbbfcc 100644 --- a/Source/Drag/Drag.Move.js +++ b/Source/Drag/Drag.Move.js @@ -45,10 +45,7 @@ Drag.Move = new Class({ element = this.element; this.droppables = $$(this.options.droppables); - this.container = document.id(this.options.container); - - if (this.container && typeOf(this.container) != 'element') - this.container = document.id(this.container.getDocument().body); + this.setContainer(this.options.container); if (this.options.style){ if (this.options.modifiers.x == 'left' && this.options.modifiers.y == 'top'){ @@ -65,6 +62,15 @@ Drag.Move = new Class({ this.addEvent('start', this.checkDroppables, true); this.overed = null; }, + + setContainer: function(container) { + + this.container = document.id(container); + + if (this.container && typeOf(this.container) != 'element') + this.container = document.id(this.container.getDocument().body); + + }, start: function(event){ if (this.container) this.options.limit = this.calculateLimit(); From 19921d73a0543db07dd48f1ef16b1d0341a044ba Mon Sep 17 00:00:00 2001 From: Lorenzo Stanco Date: Mon, 22 Oct 2012 21:33:09 +0200 Subject: [PATCH 2/3] Drag.Move.setContainer() rewrite suggested by anutron --- Source/Drag/Drag.Move.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/Drag/Drag.Move.js b/Source/Drag/Drag.Move.js index dbfbbfcc..5473e56a 100644 --- a/Source/Drag/Drag.Move.js +++ b/Source/Drag/Drag.Move.js @@ -64,12 +64,8 @@ Drag.Move = new Class({ }, setContainer: function(container) { - - this.container = document.id(container); - - if (this.container && typeOf(this.container) != 'element') - this.container = document.id(this.container.getDocument().body); - + container = document.id(container); + this.container = container || document.id(this.container.getDocument().body); }, start: function(event){ From 1b3fccc1632f518f2b1c6b29fc462fa6cd74d00a Mon Sep 17 00:00:00 2001 From: Lorenzo Stanco Date: Mon, 7 Jul 2014 11:08:39 +0200 Subject: [PATCH 3/3] Element.getSize() instead of Element.getComputedSize() in Mask.resize(), fixes #1273 --- Source/Interface/Mask.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/Interface/Mask.js b/Source/Interface/Mask.js index 39b21d03..de49414d 100644 --- a/Source/Interface/Mask.js +++ b/Source/Interface/Mask.js @@ -111,21 +111,23 @@ var Mask = new Class({ }, resize: function(x, y){ - var opt = { - styles: ['padding', 'border'] - }; - if (this.options.maskMargins) opt.styles.push('margin'); - var dim = this.target.getComputedSize(opt); + var dim = this.target.getSize(); + if (this.options.maskMargins) { + dim.x += this.target.getStyle('margin-left').toInt() + this.target.getStyle('margin-right').toInt(); + dim.y += this.target.getStyle('margin-top').toInt() + this.target.getStyle('margin-bottom').toInt(); + } + if (this.target == document.body){ this.element.setStyles({width: 0, height: 0}); var win = window.getScrollSize(); - if (dim.totalHeight < win.y) dim.totalHeight = win.y; - if (dim.totalWidth < win.x) dim.totalWidth = win.x; + if (dim.y < win.y) dim.y = win.y; + if (dim.x < win.x) dim.x = win.x; } + this.element.setStyles({ - width: Array.pick([x, dim.totalWidth, dim.x]), - height: Array.pick([y, dim.totalHeight, dim.y]) + width: Array.pick([x, dim.x]), + height: Array.pick([y, dim.y]) }); return this;