Options
All
  • Public
  • Public/Protected
  • All
Menu

The interaction manager deals with mouse, touch and pointer events.

Any DisplayObject can be interactive if its interactive property is set to true.

This manager also supports multitouch.

An instance of this class is automatically created by default, and can be found at renderer.plugins.interaction

memberof

PIXI

Hierarchy

Index

Constructors

constructor

Properties

Private _deltaTime

_deltaTime: any

Private _didMove

_didMove: any

Private _tempDisplayObject

_tempDisplayObject: any

Private _useSystemTicker

_useSystemTicker: any

Readonly activeInteractionData

activeInteractionData: {}

Type declaration

Private addEvents

addEvents: any

Registers all the DOM events

Private addTickerListener

addTickerListener: any

Add the ticker listener

autoPreventDefault

autoPreventDefault: boolean

Private configureInteractionEventForDOMEvent

configureInteractionEventForDOMEvent: any

Configure an InteractionEvent to wrap a DOM PointerEvent and InteractionData

param

The event to be configured

param

The DOM event that will be paired with the InteractionEvent

param

The InteractionData that will be paired with the InteractionEvent

returns

the interaction event that was passed in

currentCursorMode

currentCursorMode: string

cursor

cursor: string

cursorStyles

cursorStyles: Dict<string | CSSStyleDeclaration | ((mode: string) => void)>

Private delayDispatchEvent

delayDispatchEvent: any

Puts a event on a queue to be dispatched later. This is used to guarantee correct ordering of over/out events.

param

the display object in question

param

the name of the event (e.g, mousedown)

param

the event data object

delayedEvents

delayedEvents: DelayedEvent[]

Private dispatchEvent

dispatchEvent: any

Dispatches an event on the display object that was interacted with

param

the display object in question

param

the name of the event (e.g, mousedown)

param

the event data object

eventData

eventData: InteractionEvent

Protected eventsAdded

eventsAdded: boolean

Private getInteractionDataForPointerId

getInteractionDataForPointerId: any

Get InteractionData for a given pointerId. Store that data as well

param

Normalized pointer event, output from normalizeToPointerData

returns
  • Interaction data for the given pointer identifier

Protected interactionDOMElement

interactionDOMElement: HTMLElement

interactionDataPool

interactionDataPool: InteractionData[]

interactionFrequency

interactionFrequency: number

mouse

Protected mouseOverRenderer

mouseOverRenderer: boolean

moveWhenInside

moveWhenInside: boolean

Private normalizeToPointerData

normalizeToPointerData: any

Ensures that the original event object contains all data that a regular pointer event would have

param

The original event data from a touch or mouse event

returns

An array containing a single normalized pointer event, in the case of a pointer or mouse event, or a multiple normalized pointer events if there are multiple changed touches

Private onPointerCancel

onPointerCancel: any

Is called when the pointer button is cancelled

param

The DOM event of a pointer button being released

Private onPointerComplete

onPointerComplete: any

Is called when the pointer button is released on the renderer element

param

The DOM event of a pointer button being released

param

true if the pointer is cancelled

param

Function passed to processInteractive

Private onPointerDown

onPointerDown: any

Is called when the pointer button is pressed down on the renderer element

param

The DOM event of a pointer button being pressed down

Private onPointerMove

onPointerMove: any

Is called when the pointer moves across the renderer element

param

The DOM event of a pointer moving

Private onPointerOut

onPointerOut: any

Is called when the pointer is moved out of the renderer element

param

The DOM event of a pointer being moved out

Private onPointerOver

onPointerOver: any

Is called when the pointer is moved into the renderer element

param

The DOM event of a pointer button being moved into the renderer view

Private onPointerUp

onPointerUp: any

Is called when the pointer button is released on the renderer element

param

The DOM event of a pointer button being released

Private processPointerCancel

processPointerCancel: any

Processes the result of the pointer cancel check and dispatches the event if need be

param

The interaction event wrapping the DOM event

param

The display object that was tested

Private processPointerDown

processPointerDown: any

Processes the result of the pointer down check and dispatches the event if need be

param

The interaction event wrapping the DOM event

param

The display object that was tested

param

the result of the hit test on the display object

Private processPointerMove

processPointerMove: any

Processes the result of the pointer move check and dispatches the event if need be

param

The interaction event wrapping the DOM event

param

The display object that was tested

param

the result of the hit test on the display object

Private processPointerOverOut

processPointerOverOut: any

Processes the result of the pointer over/out check and dispatches the event if need be

param

The interaction event wrapping the DOM event

param

