This library is used to make DOM objects draggable. For examples of how to use this library see the examples page.
This class makes a DOM object draggable.
Constructor | Description |
---|---|
ExtDraggableObject(src:Node, opt_drag:ExtDraggableObjectOptions) |
Sets up event handlers so that the source object can be dragged. For a complete reference on the available options see ExtDraggableObjectOptions |
Method | Return Value | Description |
---|---|---|
moveTo(point:point) |
None |
Moves the draggable object to a given absolute position. The position is relative to the parent node. Note that point can be any object with an x and y property. google.maps.Point works for this but you can also simply pass an object literal with an x and y property. |
moveBy(size:size) |
None |
Moves the draggable object by the specified offset. Note that size can be any object with a width and height property. google.maps.Size works for this but you can also simply pass an object literal with a width and height property. |
setDraggableCursor(cursor:String) |
None |
Sets the cursor to use when the mouse is over the draggable object. |
setDraggingCursor(cursor:String) |
None |
Sets the cursor to use when the draggable object is being dragged. |
left() |
Number |
Returns the current left position of the draggable object. |
top() |
Number |
Returns the current top position of the draggable object. |
valueX() |
Number |
Returns the current number of times the draggable object has moved the amount specified by intervalX . If intervalX was not given in the constructor than valueX acts as if intervalX is set to 1. |
valueY() |
Number |
Returns the current number of times the draggable object has moved the amount specified by intervalY . If intervalY was not given in the constructor than valueY acts as if intervalY is set to 1. |
setValueX(value:Number) |
None |
Moves the draggable object by an amount equal to value multiplied by intervalX . If intervalX was not given in the constructor than setValueX acts as if intervalX is set to 1. |
setValueY(value:Number) |
None |
Moves the draggable object by an amount equal to value multiplied by intervalY . If intervalY was not given in the constructor than setValueY acts as if intervalY is set to 1. |
preventDefaultMovement() |
None |
Prevents the events setup by ExtDraggableObject from moving the draggable object by default. Note that mouse movement is still tracked and the position the object should be at is still calculated like normal, only the object isn't physically moved. Also, methods that allow the user to manually move the object still work. |
Event | Arguments | Description |
---|---|---|
dragstart |
DragObjectEvent |
This event is fired when the mouse is first down and no dragging has taken place yet. |
drag |
DragObjectEvent |
This event is fired repeatedly as the mouse is moved by the user while dragstart has been triggered. |
dragend |
DragObjectEvent |
This event is fired when the user releases the mouse after dragstart has been triggered. |
mousedown |
DOM Event |
This event is fired when the user clicks and holds the mouse button down over the draggable object. |
mouseup |
DOM Event |
This event is fired when the user releases the mouse button after mousedown has been triggered. |
This class represents optional arguments to the ExtDraggableObject constructor. It has no constructor but is instantiated as an object literal.
Property | Type | Description |
---|---|---|
left |
Number |
The left starting position of the object. |
top |
Number |
The top starting position of the object. |
container |
Node |
A DOM element that will act as the bounding box for the draggable object. |
draggableCursor |
String |
The cursor to show on mouseover. |
draggingCursor |
String |
The cursor to show while dragging. |
intervalX |
Number |
The number of pixels the draggable object will move along the X-axis while dragging. |
intervalY |
Number |
The number of pixels the draggable object will move along the Y-axis while dragging. |
toleranceX |
Number |
The number of pixels the mouse can move away from the object along the X-axis before the object is snapped back to the position it was at dragstart. |
toleranceY |
Number |
The number of pixels the mouse can move away from the object along the Y-axis before the object is snapped back to the position it was at dragstart. |
restrictX |
Number |
Prevents the draggable object from moving along the X-axis if set to true . |
restrictY |
Number |
Prevents the draggable object from moving along the Y-axis if set to true . |
This class represents arguments returned by ExtDraggableObject events. It has no constructor or interfaces and is simply returned by events as an object literal.
Property | Type | Description |
---|---|---|
mouseX |
Number |
The X-axis position of the mouse on the page. |
mouseY |
Number |
The Y-axis position of the mouse on the page. |
startLeft |
Number |
The left position the draggable object was at on dragstart. |
startTop |
Number |
The top position the draggable object was at on dragstart. |
event |
DOM Event |
The DOM Event object associated with the underlying mouse event. |