Name | Type | Attributes | Description |
---|---|---|---|
rootTarget |
Container |
<optional> |
The holder of the event boundary. |
Members
cursor Cursor | string
The cursor preferred by the event targets underneath this boundary.
Emits events after they were dispatched into the scene graph.
This can be used for global events listening, regardless of the scene graph being used. It should not be used by interactive libraries for normal use.
Special events that do not bubble all the way to the root target are not emitted from here, e.g. pointerenter, pointerleave, click.
Enables the global move events. globalpointermove
, globaltouchmove
, and globalmousemove
- Default Value:
- true
This flag would emit pointermove
, touchmove
, and mousemove
events on all Containers.
The moveOnAll
semantics mirror those of earlier versions of PixiJS. This was disabled in favor of
the Pointer Event API's approach.
- Default Value:
- false
rootTarget Container
The root event-target residing below the event boundary.
All events are dispatched trickling down and bubbling up to this rootTarget
.
eventPool Map<typeof FederatedEvent, FederatedEvent[]> protected
The event pool maps event constructors to an free pool of instances of those specific events.
- See:
-
- EventBoundary#allocateEvent
- EventBoundary#freeEvent
State object for mapping methods.
- See:
-
- EventBoundary#trackingData
mappingTable Record<string, FederatedEvent<{ fn : (e: Array) => void, priority : number }>> protected
Maps event types to forwarding handles for them.
EventBoundary provides mapping for "pointerdown", "pointermove", "pointerout", "pointerleave", "pointerover", "pointerup", and "pointerupoutside" by default.
- See:
-
- EventBoundary#addEventMapping
Methods
Adds an event mapping for the event type
handled by fn
.
Event mappings can be used to implement additional or custom events. They take an event coming from the upstream scene (or directly from the EventSystem) and dispatch new downstream events generally trickling down and bubbling up to this.rootTarget.
To modify the semantics of existing events, the built-in mapping methods of EventBoundary should be overridden instead.
Name | Type | Description |
---|---|---|
type |
string |
The type of upstream event to map. |
fn |
(e: FederatedEvent) => void |
The mapping method. The context of this function must be bound manually, if desired. |
Emits the event e
to all interactive containers. The event is propagated in the bubbling phase always.
This is used in the globalpointermove
event.
Name | Type | Attributes | Description |
---|---|---|---|
e |
FederatedEvent |
The emitted event. |
|
type |
string | string[] |
<optional> |
The listeners to notify. |
targets |
The targets to notify. |
Dispatches the given event
Name | Type | Attributes | Description |
---|---|---|---|
e |
FederatedEvent |
The event to dispatch. |
|
type |
string |
<optional> |
The type of event to dispatch. Defaults to |
Finds the Container that is the target of a event at the given coordinates.
The passed (x,y) coordinates are in the world space above this event boundary.
Name | Type | Description |
---|---|---|
x |
number |
The x coordinate of the event. |
y |
number |
The y coordinate of the event. |
Returns:
Type | Description |
---|---|
Container |
Maps the given upstream event through the event boundary and propagates it downstream.
Name | Type | Description |
---|---|---|
e |
FederatedEvent |
The event to map. |
Propagate the passed event from from this.rootTarget to its
target e.target
.
Name | Type | Attributes | Description |
---|---|---|---|
e |
FederatedEvent |
The event to propagate. |
|
type |
string |
<optional> |
The type of event to propagate. Defaults to |
Finds the propagation path from rootTarget to the passed
target
. The last element in the path is target
.
Name | Type | Description |
---|---|---|
target |
Container |
The target to find the propagation path to. |
Returns:
Type | Description |
---|---|
Container[] |
Allocate a specific type of event from this.eventPool.
This allocation is constructor-agnostic, as long as it only takes one argument - this event boundary.
Name | Type | Description |
---|---|---|
constructor |
{ new (boundary: EventBoundary): T } |
The event's constructor. |
Returns:
Type | Description |
---|---|
T |
clonePointerEvent (from, type) FederatedPointerEvent protected
Clones the event from
, with an optional type
override.
The event is allocated using this.allocateEvent.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
from |
FederatedPointerEvent |
The event to clone. |
||
type |
string |
<optional> |
from.type |
The type of the returned event. |
Returns:
Type | Description |
---|---|
FederatedPointerEvent |
Copies base FederatedEvent data from from
into to
.
The following properties are copied:
- isTrusted
- srcElement
- timeStamp
- type
Name | Type | Description |
---|---|---|
from |
FederatedEvent |
The event to copy data from. |
to |
FederatedEvent |
The event to copy data into. |
Copies mouse FederatedMouseEvent data from from
to to
.
The following properties are copied:
- altKey
- button
- buttons
- clientX
- clientY
- metaKey
- movementX
- movementY
- pageX
- pageY
- x
- y
- screen
- shiftKey
- global
Name | Type | Description |
---|---|---|
from |
FederatedEvent |
The event to copy data from. |
to |
FederatedEvent |
The event to copy data into. |
Copies pointer FederatedPointerEvent data from from
into to
.
The following properties are copied:
- pointerId
- width
- height
- isPrimary
- pointerType
- pressure
- tangentialPressure
- tiltX
- tiltY
Name | Type | Description |
---|---|---|
from |
FederatedEvent |
The event to copy data from. |
to |
FederatedEvent |
The event to copy data into. |
Copies wheel FederatedWheelEvent data from from
into to
.
The following properties are copied:
- deltaMode
- deltaX
- deltaY
- deltaZ
Name | Type | Description |
---|---|---|
from |
FederatedWheelEvent |
The event to copy data from. |
to |
FederatedWheelEvent |
The event to copy data into. |
createPointerEvent (from, type, target) FederatedPointerEvent protected
Creates an event whose originalEvent
is from
, with an optional type
and target
override.
The event is allocated using this.allocateEvent.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
from |
FederatedPointerEvent |
The |
||
type |
string |
<optional> |
from.type |
The type of the returned event. |
target |
Container |
<optional> |
The target of the returned event. |
Returns:
Type | Description |
---|---|
FederatedPointerEvent |
createWheelEvent (from) FederatedWheelEvent protected
Creates a wheel event whose originalEvent
is from
.
The event is allocated using this.allocateEvent.
Name | Type | Description |
---|---|---|
from |
FederatedWheelEvent |
The upstream wheel event. |
Returns:
Type | Description |
---|---|
FederatedWheelEvent |
Finds the most specific event-target in the given propagation path that is still mounted in the scene graph.
This is used to find the correct pointerup
and pointerout
target in the case that the original pointerdown
or pointerover
target was unmounted from the scene graph.
Name | Type | Description |
---|---|---|
propagationPath |
Container[] |
The propagation path was valid in the past. |
Returns:
Type | Description |
---|---|
Container |
|
Frees the event and puts it back into the event pool.
It is illegal to reuse the event until it is allocated again, using this.allocateEvent
.
It is also advised that events not allocated from this.allocateEvent not be freed. This is because of the possibility that the same event is freed twice, which can cause it to be allocated twice & result in overwriting.
Name | Type | Description |
---|---|---|
event |
T |
The event to be freed. |
Checks whether the container or any of its children cannot pass the hit test at all.
EventBoundary's implementation uses the hitArea and {@link Container._maskEffect} for pruning.
Name | Type | Description |
---|---|---|
container |
Container |
The container to prune. |
location |
Point |
The location to test for overlap. |
Returns:
Type | Description |
---|---|
boolean |
Checks whether the container passes hit testing for the given location.
Name | Type | Description |
---|---|---|
container |
Container |
The container to test. |
location |
Point |
The location to test for overlap. |
Returns:
Type | Description |
---|---|
boolean |
|
Recursive implementation for hitTest.
Name | Type | Description |
---|---|---|
currentTarget |
Container |
The Container that is to be hit tested. |
eventMode |
EventMode |
The event mode for the |
location |
Point |
The location that is being tested for overlap. |
testFn |
(object: Container, pt: Point) => boolean |
Callback that determines whether the target passes hit testing. This callback
can assume that |
pruneFn |
(object: Container, pt: Point) => boolean |
Callback that determiness whether the target and all of its children cannot pass the hit test. It is used as a preliminary optimization to prune entire subtrees of the scene graph. |
Returns:
Type | Description |
---|---|
Container[] | An array holding the hit testing target and all its ancestors in order. The first element is the target itself and the last is rootTarget. This is the opposite order w.r.t. the propagation path. If no hit testing target is found, null is returned. |
Maps the upstream pointerdown
events to a downstream pointerdown
event.
touchstart
, rightdown
, mousedown
events are also dispatched for specific pointer types.
Name | Type | Description |
---|---|---|
from |
FederatedEvent |
The upstream |
Maps the upstream pointermove
to downstream pointerout
, pointerover
, and pointermove
events, in that order.
The tracking data for the specific pointer has an updated overTarget
. mouseout
, mouseover
,
mousemove
, and touchmove
events are fired as well for specific pointer types.
Name | Type | Description |
---|---|---|
from |
FederatedEvent |
The upstream |
Maps the upstream pointerout
to downstream pointerout
, pointerleave
events, in that order.
The tracking data for the specific pointer is cleared of a overTarget
.
Name | Type | Description |
---|---|---|
from |
FederatedEvent |
The upstream |
Maps the upstream pointerover
to downstream pointerover
and pointerenter
events, in that order.
The tracking data for the specific pointer gets a new overTarget
.
Name | Type | Description |
---|---|---|
from |
FederatedEvent |
The upstream |
Maps the upstream pointerup
event to downstream pointerup
, pointerupoutside
,
and click
/rightclick
/pointertap
events, in that order.
The pointerupoutside
event bubbles from the original pointerdown
target to the most specific
ancestor of the pointerdown
and pointerup
targets, which is also the click
event's target. touchend
,
rightup
, mouseup
, touchendoutside
, rightupoutside
, mouseupoutside
, and tap
are fired as well for
specific pointer types.
Name | Type | Description |
---|---|---|
from |
FederatedEvent |
The upstream |
Maps the upstream pointerupoutside
event to a downstream pointerupoutside
event, bubbling from the original
pointerdown
target to rootTarget
.
(The most specific ancestor of the pointerdown
event and the pointerup
event must the
EventBoundary's root because the
pointerup` event occurred outside of the boundary.)
touchendoutside
, mouseupoutside
, and rightupoutside
events are fired as well for specific pointer
types. The tracking data for the specific pointer is cleared of a pressTarget
.
Name | Type | Description |
---|---|---|
from |
FederatedEvent |
The upstream |
Maps the upstream wheel
event to a downstream wheel
event.
Name | Type | Description |
---|---|---|
from |
FederatedEvent |
The upstream |
Notify all the listeners to the event's currentTarget
.
If the currentTarget
contains the property on<type>
, then it is called here,
simulating the behavior from version 6.x and prior.
Name | Type | Attributes | Description |
---|---|---|---|
e |
FederatedEvent |
The event passed to the target. |
|
type |
string |
<optional> |
The type of event to notify. Defaults to |
trackingData (id) TrackingData protected
Name | Type | Description |
---|---|---|
id |
number |
The pointer ID. |
Returns:
Type | Description |
---|---|
TrackingData | The tracking data stored for the given pointer. If no data exists, a blank state will be created. |