Drag manager is responsible for handling the dragging of stage elements. Supports click-n-stick (click to start, move mouse, click to release) and click-n-drag (standard dragging) functionality.
_handlePointSnap
localMousePos
dragOffset
obj
Handles snapping the dragged object to the nearest among a list of points
localMousePos
createjs.Point
The mouse position in the same space as the dragged object.
dragOffset
createjs.Point
The drag offset for the dragged object.
obj
createjs.DisplayObject
The object to snap.
_objMouseDown
ev
object
Mouse down on an obmect
ev
createjs.MouseEvent
A mouse down event to listen to to determine what type of drag should be used.
object
createjs.DisplayObject
The object that should be dragged.
_stopDrag
ev
doCallback
Internal stop dragging on the stage
ev
createjs.MouseEvent
Mouse up event
doCallback
Boolean
If we should do the callback
_triggerHeldDrag
ev
Start hold dragging
ev
createjs.MouseEvent
The mouse down event
_triggerStickyClick
ev
Start the sticky click
ev
createjs.MouseEvent
The mouse down event
_updateObjPosition
ev
Update the object position based on the mouse
ev
createjs.MouseEvent
Mouse move event
addObject
obj
[bounds]
[dragOffset]
Adds properties and functions to the object - use enableDrag() and disableDrag() on objects to enable/disable them (they start out disabled). Properties added to objects: _dragBounds (Rectangle), _dragOffset (Point), _onMouseDownListener (Function), _dragMan (springroll.DragManager) reference to the DragManager these will override any existing properties of the same name
obj
createjs.DisplayObject
The display object
[bounds]
createjs.Rectangle
optional
The rectangle bounds. 'right' and 'bottom' properties will be added to this object.
[dragOffset]
createjs.Point
optional
A specific drag offset to use each time, instead of the mousedown/touchstart position relative to the object. This is useful if you want something to always be dragged from a specific position, like the base of a torch.
removeObject
obj
Removes properties and functions added by addObject().
obj
createjs.DisplayObject
The display object
startDrag
object
ev
Manually starts dragging an object. If a mouse down event is not supplied as the second argument, it defaults to a held drag, that ends as soon as the mouse is released. When using multitouch, passing a mouse event is required.
object
createjs.DisplayObject
The object that should be dragged.
ev
createjs.MouseEvent
A mouse down event that should be considered to have started the drag, to determine what type of drag should be used.
stopDrag
[doCallback=false]
[obj]
Stops dragging the currently dragged object.
[doCallback=false]
Boolean
optional
If the drag end callback should be called.
[obj]
createjs.DisplayObject
optional
A specific object to stop dragging, if multitouch is true. If this is omitted, it stops all drags.
_dragOffset
The offset from the dragged object's position that the initial mouse event was at. This is only used when multitouch is false - the DragData has it when multitouch is true.
_dragPointerID
The pointer id that triggered the drag. This is only used when multitouch is false
draggedObj
The object that's being dragged, or a dictionary of DragData being dragged by id if multitouch is true.
dragStartThreshold
The radius in pixel to allow for dragging, or else does sticky click
Default: 20
isStickyClick
Is the drag a sticky clicking (click on a item, then mouse the mouse)
Default: false
mouseDownObjPos
The position x, y of the object when interaction with it started. If multitouch is true, then this will only be set during a drag stop callback, for the object that just stopped getting dragged.
mouseDownStagePos
The position x, y of the mouse down on the stage. This is only used when multitouch is false - the DragData has it when multitouch is true.
multitouch
If the DragManager allows multitouch dragging. Setting this stops any current drags.
snapSettings
Settings for snapping.
Format for snapping to a list of points: { mode:"points", dist:20,//snap when within 20 pixels/units points:[ { x: 20, y:30 }, { x: 50, y:10 } ] }
Default: null