Class tsMove
Giovanni Capalbo <gcapalbo@users.sourceforge.net>
This source file is subject to the LGPL license, which is available online at this address: http://www.gnu.org/copyleft/lesser.html
This class allows the user to move HTMLElements around the screen. Any HTMLElement that is being moved around the screen must have "absolute" for its position style value.
Attribute Summary
Name | Description |
id | A unique id assigned to a tsMove instance upon instantiation. |
target | The HTMLElement that will be moving. |
mover | The HTMLElement that will cause the target to move. |
instances | An Array that stores all tsMove instances, where each index is a tsMove id and each value is the corresponding reference to the tsMove object with that id. |
curInstance | The tsMove object whose target is currently being moved, or null if no HTMLElements are currently being moved. |
moving | True if any HTMLElement is currently being moved, false if not. |
lastX | The last x-coordinate of the mouse in relation to the upper-left corner of the screen. Only valid when moving. |
lastY | The last y-coordinate of the mouse in relation to the upper-left corner of the screen. Only valid when moving. |
Constructor Summary
Method Summary
Attribute Details
id
number
A unique id assigned to a tsMove instance upon instantiation.
public
target
HTMLElement
The HTMLElement that will be moving.
public
mover
HTMLElement
The HTMLElement that will cause the target to move.
public
instances
NOTE: This attribute is static, so it is referenced as tsMove.instances
Array
An Array that stores all tsMove instances, where each index is a tsMove id and each value is the corresponding reference to the tsMove object with that id.
public
curInstance
NOTE: This attribute is static, so it is referenced as tsMove.curInstance
number
The tsMove object whose target is currently being moved, or null if no HTMLElements are currently being moved.
public
moving
NOTE: This attribute is static, so it is referenced as tsMove.moving
boolean
True if any HTMLElement is currently being moved, false if not.
public
lastX
NOTE: This attribute is static, so it is referenced as tsMove.lastX
number
The last x-coordinate of the mouse in relation to the upper-left corner of the screen. Only valid when moving.
public
lastY
NOTE: This attribute is static, so it is referenced as tsMove.lastY
number
The last y-coordinate of the mouse in relation to the upper-left corner of the screen. Only valid when moving.
public
Constructor Details
tsMove
Constructs a tsMove object. By constructing a tsMove object, the toolkit will automatically create all of infrastructure necessary to move the given HTMLElement around the screen. The following are the three rules that must be adhered to in order to successfully instantiate a tsMove oject:
- The HTMLElement that will be moving around the screen (parameter nodeToMove below) must have "absolute" for its position style value. This may be done either in CSS or Javascript.
- The parameter nodeToCauseMoving must either be the same element as nodeToMove or must be a child of nodeToMove.
- Be aware that only one HTMLElement may be moved at a time, and the toolkit will automatically ensure this.
Type | Name | Description |
HTMLElement | nodeToMove | The HTMLElement to move. |
HTMLElement | nodeToCauseMoving | The HTMLElement, that when clicked and dragged, will cause nodeToMove to move. |
Method Details
addInstance
NOTE: This method is static, so it is referenced as tsMove.addInstance
Stores the given tsMove object in the tsMove.instances Array. This function is automatically called upon instantiation of a new tsMove object.
Type | Name | Description |
tsMove | obj | The tsMove object to store. |
void
public
enterMoveMode
NOTE: This method is static, so it is referenced as tsMove.enterMoveMode
Starts moving an HTMLElement. The HTMLElement that begins moving is the the element referenced by the Event passed to this function.
Type | Name | Description |
Event | e | The Event that caused this function to be called. |
void
public
exitMoveMode
NOTE: This method is static, so it is referenced as tsMove.exitMoveMode
Stops moving.
Type | Name | Description |
Event | e | The Event that caused this function to be called. |
void
public
getInstance
NOTE: This method is static, so it is referenced as tsMove.getInstance
Retrieves the tsMove object with the given id.
Type | Name | Description |
number | id | The id of the tsMove object to retrieve. |
tsMove; The tsMove object.
public
move
NOTE: This method is static, so it is referenced as tsMove.move
Moves the currently moving HTMLElement in relation to tsMove.lastX and tsMove.lastY.
Type | Name | Description |
Event | e | The Event that caused this function to be called. |
void
public