springroll.pixi.DragManager Class

Drag manager is responsible for handling the dragging of stage elements supports click-n-stick and click-n-drag functionality.

Constructor

springroll.pixi.DragManager

(
  • display
  • startCallback
  • endCallback
)

Parameters:

  • display PixiDisplay

    The display that this DragManager is handling objects on. Optionally, this parameter can 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 PIXI.Point

    The mouse position in the same space as the dragged object.

  • dragOffset PIXI.Point

    The drag offset for the dragged object.

  • obj PIXI.DisplayObject

    The object to snap.

_objMouseDown

(
  • object
  • interactionData
)
private

Defined in _objMouseDown:238

Mouse down on an object

Parameters:

  • object PIXI.DisplayObject

    The object that should be dragged.

  • interactionData PIXI.InteractionData

    The interaction data about the input event that triggered this.

_startDrag

(
  • interactionData
)
private

Defined in _startDrag:376

Internal start dragging on the stage

Parameters:

  • interactionData PIXI.InteractionData

    The ineraction data about the moved mouse

_stopDrag

(
  • interactionData
  • doCallback
)
private

Defined in _stopDrag:431

Internal stop dragging on the stage

Parameters:

  • interactionData PIXI.InteractionData

    The ineraction data about the moved mouse

  • doCallback Bool

    If we should do the callback

_triggerHeldDrag

(
  • interactionData
)
private

Start hold dragging

Parameters:

  • interactionData PIXI.InteractionData

    The ineraction data about the moved mouse

_triggerStickyClick

(
  • interactionData
)
private

Start the sticky click

Parameters:

  • interactionData PIXI.InteractionData

    The interaction data about the input event that triggered this.

_updateObjPosition

(
  • interactionData
)
private

Update the object position based on the mouse

Parameters:

  • interactionData PIXI.InteractionData

    Mouse move event

addObject

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

Defined in addObject:626

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 PIXI.DisplayObject

    The display object

  • [bounds] PIXI.Rectangle optional

    The rectangle bounds. 'right' and 'bottom' properties will be added to this object.

  • [dragOffset] PIXI.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:686

Destroy the manager

removeObject

(
  • obj
)
public

Defined in removeObject:664

Removes properties and functions added by addObject().

Parameters:

  • obj PIXI.DisplayObject

    The display object

startDrag

(
  • object
  • interactionData
)
public

Defined in startDrag:222

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 interaction data is required.

Parameters:

  • object PIXI.DisplayObject

    The object that should be dragged.

  • interactionData PIXI.InteractionData

    The interaction data about the input event that triggered this.

stopDrag

(
  • [doCallback=false]
  • [obj]
)
public

Defined in stopDrag:405

Stops dragging the currently dragged object.

Parameters:

  • [doCallback=false] Bool optional

    If the drag end callback should be called.

  • [obj] PIXI.DisplayObject optional

    A specific object to stop dragging, if multitouch is true. If this is omitted, it stops all drags.

_addedDragListeners

Boolean private

If this DragManager has added drag listeners to the InteractionManager

_dragEndCallback

Function private

External callback when we are done dragging

_draggableObjects

Array private

The collection of draggable objects

_dragOffset

PIXI.Point private

Defined in _dragOffset:136

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.

_dragStartCallback

Function private

External callback when we start dragging

_interaction

PIXI.interaction.InteractionManager private

Defined in _interaction:129

Reference to the Pixi InteractionManager.

_multitouch

Boolean private

Defined in _multitouch:171

If this DragManager is using multitouch for dragging.

allowStickyClick

Bool public

Defined in allowStickyClick:75

If sticky click dragging is allowed.

Default: true

draggedObj

PIXI.DisplayObject | Dictionary public

Defined in draggedObj:42

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

Bool public

Defined in isHeldDrag:92

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

Default: false

isStickyClick

Bool public

Defined in isStickyClick:101

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

Default: false

isTouchMove

Bool public

Defined in isTouchMove:83

Is the move touch based

Default: false

mouseDownObjPos

PIXI.Point

Defined in mouseDownObjPos:67

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

PIXI.Point 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:191

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

snapSettings

Object public

Defined in snapSettings:110

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