craftyjs.github.com

Draggable

Enable drag and drop of the entity.

Events

Dragging [Data: MouseEvent]
is triggered each frame the entity is being dragged
StartDrag [Data: MouseEvent]
is triggered when dragging begins
StopDrag [Data: MouseEvent]
is triggered when dragging ends
Back to top

.dragDirection

public this .dragDirection()

Remove any previously specified direction.

public this .dragDirection(vector)

vector
Of the form of {x: valx, y: valy}, the vector (valx, valy) denotes the move direction.

public this .dragDirection(degree)

degree
A number, the degree (clockwise) of the move direction with respect to the x axis.

Specify the dragging direction.

Example

this.dragDirection()
this.dragDirection({x:1, y:0}) //Horizontal
this.dragDirection({x:0, y:1}) //Vertical
// Note: because of the orientation of x and y axis,
// this is 45 degree clockwise with respect to the x axis.
this.dragDirection({x:1, y:1}) //45 degree.
this.dragDirection(60) //60 degree.
Back to top

._startDrag

Internal method for starting a drag of an entity either programatically or via Mouse click

e
a mouse event
Back to top

.stopDrag

public this .stopDrag(void)

Events

StopDrag
Called right after the mouse listeners are removed

Stop the entity from dragging. Essentially reproducing the drop.

See Also

Back to top

.startDrag

public this .startDrag(void)

Make the entity follow the mouse positions.

See Also

Back to top

.enableDrag

public this .enableDrag(void)

Rebind the mouse events. Use if .disableDrag has been called.

See Also

Back to top

.disableDrag

public this .disableDrag(void)

Stops entity from being draggable. Reenable with .enableDrag().

See Also