The display object that was tested

param

the result of the hit test on the display object

Private processPointerUp

processPointerUp: any

Processes the result of the pointer up check and dispatches the event if need be

param

The interaction event wrapping the DOM event

param

The display object that was tested

param

the result of the hit test on the display object

Private releaseInteractionDataForPointerId

releaseInteractionDataForPointerId: any

Return unused InteractionData to the pool, for a given pointerId

param

Identifier from a pointer event

Private removeEvents

removeEvents: any

Removes all the DOM events that were previously registered

Private removeTickerListener

removeTickerListener: any

Remove the ticker listener

renderer

resolution

resolution: number

search

search: TreeSearch

Readonly supportsPointerEvents

supportsPointerEvents: boolean

Readonly supportsTouchEvents

supportsTouchEvents: boolean

Protected tickerAdded

tickerAdded: boolean

Static prefixed

prefixed: string | boolean

Accessors

Protected lastObjectRendered

  • Last rendered object or temp object

    readonly
    member

    {PIXI.DisplayObject}

    Returns DisplayObject

useSystemTicker

  • get useSystemTicker(): boolean
  • set useSystemTicker(useSystemTicker: boolean): void
  • Should the InteractionManager automatically add tickerUpdate to PIXI.Ticker.system.

    member

    {boolean}

    default

    true

    Returns boolean

  • Should the InteractionManager automatically add tickerUpdate to PIXI.Ticker.system.

    Parameters

    • useSystemTicker: boolean

    Returns void

Methods

addListener

destroy

  • destroy(): void
  • Destroys the interaction manager

    Returns void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Calls each of the listeners registered for a given event.

    Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): (string | symbol)[]
  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

hitTest

  • Hit tests a point against the display tree, returning the first interactive object that is hit.

    Parameters

    • globalPoint: Point

      A point to hit test with, in global space.

    • Optional root: DisplayObject

    Returns DisplayObject

    The hit display object, if any.

listenerCount

  • listenerCount(event: string | symbol): number
  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

listeners

  • Return the listeners registered for a given event.

    Parameters

    • event: string | symbol

    Returns ListenerFn[]

mapPositionToPoint

  • mapPositionToPoint(point: IPointData, x: number, y: number): void
  • Maps x and y coords from a DOM object and maps them correctly to the PixiJS view. The resulting value is stored in the point. This takes into account the fact that the DOM element could be scaled and positioned anywhere on the screen.

    Parameters

    • point: IPointData

      the point that the result will be stored in

    • x: number

      the x coord of the position to map

    • y: number

      the y coord of the position to map

    Returns void

off

  • Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns InteractionManager

on

  • Add a listener for a given event.

    Parameters

    • event: string | symbol
    • fn: ListenerFn
    • Optional context: any

    Returns InteractionManager

once

  • Add a one-time listener for a given event.

    Parameters

    • event: string | symbol
    • fn: ListenerFn
    • Optional context: any

    Returns InteractionManager

Protected processInteractive

  • This function is provides a neat way of crawling through the scene graph and running a specified function on all interactive objects it finds. It will also take care of hit testing the interactive objects and passes the hit across in the function.

    Parameters

    • interactionEvent: InteractionEvent

      event containing the point that is tested for collision

    • displayObject: DisplayObject

      the displayObject that will be hit test (recursively crawls its children)

    • Optional func: InteractionCallback
    • Optional hitTest: boolean

    Returns void

removeAllListeners

removeListener

  • Remove the listeners of a given event.

    Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns InteractionManager

setCursorMode

  • setCursorMode(mode: string): void
  • Sets the current cursor mode, handling any callbacks or CSS style changes.

    Parameters

    • mode: string

      cursor mode, a key from the cursorStyles dictionary

    Returns void

setTargetElement

  • setTargetElement(element: HTMLElement, resolution?: number): void
  • Sets the DOM element which will receive mouse/touch events. This is useful for when you have other DOM elements on top of the renderers Canvas element. With this you'll be bale to delegate another DOM element to receive those events.

    Parameters

    • element: HTMLElement

      the DOM element which will receive mouse and touch events.

    • Optional resolution: number

    Returns void

tickerUpdate

  • tickerUpdate(deltaTime: number): void
  • Updates the state of interactive objects if at least interactionFrequency milliseconds have passed since the last invocation.

    Invoked by a throttled ticker update from PIXI.Ticker.system.

    Parameters

    • deltaTime: number

      time delta since the last call

    Returns void

update

  • update(): void
  • Updates the state of interactive objects.

    Returns void

Generated using TypeDoc