Class tsMove

Author
Giovanni Capalbo <gcapalbo@users.sourceforge.net>
License
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


NameDescription
idA unique id assigned to a tsMove instance upon instantiation.
targetThe HTMLElement that will be moving.
moverThe HTMLElement that will cause the target to move.
instancesAn 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.
curInstanceThe tsMove object whose target is currently being moved, or null if no HTMLElements are currently being moved.
movingTrue if any HTMLElement is currently being moved, false if not.
lastXThe last x-coordinate of the mouse in relation to the upper-left corner of the screen. Only valid when moving.
lastYThe last y-coordinate of the mouse in relation to the upper-left corner of the screen. Only valid when moving.


Constructor Summary


Signature
tsMove(nodeToMove, nodeToCauseMoving)


Method Summary


Return TypeSignature
voidaddInstance(obj)
voidenterMoveMode(e)
voidexitMoveMode(e)
tsMovegetInstance(id)
voidmove(e)


Attribute Details

id

Type
number
Description
A unique id assigned to a tsMove instance upon instantiation.
Access
public



target

Type
HTMLElement
Description
The HTMLElement that will be moving.
Access
public



mover

Type
HTMLElement
Description
The HTMLElement that will cause the target to move.
Access
public



instances

NOTE: This attribute is static, so it is referenced as tsMove.instances
Type
Array
Description
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.
Access
public



curInstance

NOTE: This attribute is static, so it is referenced as tsMove.curInstance
Type
number
Description
The tsMove object whose target is currently being moved, or null if no HTMLElements are currently being moved.
Access
public



moving

NOTE: This attribute is static, so it is referenced as tsMove.moving
Type
boolean
Description
True if any HTMLElement is currently being moved, false if not.
Access
public



lastX

NOTE: This attribute is static, so it is referenced as tsMove.lastX
Type
number
Description
The last x-coordinate of the mouse in relation to the upper-left corner of the screen. Only valid when moving.
Access
public



lastY

NOTE: This attribute is static, so it is referenced as tsMove.lastY
Type
number
Description
The last y-coordinate of the mouse in relation to the upper-left corner of the screen. Only valid when moving.
Access
public


Constructor Details

tsMove

Description

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:

Parameters
TypeNameDescription
HTMLElementnodeToMoveThe HTMLElement to move.
HTMLElementnodeToCauseMovingThe 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
Description
Stores the given tsMove object in the tsMove.instances Array. This function is automatically called upon instantiation of a new tsMove object.
Parameters
TypeNameDescription
tsMoveobjThe tsMove object to store.
Return
void
Access
public



enterMoveMode

NOTE: This method is static, so it is referenced as tsMove.enterMoveMode
Description
Starts moving an HTMLElement. The HTMLElement that begins moving is the the element referenced by the Event passed to this function.
Parameters
TypeNameDescription
EventeThe Event that caused this function to be called.
Return
void
Access
public



exitMoveMode

NOTE: This method is static, so it is referenced as tsMove.exitMoveMode
Description
Stops moving.
Parameters
TypeNameDescription
EventeThe Event that caused this function to be called.
Return
void
Access
public



getInstance

NOTE: This method is static, so it is referenced as tsMove.getInstance
Description
Retrieves the tsMove object with the given id.
Parameters
TypeNameDescription
numberidThe id of the tsMove object to retrieve.
Return
tsMove; The tsMove object.
Access
public



move

NOTE: This method is static, so it is referenced as tsMove.move
Description
Moves the currently moving HTMLElement in relation to tsMove.lastX and tsMove.lastY.
Parameters
TypeNameDescription
EventeThe Event that caused this function to be called.
Return
void
Access
public