springroll.easeljs.DragManager Class

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.

Constructor

springroll.easeljs.DragManager

(
  • display
  • startCallback
  • endCallback
)

Parameters:

  • display PixiDisplay

    The display that this DragManager is handling objects on. Optionally, this parameter an be omitted and the Application's default display will be used.

  • startCallback Function

    The callback when when starting

  • endCallback Function

    The callback when ending

_handlePointSnap

(
  • localMousePos
  • dragOffset
  • obj
)
private

Handles snapping the dragged object to the nearest among a list of points

Parameters:

  • 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
)
private

Defined in _objMouseDown:252

Mouse down on an obmect

Parameters:

  • 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.

_startDrag

()
private

Defined in _startDrag:386

Internal start dragging on the stage

_stopDrag

(
  • ev
  • doCallback
)
private

Defined in _stopDrag:434

Internal stop dragging on the stage

Parameters:

  • ev createjs.MouseEvent

    Mouse up event

  • doCallback Boolean

    If we should do the callback

_triggerHeldDrag

(
  • ev
)
private

Start hold dragging

Parameters:

  • ev createjs.MouseEvent

    The mouse down event

_triggerStickyClick

(
  • ev
)
private

Start the sticky click

Parameters:

  • ev createjs.MouseEvent

    The mouse down event

_updateObjPosition

(
  • ev
)
private

Update the object position based on the mouse

Parameters:

  • ev createjs.MouseEvent

    Mouse move event

addObject

(
  • obj
  • [bounds]
  • [dragOffset]
)
public

Defined in addObject:627

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

Parameters:

  • 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.

destroy

()
public

Defined in destroy:687

Destroy the manager

removeObject

(
  • obj
)
public

Defined in removeObject:665

Removes properties and functions added by addObject().

Parameters:

  • obj createjs.DisplayObject

    The display object

startDrag

(
  • object
  • ev
)
public

Defined in startDrag:235

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.

Parameters:

  • 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]
)
public

Defined in stopDrag:408

Stops dragging the currently dragged object.

Parameters:

  • [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.

_dragEndCallback

Function private

Callback when we are done dragging

_draggableObjects

Array private

The collection of draggable objects

_dragOffset

createjs.Point private

Defined in _dragOffset:143

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

Number private

Defined in _dragPointerID:152

The pointer id that triggered the drag. This is only used when multitouch is false

  • the DragData is indexed by pointer id when multitouch is true.

_dragStartCallback

Function private

Callback when we start dragging

_helperPoint

createjs.Point private

Defined in _helperPoint:186

A point for reuse instead of lots of object creation.

_multitouch

Boolean private

Defined in _multitouch:193

If this DragManager is using multitouch for dragging.

_theStage

createjs.Stage private

Defined in _theStage:133

Reference to the stage

allowStickyClick

Boolean public

Defined in allowStickyClick:79

If sticky click dragging is allowed.

Default: true

draggedObj

createjs.DisplayObject | Dictionary public

Defined in draggedObj:40

The object that's being dragged, or a dictionary of DragData being dragged by id if multitouch is true.

dragStartThreshold

Unknown public

The radius in pixel to allow for dragging, or else does sticky click

Default: 20

isHeldDrag

Boolean public

Defined in isHeldDrag:96

Is the drag being held on mouse down (not sticky clicking)

Default: false

isStickyClick

Boolean public

Defined in isStickyClick:105

Is the drag a sticky clicking (click on a item, then mouse the mouse)

Default: false

isTouchMove

Boolean public

Defined in isTouchMove:87

Is the move touch based

Default: false

mouseDownObjPos

Object

Defined in mouseDownObjPos:68

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

Object private

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

Boolean

Defined in multitouch:204

If the DragManager allows multitouch dragging. Setting this stops any current drags.

snapSettings

Object public

Defined in snapSettings:114

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