Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added setContainer() method for Drag.Move

  • Loading branch information...
commit c2f1ed51076acede948d520a4c4dbf03a38fcbe8 1 parent 5740c63
@lorenzos authored
Showing with 24 additions and 4 deletions.
  1. +14 −0 Docs/Drag/Drag.Move.md
  2. +10 −4 Source/Drag/Drag.Move.js
View
14 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}
==========================
View
14 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();
Please sign in to comment.
Something went wrong with that request. Please try again.