sdfsdfs
This commit is contained in:
410
node_modules/pixi.js/lib/events/EventBoundary.d.ts
generated
vendored
Normal file
410
node_modules/pixi.js/lib/events/EventBoundary.d.ts
generated
vendored
Normal file
@@ -0,0 +1,410 @@
|
||||
import EventEmitter from 'eventemitter3';
|
||||
import { Point } from '../maths/point/Point';
|
||||
import { FederatedPointerEvent } from './FederatedPointerEvent';
|
||||
import { FederatedWheelEvent } from './FederatedWheelEvent';
|
||||
import type { Container } from '../scene/container/Container';
|
||||
import type { TrackingData } from './EventBoundaryTypes';
|
||||
import type { FederatedEvent } from './FederatedEvent';
|
||||
import type { Cursor, EventMode } from './FederatedEventTarget';
|
||||
/**
|
||||
* Event boundaries are "barriers" where events coming from an upstream scene are modified before downstream propagation.
|
||||
*
|
||||
* ## Root event boundary
|
||||
*
|
||||
* The {@link EventSystem#rootBoundary rootBoundary} handles events coming from the <canvas />.
|
||||
* {@link EventSystem} handles the normalization from native {@link https://dom.spec.whatwg.org/#event Events}
|
||||
* into {@link FederatedEvent FederatedEvents}. The rootBoundary then does the hit-testing and event dispatch
|
||||
* for the upstream normalized event.
|
||||
*
|
||||
* ## Additional event boundaries
|
||||
*
|
||||
* An additional event boundary may be desired within an application's scene graph. For example, if a portion of the scene is
|
||||
* is flat with many children at one level - a spatial hash maybe needed to accelerate hit testing. In this scenario, the
|
||||
* container can be detached from the scene and glued using a custom event boundary.
|
||||
*
|
||||
* ```ts
|
||||
* import { Container } from 'pixi.js';
|
||||
* import { EventBoundary } from 'pixi.js';
|
||||
* import { SpatialHash } from 'pixi-spatial-hash';
|
||||
*
|
||||
* class HashedHitTestingEventBoundary
|
||||
* {
|
||||
* private spatialHash: SpatialHash;
|
||||
*
|
||||
* constructor(scene: Container, spatialHash: SpatialHash)
|
||||
* {
|
||||
* super(scene);
|
||||
* this.spatialHash = spatialHash;
|
||||
* }
|
||||
*
|
||||
* hitTestRecursive(...)
|
||||
* {
|
||||
* // TODO: If target === this.rootTarget, then use spatial hash to get a
|
||||
* // list of possible children that match the given (x,y) coordinates.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* class VastScene extends Container
|
||||
* {
|
||||
* protected eventBoundary: EventBoundary;
|
||||
* protected scene: Container;
|
||||
* protected spatialHash: SpatialHash;
|
||||
*
|
||||
* constructor()
|
||||
* {
|
||||
* this.scene = new Container();
|
||||
* this.spatialHash = new SpatialHash();
|
||||
* this.eventBoundary = new HashedHitTestingEventBoundary(this.scene, this.spatialHash);
|
||||
*
|
||||
* // Populate this.scene with a ton of children, while updating this.spatialHash
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @memberof events
|
||||
*/
|
||||
export declare class EventBoundary {
|
||||
/**
|
||||
* The root event-target residing below the event boundary.
|
||||
* All events are dispatched trickling down and bubbling up to this `rootTarget`.
|
||||
*/
|
||||
rootTarget: Container;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
dispatch: EventEmitter;
|
||||
/** The cursor preferred by the event targets underneath this boundary. */
|
||||
cursor: Cursor | string;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
moveOnAll: boolean;
|
||||
/** Enables the global move events. `globalpointermove`, `globaltouchmove`, and `globalmousemove` */
|
||||
enableGlobalMoveEvents: boolean;
|
||||
/**
|
||||
* Maps event types to forwarding handles for them.
|
||||
*
|
||||
* {@link EventBoundary EventBoundary} provides mapping for "pointerdown", "pointermove",
|
||||
* "pointerout", "pointerleave", "pointerover", "pointerup", and "pointerupoutside" by default.
|
||||
* @see EventBoundary#addEventMapping
|
||||
*/
|
||||
protected mappingTable: Record<string, Array<{
|
||||
fn: (e: FederatedEvent) => void;
|
||||
priority: number;
|
||||
}>>;
|
||||
/**
|
||||
* State object for mapping methods.
|
||||
* @see EventBoundary#trackingData
|
||||
*/
|
||||
protected mappingState: Record<string, any>;
|
||||
/**
|
||||
* The event pool maps event constructors to an free pool of instances of those specific events.
|
||||
* @see EventBoundary#allocateEvent
|
||||
* @see EventBoundary#freeEvent
|
||||
*/
|
||||
protected eventPool: Map<typeof FederatedEvent, FederatedEvent[]>;
|
||||
/** Every interactive element gathered from the scene. Only used in `pointermove` */
|
||||
private readonly _allInteractiveElements;
|
||||
/** Every element that passed the hit test. Only used in `pointermove` */
|
||||
private _hitElements;
|
||||
/** Whether or not to collect all the interactive elements from the scene. Enabled in `pointermove` */
|
||||
private _isPointerMoveEvent;
|
||||
/**
|
||||
* @param rootTarget - The holder of the event boundary.
|
||||
*/
|
||||
constructor(rootTarget?: Container);
|
||||
/**
|
||||
* 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 {@link EventSystem}) and dispatch new downstream events
|
||||
* generally trickling down and bubbling up to {@link EventBoundary.rootTarget this.rootTarget}.
|
||||
*
|
||||
* To modify the semantics of existing events, the built-in mapping methods of EventBoundary should be overridden
|
||||
* instead.
|
||||
* @param type - The type of upstream event to map.
|
||||
* @param fn - The mapping method. The context of this function must be bound manually, if desired.
|
||||
*/
|
||||
addEventMapping(type: string, fn: (e: FederatedEvent) => void): void;
|
||||
/**
|
||||
* Dispatches the given event
|
||||
* @param e - The event to dispatch.
|
||||
* @param type - The type of event to dispatch. Defaults to `e.type`.
|
||||
*/
|
||||
dispatchEvent(e: FederatedEvent, type?: string): void;
|
||||
/**
|
||||
* Maps the given upstream event through the event boundary and propagates it downstream.
|
||||
* @param e - The event to map.
|
||||
*/
|
||||
mapEvent(e: FederatedEvent): void;
|
||||
/**
|
||||
* 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.
|
||||
* @param x - The x coordinate of the event.
|
||||
* @param y - The y coordinate of the event.
|
||||
*/
|
||||
hitTest(x: number, y: number): Container;
|
||||
/**
|
||||
* Propagate the passed event from from {@link EventBoundary.rootTarget this.rootTarget} to its
|
||||
* target {@code e.target}.
|
||||
* @param e - The event to propagate.
|
||||
* @param type - The type of event to propagate. Defaults to `e.type`.
|
||||
*/
|
||||
propagate(e: FederatedEvent, type?: string): void;
|
||||
/**
|
||||
* Emits the event {@code e} to all interactive containers. The event is propagated in the bubbling phase always.
|
||||
*
|
||||
* This is used in the `globalpointermove` event.
|
||||
* @param e - The emitted event.
|
||||
* @param type - The listeners to notify.
|
||||
* @param targets - The targets to notify.
|
||||
*/
|
||||
all(e: FederatedEvent, type?: string | string[], targets?: Container<import("../scene/container/Container").ContainerChild>[]): void;
|
||||
/**
|
||||
* Finds the propagation path from {@link EventBoundary.rootTarget rootTarget} to the passed
|
||||
* {@code target}. The last element in the path is {@code target}.
|
||||
* @param target - The target to find the propagation path to.
|
||||
*/
|
||||
propagationPath(target: Container): Container[];
|
||||
protected hitTestMoveRecursive(currentTarget: Container, eventMode: EventMode, location: Point, testFn: (object: Container, pt: Point) => boolean, pruneFn: (object: Container, pt: Point) => boolean, ignore?: boolean): Container[];
|
||||
/**
|
||||
* Recursive implementation for {@link EventBoundary.hitTest hitTest}.
|
||||
* @param currentTarget - The Container that is to be hit tested.
|
||||
* @param eventMode - The event mode for the `currentTarget` or one of its parents.
|
||||
* @param location - The location that is being tested for overlap.
|
||||
* @param testFn - Callback that determines whether the target passes hit testing. This callback
|
||||
* can assume that `pruneFn` failed to prune the container.
|
||||
* @param pruneFn - 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 An array holding the hit testing target and all its ancestors in order. The first element
|
||||
* is the target itself and the last is {@link EventBoundary.rootTarget rootTarget}. This is the opposite
|
||||
* order w.r.t. the propagation path. If no hit testing target is found, null is returned.
|
||||
*/
|
||||
protected hitTestRecursive(currentTarget: Container, eventMode: EventMode, location: Point, testFn: (object: Container, pt: Point) => boolean, pruneFn: (object: Container, pt: Point) => boolean): Container[];
|
||||
private _isInteractive;
|
||||
private _interactivePrune;
|
||||
/**
|
||||
* Checks whether the container or any of its children cannot pass the hit test at all.
|
||||
*
|
||||
* {@link EventBoundary}'s implementation uses the {@link Container.hitArea hitArea}
|
||||
* and {@link Container._maskEffect} for pruning.
|
||||
* @param container - The container to prune.
|
||||
* @param location - The location to test for overlap.
|
||||
*/
|
||||
protected hitPruneFn(container: Container, location: Point): boolean;
|
||||
/**
|
||||
* Checks whether the container passes hit testing for the given location.
|
||||
* @param container - The container to test.
|
||||
* @param location - The location to test for overlap.
|
||||
* @returns - Whether `container` passes hit testing for `location`.
|
||||
*/
|
||||
protected hitTestFn(container: Container, location: Point): boolean;
|
||||
/**
|
||||
* 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.
|
||||
* @param e - The event passed to the target.
|
||||
* @param type - The type of event to notify. Defaults to `e.type`.
|
||||
*/
|
||||
protected notifyTarget(e: FederatedEvent, type?: string): void;
|
||||
/**
|
||||
* Maps the upstream `pointerdown` events to a downstream `pointerdown` event.
|
||||
*
|
||||
* `touchstart`, `rightdown`, `mousedown` events are also dispatched for specific pointer types.
|
||||
* @param from - The upstream `pointerdown` event.
|
||||
*/
|
||||
protected mapPointerDown(from: FederatedEvent): void;
|
||||
/**
|
||||
* 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.
|
||||
* @param from - The upstream `pointermove` event.
|
||||
*/
|
||||
protected mapPointerMove(from: FederatedEvent): void;
|
||||
/**
|
||||
* Maps the upstream `pointerover` to downstream `pointerover` and `pointerenter` events, in that order.
|
||||
*
|
||||
* The tracking data for the specific pointer gets a new `overTarget`.
|
||||
* @param from - The upstream `pointerover` event.
|
||||
*/
|
||||
protected mapPointerOver(from: FederatedEvent): void;
|
||||
/**
|
||||
* Maps the upstream `pointerout` to downstream `pointerout`, `pointerleave` events, in that order.
|
||||
*
|
||||
* The tracking data for the specific pointer is cleared of a `overTarget`.
|
||||
* @param from - The upstream `pointerout` event.
|
||||
*/
|
||||
protected mapPointerOut(from: FederatedEvent): void;
|
||||
/**
|
||||
* 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.
|
||||
* @param from - The upstream `pointerup` event.
|
||||
*/
|
||||
protected mapPointerUp(from: FederatedEvent): void;
|
||||
/**
|
||||
* 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
|
||||
* `{@link 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`.
|
||||
* @param from - The upstream `pointerupoutside` event.
|
||||
*/
|
||||
protected mapPointerUpOutside(from: FederatedEvent): void;
|
||||
/**
|
||||
* Maps the upstream `wheel` event to a downstream `wheel` event.
|
||||
* @param from - The upstream `wheel` event.
|
||||
*/
|
||||
protected mapWheel(from: FederatedEvent): void;
|
||||
/**
|
||||
* 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.
|
||||
* @param propagationPath - The propagation path was valid in the past.
|
||||
* @returns - The most specific event-target still mounted at the same location in the scene graph.
|
||||
*/
|
||||
protected findMountedTarget(propagationPath: Container[]): Container;
|
||||
/**
|
||||
* Creates an event whose {@code originalEvent} is {@code from}, with an optional `type` and `target` override.
|
||||
*
|
||||
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
||||
* @param from - The {@code originalEvent} for the returned event.
|
||||
* @param [type=from.type] - The type of the returned event.
|
||||
* @param target - The target of the returned event.
|
||||
*/
|
||||
protected createPointerEvent(from: FederatedPointerEvent, type?: string, target?: Container): FederatedPointerEvent;
|
||||
/**
|
||||
* Creates a wheel event whose {@code originalEvent} is {@code from}.
|
||||
*
|
||||
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
||||
* @param from - The upstream wheel event.
|
||||
*/
|
||||
protected createWheelEvent(from: FederatedWheelEvent): FederatedWheelEvent;
|
||||
/**
|
||||
* Clones the event {@code from}, with an optional {@code type} override.
|
||||
*
|
||||
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
||||
* @param from - The event to clone.
|
||||
* @param [type=from.type] - The type of the returned event.
|
||||
*/
|
||||
protected clonePointerEvent(from: FederatedPointerEvent, type?: string): FederatedPointerEvent;
|
||||
/**
|
||||
* Copies wheel {@link FederatedWheelEvent} data from {@code from} into {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + deltaMode
|
||||
* + deltaX
|
||||
* + deltaY
|
||||
* + deltaZ
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
protected copyWheelData(from: FederatedWheelEvent, to: FederatedWheelEvent): void;
|
||||
/**
|
||||
* Copies pointer {@link FederatedPointerEvent} data from {@code from} into {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + pointerId
|
||||
* + width
|
||||
* + height
|
||||
* + isPrimary
|
||||
* + pointerType
|
||||
* + pressure
|
||||
* + tangentialPressure
|
||||
* + tiltX
|
||||
* + tiltY
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
protected copyPointerData(from: FederatedEvent, to: FederatedEvent): void;
|
||||
/**
|
||||
* Copies mouse {@link FederatedMouseEvent} data from {@code from} to {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + altKey
|
||||
* + button
|
||||
* + buttons
|
||||
* + clientX
|
||||
* + clientY
|
||||
* + metaKey
|
||||
* + movementX
|
||||
* + movementY
|
||||
* + pageX
|
||||
* + pageY
|
||||
* + x
|
||||
* + y
|
||||
* + screen
|
||||
* + shiftKey
|
||||
* + global
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
protected copyMouseData(from: FederatedEvent, to: FederatedEvent): void;
|
||||
/**
|
||||
* Copies base {@link FederatedEvent} data from {@code from} into {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + isTrusted
|
||||
* + srcElement
|
||||
* + timeStamp
|
||||
* + type
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
protected copyData(from: FederatedEvent, to: FederatedEvent): void;
|
||||
/**
|
||||
* @param id - The pointer ID.
|
||||
* @returns The tracking data stored for the given pointer. If no data exists, a blank
|
||||
* state will be created.
|
||||
*/
|
||||
protected trackingData(id: number): TrackingData;
|
||||
/**
|
||||
* Allocate a specific type of event from {@link EventBoundary#eventPool this.eventPool}.
|
||||
*
|
||||
* This allocation is constructor-agnostic, as long as it only takes one argument - this event
|
||||
* boundary.
|
||||
* @param constructor - The event's constructor.
|
||||
*/
|
||||
protected allocateEvent<T extends FederatedEvent>(constructor: {
|
||||
new (boundary: EventBoundary): T;
|
||||
}): T;
|
||||
/**
|
||||
* 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 {@link EventBoundary#allocateEvent 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.
|
||||
* @param event - The event to be freed.
|
||||
* @throws Error if the event is managed by another event boundary.
|
||||
*/
|
||||
protected freeEvent<T extends FederatedEvent>(event: T): void;
|
||||
/**
|
||||
* Similar to {@link EventEmitter.emit}, except it stops if the `propagationImmediatelyStopped` flag
|
||||
* is set on the event.
|
||||
* @param e - The event to call each listener with.
|
||||
* @param type - The event key.
|
||||
*/
|
||||
private _notifyListeners;
|
||||
}
|
955
node_modules/pixi.js/lib/events/EventBoundary.js
generated
vendored
Normal file
955
node_modules/pixi.js/lib/events/EventBoundary.js
generated
vendored
Normal file
@@ -0,0 +1,955 @@
|
||||
'use strict';
|
||||
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var Point = require('../maths/point/Point.js');
|
||||
var warn = require('../utils/logging/warn.js');
|
||||
var EventTicker = require('./EventTicker.js');
|
||||
var FederatedMouseEvent = require('./FederatedMouseEvent.js');
|
||||
var FederatedPointerEvent = require('./FederatedPointerEvent.js');
|
||||
var FederatedWheelEvent = require('./FederatedWheelEvent.js');
|
||||
|
||||
"use strict";
|
||||
const PROPAGATION_LIMIT = 2048;
|
||||
const tempHitLocation = new Point.Point();
|
||||
const tempLocalMapping = new Point.Point();
|
||||
class EventBoundary {
|
||||
/**
|
||||
* @param rootTarget - The holder of the event boundary.
|
||||
*/
|
||||
constructor(rootTarget) {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
this.dispatch = new EventEmitter();
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
this.moveOnAll = false;
|
||||
/** Enables the global move events. `globalpointermove`, `globaltouchmove`, and `globalmousemove` */
|
||||
this.enableGlobalMoveEvents = true;
|
||||
/**
|
||||
* State object for mapping methods.
|
||||
* @see EventBoundary#trackingData
|
||||
*/
|
||||
this.mappingState = {
|
||||
trackingData: {}
|
||||
};
|
||||
/**
|
||||
* The event pool maps event constructors to an free pool of instances of those specific events.
|
||||
* @see EventBoundary#allocateEvent
|
||||
* @see EventBoundary#freeEvent
|
||||
*/
|
||||
this.eventPool = /* @__PURE__ */ new Map();
|
||||
/** Every interactive element gathered from the scene. Only used in `pointermove` */
|
||||
this._allInteractiveElements = [];
|
||||
/** Every element that passed the hit test. Only used in `pointermove` */
|
||||
this._hitElements = [];
|
||||
/** Whether or not to collect all the interactive elements from the scene. Enabled in `pointermove` */
|
||||
this._isPointerMoveEvent = false;
|
||||
this.rootTarget = rootTarget;
|
||||
this.hitPruneFn = this.hitPruneFn.bind(this);
|
||||
this.hitTestFn = this.hitTestFn.bind(this);
|
||||
this.mapPointerDown = this.mapPointerDown.bind(this);
|
||||
this.mapPointerMove = this.mapPointerMove.bind(this);
|
||||
this.mapPointerOut = this.mapPointerOut.bind(this);
|
||||
this.mapPointerOver = this.mapPointerOver.bind(this);
|
||||
this.mapPointerUp = this.mapPointerUp.bind(this);
|
||||
this.mapPointerUpOutside = this.mapPointerUpOutside.bind(this);
|
||||
this.mapWheel = this.mapWheel.bind(this);
|
||||
this.mappingTable = {};
|
||||
this.addEventMapping("pointerdown", this.mapPointerDown);
|
||||
this.addEventMapping("pointermove", this.mapPointerMove);
|
||||
this.addEventMapping("pointerout", this.mapPointerOut);
|
||||
this.addEventMapping("pointerleave", this.mapPointerOut);
|
||||
this.addEventMapping("pointerover", this.mapPointerOver);
|
||||
this.addEventMapping("pointerup", this.mapPointerUp);
|
||||
this.addEventMapping("pointerupoutside", this.mapPointerUpOutside);
|
||||
this.addEventMapping("wheel", this.mapWheel);
|
||||
}
|
||||
/**
|
||||
* 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 {@link EventSystem}) and dispatch new downstream events
|
||||
* generally trickling down and bubbling up to {@link EventBoundary.rootTarget this.rootTarget}.
|
||||
*
|
||||
* To modify the semantics of existing events, the built-in mapping methods of EventBoundary should be overridden
|
||||
* instead.
|
||||
* @param type - The type of upstream event to map.
|
||||
* @param fn - The mapping method. The context of this function must be bound manually, if desired.
|
||||
*/
|
||||
addEventMapping(type, fn) {
|
||||
if (!this.mappingTable[type]) {
|
||||
this.mappingTable[type] = [];
|
||||
}
|
||||
this.mappingTable[type].push({
|
||||
fn,
|
||||
priority: 0
|
||||
});
|
||||
this.mappingTable[type].sort((a, b) => a.priority - b.priority);
|
||||
}
|
||||
/**
|
||||
* Dispatches the given event
|
||||
* @param e - The event to dispatch.
|
||||
* @param type - The type of event to dispatch. Defaults to `e.type`.
|
||||
*/
|
||||
dispatchEvent(e, type) {
|
||||
e.propagationStopped = false;
|
||||
e.propagationImmediatelyStopped = false;
|
||||
this.propagate(e, type);
|
||||
this.dispatch.emit(type || e.type, e);
|
||||
}
|
||||
/**
|
||||
* Maps the given upstream event through the event boundary and propagates it downstream.
|
||||
* @param e - The event to map.
|
||||
*/
|
||||
mapEvent(e) {
|
||||
if (!this.rootTarget) {
|
||||
return;
|
||||
}
|
||||
const mappers = this.mappingTable[e.type];
|
||||
if (mappers) {
|
||||
for (let i = 0, j = mappers.length; i < j; i++) {
|
||||
mappers[i].fn(e);
|
||||
}
|
||||
} else {
|
||||
warn.warn(`[EventBoundary]: Event mapping not defined for ${e.type}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param x - The x coordinate of the event.
|
||||
* @param y - The y coordinate of the event.
|
||||
*/
|
||||
hitTest(x, y) {
|
||||
EventTicker.EventsTicker.pauseUpdate = true;
|
||||
const useMove = this._isPointerMoveEvent && this.enableGlobalMoveEvents;
|
||||
const fn = useMove ? "hitTestMoveRecursive" : "hitTestRecursive";
|
||||
const invertedPath = this[fn](
|
||||
this.rootTarget,
|
||||
this.rootTarget.eventMode,
|
||||
tempHitLocation.set(x, y),
|
||||
this.hitTestFn,
|
||||
this.hitPruneFn
|
||||
);
|
||||
return invertedPath && invertedPath[0];
|
||||
}
|
||||
/**
|
||||
* Propagate the passed event from from {@link EventBoundary.rootTarget this.rootTarget} to its
|
||||
* target {@code e.target}.
|
||||
* @param e - The event to propagate.
|
||||
* @param type - The type of event to propagate. Defaults to `e.type`.
|
||||
*/
|
||||
propagate(e, type) {
|
||||
if (!e.target) {
|
||||
return;
|
||||
}
|
||||
const composedPath = e.composedPath();
|
||||
e.eventPhase = e.CAPTURING_PHASE;
|
||||
for (let i = 0, j = composedPath.length - 1; i < j; i++) {
|
||||
e.currentTarget = composedPath[i];
|
||||
this.notifyTarget(e, type);
|
||||
if (e.propagationStopped || e.propagationImmediatelyStopped)
|
||||
return;
|
||||
}
|
||||
e.eventPhase = e.AT_TARGET;
|
||||
e.currentTarget = e.target;
|
||||
this.notifyTarget(e, type);
|
||||
if (e.propagationStopped || e.propagationImmediatelyStopped)
|
||||
return;
|
||||
e.eventPhase = e.BUBBLING_PHASE;
|
||||
for (let i = composedPath.length - 2; i >= 0; i--) {
|
||||
e.currentTarget = composedPath[i];
|
||||
this.notifyTarget(e, type);
|
||||
if (e.propagationStopped || e.propagationImmediatelyStopped)
|
||||
return;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Emits the event {@code e} to all interactive containers. The event is propagated in the bubbling phase always.
|
||||
*
|
||||
* This is used in the `globalpointermove` event.
|
||||
* @param e - The emitted event.
|
||||
* @param type - The listeners to notify.
|
||||
* @param targets - The targets to notify.
|
||||
*/
|
||||
all(e, type, targets = this._allInteractiveElements) {
|
||||
if (targets.length === 0)
|
||||
return;
|
||||
e.eventPhase = e.BUBBLING_PHASE;
|
||||
const events = Array.isArray(type) ? type : [type];
|
||||
for (let i = targets.length - 1; i >= 0; i--) {
|
||||
events.forEach((event) => {
|
||||
e.currentTarget = targets[i];
|
||||
this.notifyTarget(e, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Finds the propagation path from {@link EventBoundary.rootTarget rootTarget} to the passed
|
||||
* {@code target}. The last element in the path is {@code target}.
|
||||
* @param target - The target to find the propagation path to.
|
||||
*/
|
||||
propagationPath(target) {
|
||||
const propagationPath = [target];
|
||||
for (let i = 0; i < PROPAGATION_LIMIT && (target !== this.rootTarget && target.parent); i++) {
|
||||
if (!target.parent) {
|
||||
throw new Error("Cannot find propagation path to disconnected target");
|
||||
}
|
||||
propagationPath.push(target.parent);
|
||||
target = target.parent;
|
||||
}
|
||||
propagationPath.reverse();
|
||||
return propagationPath;
|
||||
}
|
||||
hitTestMoveRecursive(currentTarget, eventMode, location, testFn, pruneFn, ignore = false) {
|
||||
let shouldReturn = false;
|
||||
if (this._interactivePrune(currentTarget))
|
||||
return null;
|
||||
if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") {
|
||||
EventTicker.EventsTicker.pauseUpdate = false;
|
||||
}
|
||||
if (currentTarget.interactiveChildren && currentTarget.children) {
|
||||
const children = currentTarget.children;
|
||||
for (let i = children.length - 1; i >= 0; i--) {
|
||||
const child = children[i];
|
||||
const nestedHit = this.hitTestMoveRecursive(
|
||||
child,
|
||||
this._isInteractive(eventMode) ? eventMode : child.eventMode,
|
||||
location,
|
||||
testFn,
|
||||
pruneFn,
|
||||
ignore || pruneFn(currentTarget, location)
|
||||
);
|
||||
if (nestedHit) {
|
||||
if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
|
||||
continue;
|
||||
}
|
||||
const isInteractive = currentTarget.isInteractive();
|
||||
if (nestedHit.length > 0 || isInteractive) {
|
||||
if (isInteractive)
|
||||
this._allInteractiveElements.push(currentTarget);
|
||||
nestedHit.push(currentTarget);
|
||||
}
|
||||
if (this._hitElements.length === 0)
|
||||
this._hitElements = nestedHit;
|
||||
shouldReturn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
const isInteractiveMode = this._isInteractive(eventMode);
|
||||
const isInteractiveTarget = currentTarget.isInteractive();
|
||||
if (isInteractiveTarget && isInteractiveTarget)
|
||||
this._allInteractiveElements.push(currentTarget);
|
||||
if (ignore || this._hitElements.length > 0)
|
||||
return null;
|
||||
if (shouldReturn)
|
||||
return this._hitElements;
|
||||
if (isInteractiveMode && (!pruneFn(currentTarget, location) && testFn(currentTarget, location))) {
|
||||
return isInteractiveTarget ? [currentTarget] : [];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Recursive implementation for {@link EventBoundary.hitTest hitTest}.
|
||||
* @param currentTarget - The Container that is to be hit tested.
|
||||
* @param eventMode - The event mode for the `currentTarget` or one of its parents.
|
||||
* @param location - The location that is being tested for overlap.
|
||||
* @param testFn - Callback that determines whether the target passes hit testing. This callback
|
||||
* can assume that `pruneFn` failed to prune the container.
|
||||
* @param pruneFn - 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 An array holding the hit testing target and all its ancestors in order. The first element
|
||||
* is the target itself and the last is {@link EventBoundary.rootTarget rootTarget}. This is the opposite
|
||||
* order w.r.t. the propagation path. If no hit testing target is found, null is returned.
|
||||
*/
|
||||
hitTestRecursive(currentTarget, eventMode, location, testFn, pruneFn) {
|
||||
if (this._interactivePrune(currentTarget) || pruneFn(currentTarget, location)) {
|
||||
return null;
|
||||
}
|
||||
if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") {
|
||||
EventTicker.EventsTicker.pauseUpdate = false;
|
||||
}
|
||||
if (currentTarget.interactiveChildren && currentTarget.children) {
|
||||
const children = currentTarget.children;
|
||||
const relativeLocation = location;
|
||||
for (let i = children.length - 1; i >= 0; i--) {
|
||||
const child = children[i];
|
||||
const nestedHit = this.hitTestRecursive(
|
||||
child,
|
||||
this._isInteractive(eventMode) ? eventMode : child.eventMode,
|
||||
relativeLocation,
|
||||
testFn,
|
||||
pruneFn
|
||||
);
|
||||
if (nestedHit) {
|
||||
if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
|
||||
continue;
|
||||
}
|
||||
const isInteractive = currentTarget.isInteractive();
|
||||
if (nestedHit.length > 0 || isInteractive)
|
||||
nestedHit.push(currentTarget);
|
||||
return nestedHit;
|
||||
}
|
||||
}
|
||||
}
|
||||
const isInteractiveMode = this._isInteractive(eventMode);
|
||||
const isInteractiveTarget = currentTarget.isInteractive();
|
||||
if (isInteractiveMode && testFn(currentTarget, location)) {
|
||||
return isInteractiveTarget ? [currentTarget] : [];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
_isInteractive(int) {
|
||||
return int === "static" || int === "dynamic";
|
||||
}
|
||||
_interactivePrune(container) {
|
||||
if (!container || !container.visible || !container.renderable || !container.includeInBuild || !container.measurable) {
|
||||
return true;
|
||||
}
|
||||
if (container.eventMode === "none") {
|
||||
return true;
|
||||
}
|
||||
if (container.eventMode === "passive" && !container.interactiveChildren) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Checks whether the container or any of its children cannot pass the hit test at all.
|
||||
*
|
||||
* {@link EventBoundary}'s implementation uses the {@link Container.hitArea hitArea}
|
||||
* and {@link Container._maskEffect} for pruning.
|
||||
* @param container - The container to prune.
|
||||
* @param location - The location to test for overlap.
|
||||
*/
|
||||
hitPruneFn(container, location) {
|
||||
if (container.hitArea) {
|
||||
container.worldTransform.applyInverse(location, tempLocalMapping);
|
||||
if (!container.hitArea.contains(tempLocalMapping.x, tempLocalMapping.y)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (container.effects && container.effects.length) {
|
||||
for (let i = 0; i < container.effects.length; i++) {
|
||||
const effect = container.effects[i];
|
||||
if (effect.containsPoint) {
|
||||
const effectContainsPoint = effect.containsPoint(location, this.hitTestFn);
|
||||
if (!effectContainsPoint) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Checks whether the container passes hit testing for the given location.
|
||||
* @param container - The container to test.
|
||||
* @param location - The location to test for overlap.
|
||||
* @returns - Whether `container` passes hit testing for `location`.
|
||||
*/
|
||||
hitTestFn(container, location) {
|
||||
if (container.hitArea) {
|
||||
return true;
|
||||
}
|
||||
if (container?.containsPoint) {
|
||||
container.worldTransform.applyInverse(location, tempLocalMapping);
|
||||
return container.containsPoint(tempLocalMapping);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param e - The event passed to the target.
|
||||
* @param type - The type of event to notify. Defaults to `e.type`.
|
||||
*/
|
||||
notifyTarget(e, type) {
|
||||
if (!e.currentTarget.isInteractive()) {
|
||||
return;
|
||||
}
|
||||
type = type ?? e.type;
|
||||
const handlerKey = `on${type}`;
|
||||
e.currentTarget[handlerKey]?.(e);
|
||||
const key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? `${type}capture` : type;
|
||||
this._notifyListeners(e, key);
|
||||
if (e.eventPhase === e.AT_TARGET) {
|
||||
this._notifyListeners(e, type);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Maps the upstream `pointerdown` events to a downstream `pointerdown` event.
|
||||
*
|
||||
* `touchstart`, `rightdown`, `mousedown` events are also dispatched for specific pointer types.
|
||||
* @param from - The upstream `pointerdown` event.
|
||||
*/
|
||||
mapPointerDown(from) {
|
||||
if (!(from instanceof FederatedPointerEvent.FederatedPointerEvent)) {
|
||||
warn.warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
const e = this.createPointerEvent(from);
|
||||
this.dispatchEvent(e, "pointerdown");
|
||||
if (e.pointerType === "touch") {
|
||||
this.dispatchEvent(e, "touchstart");
|
||||
} else if (e.pointerType === "mouse" || e.pointerType === "pen") {
|
||||
const isRightButton = e.button === 2;
|
||||
this.dispatchEvent(e, isRightButton ? "rightdown" : "mousedown");
|
||||
}
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
trackingData.pressTargetsByButton[from.button] = e.composedPath();
|
||||
this.freeEvent(e);
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param from - The upstream `pointermove` event.
|
||||
*/
|
||||
mapPointerMove(from) {
|
||||
if (!(from instanceof FederatedPointerEvent.FederatedPointerEvent)) {
|
||||
warn.warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
this._allInteractiveElements.length = 0;
|
||||
this._hitElements.length = 0;
|
||||
this._isPointerMoveEvent = true;
|
||||
const e = this.createPointerEvent(from);
|
||||
this._isPointerMoveEvent = false;
|
||||
const isMouse = e.pointerType === "mouse" || e.pointerType === "pen";
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
const outTarget = this.findMountedTarget(trackingData.overTargets);
|
||||
if (trackingData.overTargets?.length > 0 && outTarget !== e.target) {
|
||||
const outType = from.type === "mousemove" ? "mouseout" : "pointerout";
|
||||
const outEvent = this.createPointerEvent(from, outType, outTarget);
|
||||
this.dispatchEvent(outEvent, "pointerout");
|
||||
if (isMouse)
|
||||
this.dispatchEvent(outEvent, "mouseout");
|
||||
if (!e.composedPath().includes(outTarget)) {
|
||||
const leaveEvent = this.createPointerEvent(from, "pointerleave", outTarget);
|
||||
leaveEvent.eventPhase = leaveEvent.AT_TARGET;
|
||||
while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
|
||||
leaveEvent.currentTarget = leaveEvent.target;
|
||||
this.notifyTarget(leaveEvent);
|
||||
if (isMouse)
|
||||
this.notifyTarget(leaveEvent, "mouseleave");
|
||||
leaveEvent.target = leaveEvent.target.parent;
|
||||
}
|
||||
this.freeEvent(leaveEvent);
|
||||
}
|
||||
this.freeEvent(outEvent);
|
||||
}
|
||||
if (outTarget !== e.target) {
|
||||
const overType = from.type === "mousemove" ? "mouseover" : "pointerover";
|
||||
const overEvent = this.clonePointerEvent(e, overType);
|
||||
this.dispatchEvent(overEvent, "pointerover");
|
||||
if (isMouse)
|
||||
this.dispatchEvent(overEvent, "mouseover");
|
||||
let overTargetAncestor = outTarget?.parent;
|
||||
while (overTargetAncestor && overTargetAncestor !== this.rootTarget.parent) {
|
||||
if (overTargetAncestor === e.target)
|
||||
break;
|
||||
overTargetAncestor = overTargetAncestor.parent;
|
||||
}
|
||||
const didPointerEnter = !overTargetAncestor || overTargetAncestor === this.rootTarget.parent;
|
||||
if (didPointerEnter) {
|
||||
const enterEvent = this.clonePointerEvent(e, "pointerenter");
|
||||
enterEvent.eventPhase = enterEvent.AT_TARGET;
|
||||
while (enterEvent.target && enterEvent.target !== outTarget && enterEvent.target !== this.rootTarget.parent) {
|
||||
enterEvent.currentTarget = enterEvent.target;
|
||||
this.notifyTarget(enterEvent);
|
||||
if (isMouse)
|
||||
this.notifyTarget(enterEvent, "mouseenter");
|
||||
enterEvent.target = enterEvent.target.parent;
|
||||
}
|
||||
this.freeEvent(enterEvent);
|
||||
}
|
||||
this.freeEvent(overEvent);
|
||||
}
|
||||
const allMethods = [];
|
||||
const allowGlobalPointerEvents = this.enableGlobalMoveEvents ?? true;
|
||||
this.moveOnAll ? allMethods.push("pointermove") : this.dispatchEvent(e, "pointermove");
|
||||
allowGlobalPointerEvents && allMethods.push("globalpointermove");
|
||||
if (e.pointerType === "touch") {
|
||||
this.moveOnAll ? allMethods.splice(1, 0, "touchmove") : this.dispatchEvent(e, "touchmove");
|
||||
allowGlobalPointerEvents && allMethods.push("globaltouchmove");
|
||||
}
|
||||
if (isMouse) {
|
||||
this.moveOnAll ? allMethods.splice(1, 0, "mousemove") : this.dispatchEvent(e, "mousemove");
|
||||
allowGlobalPointerEvents && allMethods.push("globalmousemove");
|
||||
this.cursor = e.target?.cursor;
|
||||
}
|
||||
if (allMethods.length > 0) {
|
||||
this.all(e, allMethods);
|
||||
}
|
||||
this._allInteractiveElements.length = 0;
|
||||
this._hitElements.length = 0;
|
||||
trackingData.overTargets = e.composedPath();
|
||||
this.freeEvent(e);
|
||||
}
|
||||
/**
|
||||
* Maps the upstream `pointerover` to downstream `pointerover` and `pointerenter` events, in that order.
|
||||
*
|
||||
* The tracking data for the specific pointer gets a new `overTarget`.
|
||||
* @param from - The upstream `pointerover` event.
|
||||
*/
|
||||
mapPointerOver(from) {
|
||||
if (!(from instanceof FederatedPointerEvent.FederatedPointerEvent)) {
|
||||
warn.warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
const e = this.createPointerEvent(from);
|
||||
const isMouse = e.pointerType === "mouse" || e.pointerType === "pen";
|
||||
this.dispatchEvent(e, "pointerover");
|
||||
if (isMouse)
|
||||
this.dispatchEvent(e, "mouseover");
|
||||
if (e.pointerType === "mouse")
|
||||
this.cursor = e.target?.cursor;
|
||||
const enterEvent = this.clonePointerEvent(e, "pointerenter");
|
||||
enterEvent.eventPhase = enterEvent.AT_TARGET;
|
||||
while (enterEvent.target && enterEvent.target !== this.rootTarget.parent) {
|
||||
enterEvent.currentTarget = enterEvent.target;
|
||||
this.notifyTarget(enterEvent);
|
||||
if (isMouse)
|
||||
this.notifyTarget(enterEvent, "mouseenter");
|
||||
enterEvent.target = enterEvent.target.parent;
|
||||
}
|
||||
trackingData.overTargets = e.composedPath();
|
||||
this.freeEvent(e);
|
||||
this.freeEvent(enterEvent);
|
||||
}
|
||||
/**
|
||||
* Maps the upstream `pointerout` to downstream `pointerout`, `pointerleave` events, in that order.
|
||||
*
|
||||
* The tracking data for the specific pointer is cleared of a `overTarget`.
|
||||
* @param from - The upstream `pointerout` event.
|
||||
*/
|
||||
mapPointerOut(from) {
|
||||
if (!(from instanceof FederatedPointerEvent.FederatedPointerEvent)) {
|
||||
warn.warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
if (trackingData.overTargets) {
|
||||
const isMouse = from.pointerType === "mouse" || from.pointerType === "pen";
|
||||
const outTarget = this.findMountedTarget(trackingData.overTargets);
|
||||
const outEvent = this.createPointerEvent(from, "pointerout", outTarget);
|
||||
this.dispatchEvent(outEvent);
|
||||
if (isMouse)
|
||||
this.dispatchEvent(outEvent, "mouseout");
|
||||
const leaveEvent = this.createPointerEvent(from, "pointerleave", outTarget);
|
||||
leaveEvent.eventPhase = leaveEvent.AT_TARGET;
|
||||
while (leaveEvent.target && leaveEvent.target !== this.rootTarget.parent) {
|
||||
leaveEvent.currentTarget = leaveEvent.target;
|
||||
this.notifyTarget(leaveEvent);
|
||||
if (isMouse)
|
||||
this.notifyTarget(leaveEvent, "mouseleave");
|
||||
leaveEvent.target = leaveEvent.target.parent;
|
||||
}
|
||||
trackingData.overTargets = null;
|
||||
this.freeEvent(outEvent);
|
||||
this.freeEvent(leaveEvent);
|
||||
}
|
||||
this.cursor = null;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param from - The upstream `pointerup` event.
|
||||
*/
|
||||
mapPointerUp(from) {
|
||||
if (!(from instanceof FederatedPointerEvent.FederatedPointerEvent)) {
|
||||
warn.warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
const now = performance.now();
|
||||
const e = this.createPointerEvent(from);
|
||||
this.dispatchEvent(e, "pointerup");
|
||||
if (e.pointerType === "touch") {
|
||||
this.dispatchEvent(e, "touchend");
|
||||
} else if (e.pointerType === "mouse" || e.pointerType === "pen") {
|
||||
const isRightButton = e.button === 2;
|
||||
this.dispatchEvent(e, isRightButton ? "rightup" : "mouseup");
|
||||
}
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
const pressTarget = this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
|
||||
let clickTarget = pressTarget;
|
||||
if (pressTarget && !e.composedPath().includes(pressTarget)) {
|
||||
let currentTarget = pressTarget;
|
||||
while (currentTarget && !e.composedPath().includes(currentTarget)) {
|
||||
e.currentTarget = currentTarget;
|
||||
this.notifyTarget(e, "pointerupoutside");
|
||||
if (e.pointerType === "touch") {
|
||||
this.notifyTarget(e, "touchendoutside");
|
||||
} else if (e.pointerType === "mouse" || e.pointerType === "pen") {
|
||||
const isRightButton = e.button === 2;
|
||||
this.notifyTarget(e, isRightButton ? "rightupoutside" : "mouseupoutside");
|
||||
}
|
||||
currentTarget = currentTarget.parent;
|
||||
}
|
||||
delete trackingData.pressTargetsByButton[from.button];
|
||||
clickTarget = currentTarget;
|
||||
}
|
||||
if (clickTarget) {
|
||||
const clickEvent = this.clonePointerEvent(e, "click");
|
||||
clickEvent.target = clickTarget;
|
||||
clickEvent.path = null;
|
||||
if (!trackingData.clicksByButton[from.button]) {
|
||||
trackingData.clicksByButton[from.button] = {
|
||||
clickCount: 0,
|
||||
target: clickEvent.target,
|
||||
timeStamp: now
|
||||
};
|
||||
}
|
||||
const clickHistory = trackingData.clicksByButton[from.button];
|
||||
if (clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < 200) {
|
||||
++clickHistory.clickCount;
|
||||
} else {
|
||||
clickHistory.clickCount = 1;
|
||||
}
|
||||
clickHistory.target = clickEvent.target;
|
||||
clickHistory.timeStamp = now;
|
||||
clickEvent.detail = clickHistory.clickCount;
|
||||
if (clickEvent.pointerType === "mouse") {
|
||||
const isRightButton = clickEvent.button === 2;
|
||||
this.dispatchEvent(clickEvent, isRightButton ? "rightclick" : "click");
|
||||
} else if (clickEvent.pointerType === "touch") {
|
||||
this.dispatchEvent(clickEvent, "tap");
|
||||
}
|
||||
this.dispatchEvent(clickEvent, "pointertap");
|
||||
this.freeEvent(clickEvent);
|
||||
}
|
||||
this.freeEvent(e);
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* `{@link 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`.
|
||||
* @param from - The upstream `pointerupoutside` event.
|
||||
*/
|
||||
mapPointerUpOutside(from) {
|
||||
if (!(from instanceof FederatedPointerEvent.FederatedPointerEvent)) {
|
||||
warn.warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
const pressTarget = this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
|
||||
const e = this.createPointerEvent(from);
|
||||
if (pressTarget) {
|
||||
let currentTarget = pressTarget;
|
||||
while (currentTarget) {
|
||||
e.currentTarget = currentTarget;
|
||||
this.notifyTarget(e, "pointerupoutside");
|
||||
if (e.pointerType === "touch") {
|
||||
this.notifyTarget(e, "touchendoutside");
|
||||
} else if (e.pointerType === "mouse" || e.pointerType === "pen") {
|
||||
this.notifyTarget(e, e.button === 2 ? "rightupoutside" : "mouseupoutside");
|
||||
}
|
||||
currentTarget = currentTarget.parent;
|
||||
}
|
||||
delete trackingData.pressTargetsByButton[from.button];
|
||||
}
|
||||
this.freeEvent(e);
|
||||
}
|
||||
/**
|
||||
* Maps the upstream `wheel` event to a downstream `wheel` event.
|
||||
* @param from - The upstream `wheel` event.
|
||||
*/
|
||||
mapWheel(from) {
|
||||
if (!(from instanceof FederatedWheelEvent.FederatedWheelEvent)) {
|
||||
warn.warn("EventBoundary cannot map a non-wheel event as a wheel event");
|
||||
return;
|
||||
}
|
||||
const wheelEvent = this.createWheelEvent(from);
|
||||
this.dispatchEvent(wheelEvent);
|
||||
this.freeEvent(wheelEvent);
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param propagationPath - The propagation path was valid in the past.
|
||||
* @returns - The most specific event-target still mounted at the same location in the scene graph.
|
||||
*/
|
||||
findMountedTarget(propagationPath) {
|
||||
if (!propagationPath) {
|
||||
return null;
|
||||
}
|
||||
let currentTarget = propagationPath[0];
|
||||
for (let i = 1; i < propagationPath.length; i++) {
|
||||
if (propagationPath[i].parent === currentTarget) {
|
||||
currentTarget = propagationPath[i];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return currentTarget;
|
||||
}
|
||||
/**
|
||||
* Creates an event whose {@code originalEvent} is {@code from}, with an optional `type` and `target` override.
|
||||
*
|
||||
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
||||
* @param from - The {@code originalEvent} for the returned event.
|
||||
* @param [type=from.type] - The type of the returned event.
|
||||
* @param target - The target of the returned event.
|
||||
*/
|
||||
createPointerEvent(from, type, target) {
|
||||
const event = this.allocateEvent(FederatedPointerEvent.FederatedPointerEvent);
|
||||
this.copyPointerData(from, event);
|
||||
this.copyMouseData(from, event);
|
||||
this.copyData(from, event);
|
||||
event.nativeEvent = from.nativeEvent;
|
||||
event.originalEvent = from;
|
||||
event.target = target ?? this.hitTest(event.global.x, event.global.y) ?? this._hitElements[0];
|
||||
if (typeof type === "string") {
|
||||
event.type = type;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* Creates a wheel event whose {@code originalEvent} is {@code from}.
|
||||
*
|
||||
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
||||
* @param from - The upstream wheel event.
|
||||
*/
|
||||
createWheelEvent(from) {
|
||||
const event = this.allocateEvent(FederatedWheelEvent.FederatedWheelEvent);
|
||||
this.copyWheelData(from, event);
|
||||
this.copyMouseData(from, event);
|
||||
this.copyData(from, event);
|
||||
event.nativeEvent = from.nativeEvent;
|
||||
event.originalEvent = from;
|
||||
event.target = this.hitTest(event.global.x, event.global.y);
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* Clones the event {@code from}, with an optional {@code type} override.
|
||||
*
|
||||
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
||||
* @param from - The event to clone.
|
||||
* @param [type=from.type] - The type of the returned event.
|
||||
*/
|
||||
clonePointerEvent(from, type) {
|
||||
const event = this.allocateEvent(FederatedPointerEvent.FederatedPointerEvent);
|
||||
event.nativeEvent = from.nativeEvent;
|
||||
event.originalEvent = from.originalEvent;
|
||||
this.copyPointerData(from, event);
|
||||
this.copyMouseData(from, event);
|
||||
this.copyData(from, event);
|
||||
event.target = from.target;
|
||||
event.path = from.composedPath().slice();
|
||||
event.type = type ?? event.type;
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* Copies wheel {@link FederatedWheelEvent} data from {@code from} into {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + deltaMode
|
||||
* + deltaX
|
||||
* + deltaY
|
||||
* + deltaZ
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
copyWheelData(from, to) {
|
||||
to.deltaMode = from.deltaMode;
|
||||
to.deltaX = from.deltaX;
|
||||
to.deltaY = from.deltaY;
|
||||
to.deltaZ = from.deltaZ;
|
||||
}
|
||||
/**
|
||||
* Copies pointer {@link FederatedPointerEvent} data from {@code from} into {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + pointerId
|
||||
* + width
|
||||
* + height
|
||||
* + isPrimary
|
||||
* + pointerType
|
||||
* + pressure
|
||||
* + tangentialPressure
|
||||
* + tiltX
|
||||
* + tiltY
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
copyPointerData(from, to) {
|
||||
if (!(from instanceof FederatedPointerEvent.FederatedPointerEvent && to instanceof FederatedPointerEvent.FederatedPointerEvent))
|
||||
return;
|
||||
to.pointerId = from.pointerId;
|
||||
to.width = from.width;
|
||||
to.height = from.height;
|
||||
to.isPrimary = from.isPrimary;
|
||||
to.pointerType = from.pointerType;
|
||||
to.pressure = from.pressure;
|
||||
to.tangentialPressure = from.tangentialPressure;
|
||||
to.tiltX = from.tiltX;
|
||||
to.tiltY = from.tiltY;
|
||||
to.twist = from.twist;
|
||||
}
|
||||
/**
|
||||
* Copies mouse {@link FederatedMouseEvent} data from {@code from} to {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + altKey
|
||||
* + button
|
||||
* + buttons
|
||||
* + clientX
|
||||
* + clientY
|
||||
* + metaKey
|
||||
* + movementX
|
||||
* + movementY
|
||||
* + pageX
|
||||
* + pageY
|
||||
* + x
|
||||
* + y
|
||||
* + screen
|
||||
* + shiftKey
|
||||
* + global
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
copyMouseData(from, to) {
|
||||
if (!(from instanceof FederatedMouseEvent.FederatedMouseEvent && to instanceof FederatedMouseEvent.FederatedMouseEvent))
|
||||
return;
|
||||
to.altKey = from.altKey;
|
||||
to.button = from.button;
|
||||
to.buttons = from.buttons;
|
||||
to.client.copyFrom(from.client);
|
||||
to.ctrlKey = from.ctrlKey;
|
||||
to.metaKey = from.metaKey;
|
||||
to.movement.copyFrom(from.movement);
|
||||
to.screen.copyFrom(from.screen);
|
||||
to.shiftKey = from.shiftKey;
|
||||
to.global.copyFrom(from.global);
|
||||
}
|
||||
/**
|
||||
* Copies base {@link FederatedEvent} data from {@code from} into {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + isTrusted
|
||||
* + srcElement
|
||||
* + timeStamp
|
||||
* + type
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
copyData(from, to) {
|
||||
to.isTrusted = from.isTrusted;
|
||||
to.srcElement = from.srcElement;
|
||||
to.timeStamp = performance.now();
|
||||
to.type = from.type;
|
||||
to.detail = from.detail;
|
||||
to.view = from.view;
|
||||
to.which = from.which;
|
||||
to.layer.copyFrom(from.layer);
|
||||
to.page.copyFrom(from.page);
|
||||
}
|
||||
/**
|
||||
* @param id - The pointer ID.
|
||||
* @returns The tracking data stored for the given pointer. If no data exists, a blank
|
||||
* state will be created.
|
||||
*/
|
||||
trackingData(id) {
|
||||
if (!this.mappingState.trackingData[id]) {
|
||||
this.mappingState.trackingData[id] = {
|
||||
pressTargetsByButton: {},
|
||||
clicksByButton: {},
|
||||
overTarget: null
|
||||
};
|
||||
}
|
||||
return this.mappingState.trackingData[id];
|
||||
}
|
||||
/**
|
||||
* Allocate a specific type of event from {@link EventBoundary#eventPool this.eventPool}.
|
||||
*
|
||||
* This allocation is constructor-agnostic, as long as it only takes one argument - this event
|
||||
* boundary.
|
||||
* @param constructor - The event's constructor.
|
||||
*/
|
||||
allocateEvent(constructor) {
|
||||
if (!this.eventPool.has(constructor)) {
|
||||
this.eventPool.set(constructor, []);
|
||||
}
|
||||
const event = this.eventPool.get(constructor).pop() || new constructor(this);
|
||||
event.eventPhase = event.NONE;
|
||||
event.currentTarget = null;
|
||||
event.path = null;
|
||||
event.target = null;
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* 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 {@link EventBoundary#allocateEvent 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.
|
||||
* @param event - The event to be freed.
|
||||
* @throws Error if the event is managed by another event boundary.
|
||||
*/
|
||||
freeEvent(event) {
|
||||
if (event.manager !== this)
|
||||
throw new Error("It is illegal to free an event not managed by this EventBoundary!");
|
||||
const constructor = event.constructor;
|
||||
if (!this.eventPool.has(constructor)) {
|
||||
this.eventPool.set(constructor, []);
|
||||
}
|
||||
this.eventPool.get(constructor).push(event);
|
||||
}
|
||||
/**
|
||||
* Similar to {@link EventEmitter.emit}, except it stops if the `propagationImmediatelyStopped` flag
|
||||
* is set on the event.
|
||||
* @param e - The event to call each listener with.
|
||||
* @param type - The event key.
|
||||
*/
|
||||
_notifyListeners(e, type) {
|
||||
const listeners = e.currentTarget._events[type];
|
||||
if (!listeners)
|
||||
return;
|
||||
if ("fn" in listeners) {
|
||||
if (listeners.once)
|
||||
e.currentTarget.removeListener(type, listeners.fn, void 0, true);
|
||||
listeners.fn.call(listeners.context, e);
|
||||
} else {
|
||||
for (let i = 0, j = listeners.length; i < j && !e.propagationImmediatelyStopped; i++) {
|
||||
if (listeners[i].once)
|
||||
e.currentTarget.removeListener(type, listeners[i].fn, void 0, true);
|
||||
listeners[i].fn.call(listeners[i].context, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.EventBoundary = EventBoundary;
|
||||
//# sourceMappingURL=EventBoundary.js.map
|
1
node_modules/pixi.js/lib/events/EventBoundary.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/EventBoundary.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
953
node_modules/pixi.js/lib/events/EventBoundary.mjs
generated
vendored
Normal file
953
node_modules/pixi.js/lib/events/EventBoundary.mjs
generated
vendored
Normal file
@@ -0,0 +1,953 @@
|
||||
import EventEmitter from 'eventemitter3';
|
||||
import { Point } from '../maths/point/Point.mjs';
|
||||
import { warn } from '../utils/logging/warn.mjs';
|
||||
import { EventsTicker } from './EventTicker.mjs';
|
||||
import { FederatedMouseEvent } from './FederatedMouseEvent.mjs';
|
||||
import { FederatedPointerEvent } from './FederatedPointerEvent.mjs';
|
||||
import { FederatedWheelEvent } from './FederatedWheelEvent.mjs';
|
||||
|
||||
"use strict";
|
||||
const PROPAGATION_LIMIT = 2048;
|
||||
const tempHitLocation = new Point();
|
||||
const tempLocalMapping = new Point();
|
||||
class EventBoundary {
|
||||
/**
|
||||
* @param rootTarget - The holder of the event boundary.
|
||||
*/
|
||||
constructor(rootTarget) {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
this.dispatch = new EventEmitter();
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
this.moveOnAll = false;
|
||||
/** Enables the global move events. `globalpointermove`, `globaltouchmove`, and `globalmousemove` */
|
||||
this.enableGlobalMoveEvents = true;
|
||||
/**
|
||||
* State object for mapping methods.
|
||||
* @see EventBoundary#trackingData
|
||||
*/
|
||||
this.mappingState = {
|
||||
trackingData: {}
|
||||
};
|
||||
/**
|
||||
* The event pool maps event constructors to an free pool of instances of those specific events.
|
||||
* @see EventBoundary#allocateEvent
|
||||
* @see EventBoundary#freeEvent
|
||||
*/
|
||||
this.eventPool = /* @__PURE__ */ new Map();
|
||||
/** Every interactive element gathered from the scene. Only used in `pointermove` */
|
||||
this._allInteractiveElements = [];
|
||||
/** Every element that passed the hit test. Only used in `pointermove` */
|
||||
this._hitElements = [];
|
||||
/** Whether or not to collect all the interactive elements from the scene. Enabled in `pointermove` */
|
||||
this._isPointerMoveEvent = false;
|
||||
this.rootTarget = rootTarget;
|
||||
this.hitPruneFn = this.hitPruneFn.bind(this);
|
||||
this.hitTestFn = this.hitTestFn.bind(this);
|
||||
this.mapPointerDown = this.mapPointerDown.bind(this);
|
||||
this.mapPointerMove = this.mapPointerMove.bind(this);
|
||||
this.mapPointerOut = this.mapPointerOut.bind(this);
|
||||
this.mapPointerOver = this.mapPointerOver.bind(this);
|
||||
this.mapPointerUp = this.mapPointerUp.bind(this);
|
||||
this.mapPointerUpOutside = this.mapPointerUpOutside.bind(this);
|
||||
this.mapWheel = this.mapWheel.bind(this);
|
||||
this.mappingTable = {};
|
||||
this.addEventMapping("pointerdown", this.mapPointerDown);
|
||||
this.addEventMapping("pointermove", this.mapPointerMove);
|
||||
this.addEventMapping("pointerout", this.mapPointerOut);
|
||||
this.addEventMapping("pointerleave", this.mapPointerOut);
|
||||
this.addEventMapping("pointerover", this.mapPointerOver);
|
||||
this.addEventMapping("pointerup", this.mapPointerUp);
|
||||
this.addEventMapping("pointerupoutside", this.mapPointerUpOutside);
|
||||
this.addEventMapping("wheel", this.mapWheel);
|
||||
}
|
||||
/**
|
||||
* 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 {@link EventSystem}) and dispatch new downstream events
|
||||
* generally trickling down and bubbling up to {@link EventBoundary.rootTarget this.rootTarget}.
|
||||
*
|
||||
* To modify the semantics of existing events, the built-in mapping methods of EventBoundary should be overridden
|
||||
* instead.
|
||||
* @param type - The type of upstream event to map.
|
||||
* @param fn - The mapping method. The context of this function must be bound manually, if desired.
|
||||
*/
|
||||
addEventMapping(type, fn) {
|
||||
if (!this.mappingTable[type]) {
|
||||
this.mappingTable[type] = [];
|
||||
}
|
||||
this.mappingTable[type].push({
|
||||
fn,
|
||||
priority: 0
|
||||
});
|
||||
this.mappingTable[type].sort((a, b) => a.priority - b.priority);
|
||||
}
|
||||
/**
|
||||
* Dispatches the given event
|
||||
* @param e - The event to dispatch.
|
||||
* @param type - The type of event to dispatch. Defaults to `e.type`.
|
||||
*/
|
||||
dispatchEvent(e, type) {
|
||||
e.propagationStopped = false;
|
||||
e.propagationImmediatelyStopped = false;
|
||||
this.propagate(e, type);
|
||||
this.dispatch.emit(type || e.type, e);
|
||||
}
|
||||
/**
|
||||
* Maps the given upstream event through the event boundary and propagates it downstream.
|
||||
* @param e - The event to map.
|
||||
*/
|
||||
mapEvent(e) {
|
||||
if (!this.rootTarget) {
|
||||
return;
|
||||
}
|
||||
const mappers = this.mappingTable[e.type];
|
||||
if (mappers) {
|
||||
for (let i = 0, j = mappers.length; i < j; i++) {
|
||||
mappers[i].fn(e);
|
||||
}
|
||||
} else {
|
||||
warn(`[EventBoundary]: Event mapping not defined for ${e.type}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param x - The x coordinate of the event.
|
||||
* @param y - The y coordinate of the event.
|
||||
*/
|
||||
hitTest(x, y) {
|
||||
EventsTicker.pauseUpdate = true;
|
||||
const useMove = this._isPointerMoveEvent && this.enableGlobalMoveEvents;
|
||||
const fn = useMove ? "hitTestMoveRecursive" : "hitTestRecursive";
|
||||
const invertedPath = this[fn](
|
||||
this.rootTarget,
|
||||
this.rootTarget.eventMode,
|
||||
tempHitLocation.set(x, y),
|
||||
this.hitTestFn,
|
||||
this.hitPruneFn
|
||||
);
|
||||
return invertedPath && invertedPath[0];
|
||||
}
|
||||
/**
|
||||
* Propagate the passed event from from {@link EventBoundary.rootTarget this.rootTarget} to its
|
||||
* target {@code e.target}.
|
||||
* @param e - The event to propagate.
|
||||
* @param type - The type of event to propagate. Defaults to `e.type`.
|
||||
*/
|
||||
propagate(e, type) {
|
||||
if (!e.target) {
|
||||
return;
|
||||
}
|
||||
const composedPath = e.composedPath();
|
||||
e.eventPhase = e.CAPTURING_PHASE;
|
||||
for (let i = 0, j = composedPath.length - 1; i < j; i++) {
|
||||
e.currentTarget = composedPath[i];
|
||||
this.notifyTarget(e, type);
|
||||
if (e.propagationStopped || e.propagationImmediatelyStopped)
|
||||
return;
|
||||
}
|
||||
e.eventPhase = e.AT_TARGET;
|
||||
e.currentTarget = e.target;
|
||||
this.notifyTarget(e, type);
|
||||
if (e.propagationStopped || e.propagationImmediatelyStopped)
|
||||
return;
|
||||
e.eventPhase = e.BUBBLING_PHASE;
|
||||
for (let i = composedPath.length - 2; i >= 0; i--) {
|
||||
e.currentTarget = composedPath[i];
|
||||
this.notifyTarget(e, type);
|
||||
if (e.propagationStopped || e.propagationImmediatelyStopped)
|
||||
return;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Emits the event {@code e} to all interactive containers. The event is propagated in the bubbling phase always.
|
||||
*
|
||||
* This is used in the `globalpointermove` event.
|
||||
* @param e - The emitted event.
|
||||
* @param type - The listeners to notify.
|
||||
* @param targets - The targets to notify.
|
||||
*/
|
||||
all(e, type, targets = this._allInteractiveElements) {
|
||||
if (targets.length === 0)
|
||||
return;
|
||||
e.eventPhase = e.BUBBLING_PHASE;
|
||||
const events = Array.isArray(type) ? type : [type];
|
||||
for (let i = targets.length - 1; i >= 0; i--) {
|
||||
events.forEach((event) => {
|
||||
e.currentTarget = targets[i];
|
||||
this.notifyTarget(e, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Finds the propagation path from {@link EventBoundary.rootTarget rootTarget} to the passed
|
||||
* {@code target}. The last element in the path is {@code target}.
|
||||
* @param target - The target to find the propagation path to.
|
||||
*/
|
||||
propagationPath(target) {
|
||||
const propagationPath = [target];
|
||||
for (let i = 0; i < PROPAGATION_LIMIT && (target !== this.rootTarget && target.parent); i++) {
|
||||
if (!target.parent) {
|
||||
throw new Error("Cannot find propagation path to disconnected target");
|
||||
}
|
||||
propagationPath.push(target.parent);
|
||||
target = target.parent;
|
||||
}
|
||||
propagationPath.reverse();
|
||||
return propagationPath;
|
||||
}
|
||||
hitTestMoveRecursive(currentTarget, eventMode, location, testFn, pruneFn, ignore = false) {
|
||||
let shouldReturn = false;
|
||||
if (this._interactivePrune(currentTarget))
|
||||
return null;
|
||||
if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") {
|
||||
EventsTicker.pauseUpdate = false;
|
||||
}
|
||||
if (currentTarget.interactiveChildren && currentTarget.children) {
|
||||
const children = currentTarget.children;
|
||||
for (let i = children.length - 1; i >= 0; i--) {
|
||||
const child = children[i];
|
||||
const nestedHit = this.hitTestMoveRecursive(
|
||||
child,
|
||||
this._isInteractive(eventMode) ? eventMode : child.eventMode,
|
||||
location,
|
||||
testFn,
|
||||
pruneFn,
|
||||
ignore || pruneFn(currentTarget, location)
|
||||
);
|
||||
if (nestedHit) {
|
||||
if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
|
||||
continue;
|
||||
}
|
||||
const isInteractive = currentTarget.isInteractive();
|
||||
if (nestedHit.length > 0 || isInteractive) {
|
||||
if (isInteractive)
|
||||
this._allInteractiveElements.push(currentTarget);
|
||||
nestedHit.push(currentTarget);
|
||||
}
|
||||
if (this._hitElements.length === 0)
|
||||
this._hitElements = nestedHit;
|
||||
shouldReturn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
const isInteractiveMode = this._isInteractive(eventMode);
|
||||
const isInteractiveTarget = currentTarget.isInteractive();
|
||||
if (isInteractiveTarget && isInteractiveTarget)
|
||||
this._allInteractiveElements.push(currentTarget);
|
||||
if (ignore || this._hitElements.length > 0)
|
||||
return null;
|
||||
if (shouldReturn)
|
||||
return this._hitElements;
|
||||
if (isInteractiveMode && (!pruneFn(currentTarget, location) && testFn(currentTarget, location))) {
|
||||
return isInteractiveTarget ? [currentTarget] : [];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Recursive implementation for {@link EventBoundary.hitTest hitTest}.
|
||||
* @param currentTarget - The Container that is to be hit tested.
|
||||
* @param eventMode - The event mode for the `currentTarget` or one of its parents.
|
||||
* @param location - The location that is being tested for overlap.
|
||||
* @param testFn - Callback that determines whether the target passes hit testing. This callback
|
||||
* can assume that `pruneFn` failed to prune the container.
|
||||
* @param pruneFn - 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 An array holding the hit testing target and all its ancestors in order. The first element
|
||||
* is the target itself and the last is {@link EventBoundary.rootTarget rootTarget}. This is the opposite
|
||||
* order w.r.t. the propagation path. If no hit testing target is found, null is returned.
|
||||
*/
|
||||
hitTestRecursive(currentTarget, eventMode, location, testFn, pruneFn) {
|
||||
if (this._interactivePrune(currentTarget) || pruneFn(currentTarget, location)) {
|
||||
return null;
|
||||
}
|
||||
if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") {
|
||||
EventsTicker.pauseUpdate = false;
|
||||
}
|
||||
if (currentTarget.interactiveChildren && currentTarget.children) {
|
||||
const children = currentTarget.children;
|
||||
const relativeLocation = location;
|
||||
for (let i = children.length - 1; i >= 0; i--) {
|
||||
const child = children[i];
|
||||
const nestedHit = this.hitTestRecursive(
|
||||
child,
|
||||
this._isInteractive(eventMode) ? eventMode : child.eventMode,
|
||||
relativeLocation,
|
||||
testFn,
|
||||
pruneFn
|
||||
);
|
||||
if (nestedHit) {
|
||||
if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
|
||||
continue;
|
||||
}
|
||||
const isInteractive = currentTarget.isInteractive();
|
||||
if (nestedHit.length > 0 || isInteractive)
|
||||
nestedHit.push(currentTarget);
|
||||
return nestedHit;
|
||||
}
|
||||
}
|
||||
}
|
||||
const isInteractiveMode = this._isInteractive(eventMode);
|
||||
const isInteractiveTarget = currentTarget.isInteractive();
|
||||
if (isInteractiveMode && testFn(currentTarget, location)) {
|
||||
return isInteractiveTarget ? [currentTarget] : [];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
_isInteractive(int) {
|
||||
return int === "static" || int === "dynamic";
|
||||
}
|
||||
_interactivePrune(container) {
|
||||
if (!container || !container.visible || !container.renderable || !container.includeInBuild || !container.measurable) {
|
||||
return true;
|
||||
}
|
||||
if (container.eventMode === "none") {
|
||||
return true;
|
||||
}
|
||||
if (container.eventMode === "passive" && !container.interactiveChildren) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Checks whether the container or any of its children cannot pass the hit test at all.
|
||||
*
|
||||
* {@link EventBoundary}'s implementation uses the {@link Container.hitArea hitArea}
|
||||
* and {@link Container._maskEffect} for pruning.
|
||||
* @param container - The container to prune.
|
||||
* @param location - The location to test for overlap.
|
||||
*/
|
||||
hitPruneFn(container, location) {
|
||||
if (container.hitArea) {
|
||||
container.worldTransform.applyInverse(location, tempLocalMapping);
|
||||
if (!container.hitArea.contains(tempLocalMapping.x, tempLocalMapping.y)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (container.effects && container.effects.length) {
|
||||
for (let i = 0; i < container.effects.length; i++) {
|
||||
const effect = container.effects[i];
|
||||
if (effect.containsPoint) {
|
||||
const effectContainsPoint = effect.containsPoint(location, this.hitTestFn);
|
||||
if (!effectContainsPoint) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Checks whether the container passes hit testing for the given location.
|
||||
* @param container - The container to test.
|
||||
* @param location - The location to test for overlap.
|
||||
* @returns - Whether `container` passes hit testing for `location`.
|
||||
*/
|
||||
hitTestFn(container, location) {
|
||||
if (container.hitArea) {
|
||||
return true;
|
||||
}
|
||||
if (container?.containsPoint) {
|
||||
container.worldTransform.applyInverse(location, tempLocalMapping);
|
||||
return container.containsPoint(tempLocalMapping);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param e - The event passed to the target.
|
||||
* @param type - The type of event to notify. Defaults to `e.type`.
|
||||
*/
|
||||
notifyTarget(e, type) {
|
||||
if (!e.currentTarget.isInteractive()) {
|
||||
return;
|
||||
}
|
||||
type = type ?? e.type;
|
||||
const handlerKey = `on${type}`;
|
||||
e.currentTarget[handlerKey]?.(e);
|
||||
const key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? `${type}capture` : type;
|
||||
this._notifyListeners(e, key);
|
||||
if (e.eventPhase === e.AT_TARGET) {
|
||||
this._notifyListeners(e, type);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Maps the upstream `pointerdown` events to a downstream `pointerdown` event.
|
||||
*
|
||||
* `touchstart`, `rightdown`, `mousedown` events are also dispatched for specific pointer types.
|
||||
* @param from - The upstream `pointerdown` event.
|
||||
*/
|
||||
mapPointerDown(from) {
|
||||
if (!(from instanceof FederatedPointerEvent)) {
|
||||
warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
const e = this.createPointerEvent(from);
|
||||
this.dispatchEvent(e, "pointerdown");
|
||||
if (e.pointerType === "touch") {
|
||||
this.dispatchEvent(e, "touchstart");
|
||||
} else if (e.pointerType === "mouse" || e.pointerType === "pen") {
|
||||
const isRightButton = e.button === 2;
|
||||
this.dispatchEvent(e, isRightButton ? "rightdown" : "mousedown");
|
||||
}
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
trackingData.pressTargetsByButton[from.button] = e.composedPath();
|
||||
this.freeEvent(e);
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param from - The upstream `pointermove` event.
|
||||
*/
|
||||
mapPointerMove(from) {
|
||||
if (!(from instanceof FederatedPointerEvent)) {
|
||||
warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
this._allInteractiveElements.length = 0;
|
||||
this._hitElements.length = 0;
|
||||
this._isPointerMoveEvent = true;
|
||||
const e = this.createPointerEvent(from);
|
||||
this._isPointerMoveEvent = false;
|
||||
const isMouse = e.pointerType === "mouse" || e.pointerType === "pen";
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
const outTarget = this.findMountedTarget(trackingData.overTargets);
|
||||
if (trackingData.overTargets?.length > 0 && outTarget !== e.target) {
|
||||
const outType = from.type === "mousemove" ? "mouseout" : "pointerout";
|
||||
const outEvent = this.createPointerEvent(from, outType, outTarget);
|
||||
this.dispatchEvent(outEvent, "pointerout");
|
||||
if (isMouse)
|
||||
this.dispatchEvent(outEvent, "mouseout");
|
||||
if (!e.composedPath().includes(outTarget)) {
|
||||
const leaveEvent = this.createPointerEvent(from, "pointerleave", outTarget);
|
||||
leaveEvent.eventPhase = leaveEvent.AT_TARGET;
|
||||
while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
|
||||
leaveEvent.currentTarget = leaveEvent.target;
|
||||
this.notifyTarget(leaveEvent);
|
||||
if (isMouse)
|
||||
this.notifyTarget(leaveEvent, "mouseleave");
|
||||
leaveEvent.target = leaveEvent.target.parent;
|
||||
}
|
||||
this.freeEvent(leaveEvent);
|
||||
}
|
||||
this.freeEvent(outEvent);
|
||||
}
|
||||
if (outTarget !== e.target) {
|
||||
const overType = from.type === "mousemove" ? "mouseover" : "pointerover";
|
||||
const overEvent = this.clonePointerEvent(e, overType);
|
||||
this.dispatchEvent(overEvent, "pointerover");
|
||||
if (isMouse)
|
||||
this.dispatchEvent(overEvent, "mouseover");
|
||||
let overTargetAncestor = outTarget?.parent;
|
||||
while (overTargetAncestor && overTargetAncestor !== this.rootTarget.parent) {
|
||||
if (overTargetAncestor === e.target)
|
||||
break;
|
||||
overTargetAncestor = overTargetAncestor.parent;
|
||||
}
|
||||
const didPointerEnter = !overTargetAncestor || overTargetAncestor === this.rootTarget.parent;
|
||||
if (didPointerEnter) {
|
||||
const enterEvent = this.clonePointerEvent(e, "pointerenter");
|
||||
enterEvent.eventPhase = enterEvent.AT_TARGET;
|
||||
while (enterEvent.target && enterEvent.target !== outTarget && enterEvent.target !== this.rootTarget.parent) {
|
||||
enterEvent.currentTarget = enterEvent.target;
|
||||
this.notifyTarget(enterEvent);
|
||||
if (isMouse)
|
||||
this.notifyTarget(enterEvent, "mouseenter");
|
||||
enterEvent.target = enterEvent.target.parent;
|
||||
}
|
||||
this.freeEvent(enterEvent);
|
||||
}
|
||||
this.freeEvent(overEvent);
|
||||
}
|
||||
const allMethods = [];
|
||||
const allowGlobalPointerEvents = this.enableGlobalMoveEvents ?? true;
|
||||
this.moveOnAll ? allMethods.push("pointermove") : this.dispatchEvent(e, "pointermove");
|
||||
allowGlobalPointerEvents && allMethods.push("globalpointermove");
|
||||
if (e.pointerType === "touch") {
|
||||
this.moveOnAll ? allMethods.splice(1, 0, "touchmove") : this.dispatchEvent(e, "touchmove");
|
||||
allowGlobalPointerEvents && allMethods.push("globaltouchmove");
|
||||
}
|
||||
if (isMouse) {
|
||||
this.moveOnAll ? allMethods.splice(1, 0, "mousemove") : this.dispatchEvent(e, "mousemove");
|
||||
allowGlobalPointerEvents && allMethods.push("globalmousemove");
|
||||
this.cursor = e.target?.cursor;
|
||||
}
|
||||
if (allMethods.length > 0) {
|
||||
this.all(e, allMethods);
|
||||
}
|
||||
this._allInteractiveElements.length = 0;
|
||||
this._hitElements.length = 0;
|
||||
trackingData.overTargets = e.composedPath();
|
||||
this.freeEvent(e);
|
||||
}
|
||||
/**
|
||||
* Maps the upstream `pointerover` to downstream `pointerover` and `pointerenter` events, in that order.
|
||||
*
|
||||
* The tracking data for the specific pointer gets a new `overTarget`.
|
||||
* @param from - The upstream `pointerover` event.
|
||||
*/
|
||||
mapPointerOver(from) {
|
||||
if (!(from instanceof FederatedPointerEvent)) {
|
||||
warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
const e = this.createPointerEvent(from);
|
||||
const isMouse = e.pointerType === "mouse" || e.pointerType === "pen";
|
||||
this.dispatchEvent(e, "pointerover");
|
||||
if (isMouse)
|
||||
this.dispatchEvent(e, "mouseover");
|
||||
if (e.pointerType === "mouse")
|
||||
this.cursor = e.target?.cursor;
|
||||
const enterEvent = this.clonePointerEvent(e, "pointerenter");
|
||||
enterEvent.eventPhase = enterEvent.AT_TARGET;
|
||||
while (enterEvent.target && enterEvent.target !== this.rootTarget.parent) {
|
||||
enterEvent.currentTarget = enterEvent.target;
|
||||
this.notifyTarget(enterEvent);
|
||||
if (isMouse)
|
||||
this.notifyTarget(enterEvent, "mouseenter");
|
||||
enterEvent.target = enterEvent.target.parent;
|
||||
}
|
||||
trackingData.overTargets = e.composedPath();
|
||||
this.freeEvent(e);
|
||||
this.freeEvent(enterEvent);
|
||||
}
|
||||
/**
|
||||
* Maps the upstream `pointerout` to downstream `pointerout`, `pointerleave` events, in that order.
|
||||
*
|
||||
* The tracking data for the specific pointer is cleared of a `overTarget`.
|
||||
* @param from - The upstream `pointerout` event.
|
||||
*/
|
||||
mapPointerOut(from) {
|
||||
if (!(from instanceof FederatedPointerEvent)) {
|
||||
warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
if (trackingData.overTargets) {
|
||||
const isMouse = from.pointerType === "mouse" || from.pointerType === "pen";
|
||||
const outTarget = this.findMountedTarget(trackingData.overTargets);
|
||||
const outEvent = this.createPointerEvent(from, "pointerout", outTarget);
|
||||
this.dispatchEvent(outEvent);
|
||||
if (isMouse)
|
||||
this.dispatchEvent(outEvent, "mouseout");
|
||||
const leaveEvent = this.createPointerEvent(from, "pointerleave", outTarget);
|
||||
leaveEvent.eventPhase = leaveEvent.AT_TARGET;
|
||||
while (leaveEvent.target && leaveEvent.target !== this.rootTarget.parent) {
|
||||
leaveEvent.currentTarget = leaveEvent.target;
|
||||
this.notifyTarget(leaveEvent);
|
||||
if (isMouse)
|
||||
this.notifyTarget(leaveEvent, "mouseleave");
|
||||
leaveEvent.target = leaveEvent.target.parent;
|
||||
}
|
||||
trackingData.overTargets = null;
|
||||
this.freeEvent(outEvent);
|
||||
this.freeEvent(leaveEvent);
|
||||
}
|
||||
this.cursor = null;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param from - The upstream `pointerup` event.
|
||||
*/
|
||||
mapPointerUp(from) {
|
||||
if (!(from instanceof FederatedPointerEvent)) {
|
||||
warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
const now = performance.now();
|
||||
const e = this.createPointerEvent(from);
|
||||
this.dispatchEvent(e, "pointerup");
|
||||
if (e.pointerType === "touch") {
|
||||
this.dispatchEvent(e, "touchend");
|
||||
} else if (e.pointerType === "mouse" || e.pointerType === "pen") {
|
||||
const isRightButton = e.button === 2;
|
||||
this.dispatchEvent(e, isRightButton ? "rightup" : "mouseup");
|
||||
}
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
const pressTarget = this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
|
||||
let clickTarget = pressTarget;
|
||||
if (pressTarget && !e.composedPath().includes(pressTarget)) {
|
||||
let currentTarget = pressTarget;
|
||||
while (currentTarget && !e.composedPath().includes(currentTarget)) {
|
||||
e.currentTarget = currentTarget;
|
||||
this.notifyTarget(e, "pointerupoutside");
|
||||
if (e.pointerType === "touch") {
|
||||
this.notifyTarget(e, "touchendoutside");
|
||||
} else if (e.pointerType === "mouse" || e.pointerType === "pen") {
|
||||
const isRightButton = e.button === 2;
|
||||
this.notifyTarget(e, isRightButton ? "rightupoutside" : "mouseupoutside");
|
||||
}
|
||||
currentTarget = currentTarget.parent;
|
||||
}
|
||||
delete trackingData.pressTargetsByButton[from.button];
|
||||
clickTarget = currentTarget;
|
||||
}
|
||||
if (clickTarget) {
|
||||
const clickEvent = this.clonePointerEvent(e, "click");
|
||||
clickEvent.target = clickTarget;
|
||||
clickEvent.path = null;
|
||||
if (!trackingData.clicksByButton[from.button]) {
|
||||
trackingData.clicksByButton[from.button] = {
|
||||
clickCount: 0,
|
||||
target: clickEvent.target,
|
||||
timeStamp: now
|
||||
};
|
||||
}
|
||||
const clickHistory = trackingData.clicksByButton[from.button];
|
||||
if (clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < 200) {
|
||||
++clickHistory.clickCount;
|
||||
} else {
|
||||
clickHistory.clickCount = 1;
|
||||
}
|
||||
clickHistory.target = clickEvent.target;
|
||||
clickHistory.timeStamp = now;
|
||||
clickEvent.detail = clickHistory.clickCount;
|
||||
if (clickEvent.pointerType === "mouse") {
|
||||
const isRightButton = clickEvent.button === 2;
|
||||
this.dispatchEvent(clickEvent, isRightButton ? "rightclick" : "click");
|
||||
} else if (clickEvent.pointerType === "touch") {
|
||||
this.dispatchEvent(clickEvent, "tap");
|
||||
}
|
||||
this.dispatchEvent(clickEvent, "pointertap");
|
||||
this.freeEvent(clickEvent);
|
||||
}
|
||||
this.freeEvent(e);
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* `{@link 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`.
|
||||
* @param from - The upstream `pointerupoutside` event.
|
||||
*/
|
||||
mapPointerUpOutside(from) {
|
||||
if (!(from instanceof FederatedPointerEvent)) {
|
||||
warn("EventBoundary cannot map a non-pointer event as a pointer event");
|
||||
return;
|
||||
}
|
||||
const trackingData = this.trackingData(from.pointerId);
|
||||
const pressTarget = this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
|
||||
const e = this.createPointerEvent(from);
|
||||
if (pressTarget) {
|
||||
let currentTarget = pressTarget;
|
||||
while (currentTarget) {
|
||||
e.currentTarget = currentTarget;
|
||||
this.notifyTarget(e, "pointerupoutside");
|
||||
if (e.pointerType === "touch") {
|
||||
this.notifyTarget(e, "touchendoutside");
|
||||
} else if (e.pointerType === "mouse" || e.pointerType === "pen") {
|
||||
this.notifyTarget(e, e.button === 2 ? "rightupoutside" : "mouseupoutside");
|
||||
}
|
||||
currentTarget = currentTarget.parent;
|
||||
}
|
||||
delete trackingData.pressTargetsByButton[from.button];
|
||||
}
|
||||
this.freeEvent(e);
|
||||
}
|
||||
/**
|
||||
* Maps the upstream `wheel` event to a downstream `wheel` event.
|
||||
* @param from - The upstream `wheel` event.
|
||||
*/
|
||||
mapWheel(from) {
|
||||
if (!(from instanceof FederatedWheelEvent)) {
|
||||
warn("EventBoundary cannot map a non-wheel event as a wheel event");
|
||||
return;
|
||||
}
|
||||
const wheelEvent = this.createWheelEvent(from);
|
||||
this.dispatchEvent(wheelEvent);
|
||||
this.freeEvent(wheelEvent);
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param propagationPath - The propagation path was valid in the past.
|
||||
* @returns - The most specific event-target still mounted at the same location in the scene graph.
|
||||
*/
|
||||
findMountedTarget(propagationPath) {
|
||||
if (!propagationPath) {
|
||||
return null;
|
||||
}
|
||||
let currentTarget = propagationPath[0];
|
||||
for (let i = 1; i < propagationPath.length; i++) {
|
||||
if (propagationPath[i].parent === currentTarget) {
|
||||
currentTarget = propagationPath[i];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return currentTarget;
|
||||
}
|
||||
/**
|
||||
* Creates an event whose {@code originalEvent} is {@code from}, with an optional `type` and `target` override.
|
||||
*
|
||||
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
||||
* @param from - The {@code originalEvent} for the returned event.
|
||||
* @param [type=from.type] - The type of the returned event.
|
||||
* @param target - The target of the returned event.
|
||||
*/
|
||||
createPointerEvent(from, type, target) {
|
||||
const event = this.allocateEvent(FederatedPointerEvent);
|
||||
this.copyPointerData(from, event);
|
||||
this.copyMouseData(from, event);
|
||||
this.copyData(from, event);
|
||||
event.nativeEvent = from.nativeEvent;
|
||||
event.originalEvent = from;
|
||||
event.target = target ?? this.hitTest(event.global.x, event.global.y) ?? this._hitElements[0];
|
||||
if (typeof type === "string") {
|
||||
event.type = type;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* Creates a wheel event whose {@code originalEvent} is {@code from}.
|
||||
*
|
||||
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
||||
* @param from - The upstream wheel event.
|
||||
*/
|
||||
createWheelEvent(from) {
|
||||
const event = this.allocateEvent(FederatedWheelEvent);
|
||||
this.copyWheelData(from, event);
|
||||
this.copyMouseData(from, event);
|
||||
this.copyData(from, event);
|
||||
event.nativeEvent = from.nativeEvent;
|
||||
event.originalEvent = from;
|
||||
event.target = this.hitTest(event.global.x, event.global.y);
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* Clones the event {@code from}, with an optional {@code type} override.
|
||||
*
|
||||
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
||||
* @param from - The event to clone.
|
||||
* @param [type=from.type] - The type of the returned event.
|
||||
*/
|
||||
clonePointerEvent(from, type) {
|
||||
const event = this.allocateEvent(FederatedPointerEvent);
|
||||
event.nativeEvent = from.nativeEvent;
|
||||
event.originalEvent = from.originalEvent;
|
||||
this.copyPointerData(from, event);
|
||||
this.copyMouseData(from, event);
|
||||
this.copyData(from, event);
|
||||
event.target = from.target;
|
||||
event.path = from.composedPath().slice();
|
||||
event.type = type ?? event.type;
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* Copies wheel {@link FederatedWheelEvent} data from {@code from} into {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + deltaMode
|
||||
* + deltaX
|
||||
* + deltaY
|
||||
* + deltaZ
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
copyWheelData(from, to) {
|
||||
to.deltaMode = from.deltaMode;
|
||||
to.deltaX = from.deltaX;
|
||||
to.deltaY = from.deltaY;
|
||||
to.deltaZ = from.deltaZ;
|
||||
}
|
||||
/**
|
||||
* Copies pointer {@link FederatedPointerEvent} data from {@code from} into {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + pointerId
|
||||
* + width
|
||||
* + height
|
||||
* + isPrimary
|
||||
* + pointerType
|
||||
* + pressure
|
||||
* + tangentialPressure
|
||||
* + tiltX
|
||||
* + tiltY
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
copyPointerData(from, to) {
|
||||
if (!(from instanceof FederatedPointerEvent && to instanceof FederatedPointerEvent))
|
||||
return;
|
||||
to.pointerId = from.pointerId;
|
||||
to.width = from.width;
|
||||
to.height = from.height;
|
||||
to.isPrimary = from.isPrimary;
|
||||
to.pointerType = from.pointerType;
|
||||
to.pressure = from.pressure;
|
||||
to.tangentialPressure = from.tangentialPressure;
|
||||
to.tiltX = from.tiltX;
|
||||
to.tiltY = from.tiltY;
|
||||
to.twist = from.twist;
|
||||
}
|
||||
/**
|
||||
* Copies mouse {@link FederatedMouseEvent} data from {@code from} to {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + altKey
|
||||
* + button
|
||||
* + buttons
|
||||
* + clientX
|
||||
* + clientY
|
||||
* + metaKey
|
||||
* + movementX
|
||||
* + movementY
|
||||
* + pageX
|
||||
* + pageY
|
||||
* + x
|
||||
* + y
|
||||
* + screen
|
||||
* + shiftKey
|
||||
* + global
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
copyMouseData(from, to) {
|
||||
if (!(from instanceof FederatedMouseEvent && to instanceof FederatedMouseEvent))
|
||||
return;
|
||||
to.altKey = from.altKey;
|
||||
to.button = from.button;
|
||||
to.buttons = from.buttons;
|
||||
to.client.copyFrom(from.client);
|
||||
to.ctrlKey = from.ctrlKey;
|
||||
to.metaKey = from.metaKey;
|
||||
to.movement.copyFrom(from.movement);
|
||||
to.screen.copyFrom(from.screen);
|
||||
to.shiftKey = from.shiftKey;
|
||||
to.global.copyFrom(from.global);
|
||||
}
|
||||
/**
|
||||
* Copies base {@link FederatedEvent} data from {@code from} into {@code to}.
|
||||
*
|
||||
* The following properties are copied:
|
||||
* + isTrusted
|
||||
* + srcElement
|
||||
* + timeStamp
|
||||
* + type
|
||||
* @param from - The event to copy data from.
|
||||
* @param to - The event to copy data into.
|
||||
*/
|
||||
copyData(from, to) {
|
||||
to.isTrusted = from.isTrusted;
|
||||
to.srcElement = from.srcElement;
|
||||
to.timeStamp = performance.now();
|
||||
to.type = from.type;
|
||||
to.detail = from.detail;
|
||||
to.view = from.view;
|
||||
to.which = from.which;
|
||||
to.layer.copyFrom(from.layer);
|
||||
to.page.copyFrom(from.page);
|
||||
}
|
||||
/**
|
||||
* @param id - The pointer ID.
|
||||
* @returns The tracking data stored for the given pointer. If no data exists, a blank
|
||||
* state will be created.
|
||||
*/
|
||||
trackingData(id) {
|
||||
if (!this.mappingState.trackingData[id]) {
|
||||
this.mappingState.trackingData[id] = {
|
||||
pressTargetsByButton: {},
|
||||
clicksByButton: {},
|
||||
overTarget: null
|
||||
};
|
||||
}
|
||||
return this.mappingState.trackingData[id];
|
||||
}
|
||||
/**
|
||||
* Allocate a specific type of event from {@link EventBoundary#eventPool this.eventPool}.
|
||||
*
|
||||
* This allocation is constructor-agnostic, as long as it only takes one argument - this event
|
||||
* boundary.
|
||||
* @param constructor - The event's constructor.
|
||||
*/
|
||||
allocateEvent(constructor) {
|
||||
if (!this.eventPool.has(constructor)) {
|
||||
this.eventPool.set(constructor, []);
|
||||
}
|
||||
const event = this.eventPool.get(constructor).pop() || new constructor(this);
|
||||
event.eventPhase = event.NONE;
|
||||
event.currentTarget = null;
|
||||
event.path = null;
|
||||
event.target = null;
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* 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 {@link EventBoundary#allocateEvent 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.
|
||||
* @param event - The event to be freed.
|
||||
* @throws Error if the event is managed by another event boundary.
|
||||
*/
|
||||
freeEvent(event) {
|
||||
if (event.manager !== this)
|
||||
throw new Error("It is illegal to free an event not managed by this EventBoundary!");
|
||||
const constructor = event.constructor;
|
||||
if (!this.eventPool.has(constructor)) {
|
||||
this.eventPool.set(constructor, []);
|
||||
}
|
||||
this.eventPool.get(constructor).push(event);
|
||||
}
|
||||
/**
|
||||
* Similar to {@link EventEmitter.emit}, except it stops if the `propagationImmediatelyStopped` flag
|
||||
* is set on the event.
|
||||
* @param e - The event to call each listener with.
|
||||
* @param type - The event key.
|
||||
*/
|
||||
_notifyListeners(e, type) {
|
||||
const listeners = e.currentTarget._events[type];
|
||||
if (!listeners)
|
||||
return;
|
||||
if ("fn" in listeners) {
|
||||
if (listeners.once)
|
||||
e.currentTarget.removeListener(type, listeners.fn, void 0, true);
|
||||
listeners.fn.call(listeners.context, e);
|
||||
} else {
|
||||
for (let i = 0, j = listeners.length; i < j && !e.propagationImmediatelyStopped; i++) {
|
||||
if (listeners[i].once)
|
||||
e.currentTarget.removeListener(type, listeners[i].fn, void 0, true);
|
||||
listeners[i].fn.call(listeners[i].context, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { EventBoundary };
|
||||
//# sourceMappingURL=EventBoundary.mjs.map
|
1
node_modules/pixi.js/lib/events/EventBoundary.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/EventBoundary.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
550
node_modules/pixi.js/lib/events/EventBoundaryTypes.d.ts
generated
vendored
Normal file
550
node_modules/pixi.js/lib/events/EventBoundaryTypes.d.ts
generated
vendored
Normal file
@@ -0,0 +1,550 @@
|
||||
import type { Container } from '../scene/container/Container';
|
||||
/**
|
||||
* The tracking data for each pointer held in the state of an {@link EventBoundary}.
|
||||
*
|
||||
* ```ts
|
||||
* pressTargetsByButton: {
|
||||
* [id: number]: Container[];
|
||||
* };
|
||||
* clicksByButton: {
|
||||
* [id: number]: {
|
||||
* clickCount: number;
|
||||
* target: Container;
|
||||
* timeStamp: number;
|
||||
* };
|
||||
* };
|
||||
* overTargets: Container[];
|
||||
* ```
|
||||
* @typedef {object} TrackingData
|
||||
* @property {Record.<number, Container>} pressTargetsByButton - The pressed containers'
|
||||
* propagation paths by each button of the pointer.
|
||||
* @property {Record.<number, object>} clicksByButton - Holds clicking data for each button of the pointer.
|
||||
* @property {Container[]} overTargets - The Container propagation path over which the pointer is hovering.
|
||||
* @memberof events
|
||||
*/
|
||||
export type TrackingData = {
|
||||
pressTargetsByButton: {
|
||||
[id: number]: Container[];
|
||||
};
|
||||
clicksByButton: {
|
||||
[id: number]: {
|
||||
clickCount: number;
|
||||
target: Container;
|
||||
timeStamp: number;
|
||||
};
|
||||
};
|
||||
overTargets: Container[];
|
||||
};
|
||||
/**
|
||||
* Internal storage of an event listener in EventEmitter.
|
||||
* @ignore
|
||||
*/
|
||||
type EmitterListener = {
|
||||
fn(...args: any[]): any;
|
||||
context: any;
|
||||
once: boolean;
|
||||
};
|
||||
/**
|
||||
* Internal storage of event listeners in EventEmitter.
|
||||
* @ignore
|
||||
*/
|
||||
export type EmitterListeners = Record<string, EmitterListener | EmitterListener[]>;
|
||||
export {};
|
||||
/**
|
||||
* Fired when a mouse button (usually a mouse left-button) is pressed on the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mousedown
|
||||
* @param {FederatedPointerEvent} event - The mousedown event.
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code mousedown}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mousedowncapture
|
||||
* @param {FederatedPointerEvent} event - The capture phase mousedown.
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device secondary button (usually a mouse right-button) is pressed
|
||||
* on the container. Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#rightdown
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code rightdown}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#rightdowncapture
|
||||
* @param {FederatedPointerEvent} event - The rightdowncapture event.
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device button (usually a mouse left-button) is released over the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseup
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code mouseup}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseupcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device secondary button (usually a mouse right-button) is released
|
||||
* over the container. Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#rightup
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code rightup}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#rightupcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device button (usually a mouse left-button) is pressed and released on
|
||||
* the container. Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* A {@code click} event fires after the {@code pointerdown} and {@code pointerup} events, in that
|
||||
* order. If the mouse is moved over another Container after the {@code pointerdown} event, the
|
||||
* {@code click} event is fired on the most specific common ancestor of the two target Containers.
|
||||
*
|
||||
* The {@code detail} property of the event is the number of clicks that occurred within a 200ms
|
||||
* window of each other upto the current click. For example, it will be {@code 2} for a double click.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#click
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code click}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#clickcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device secondary button (usually a mouse right-button) is pressed
|
||||
* and released on the container. Container's `eventMode`
|
||||
* property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* This event follows the semantics of {@code click}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#rightclick
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code rightclick}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#rightclickcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device button (usually a mouse left-button) is released outside the
|
||||
* container that initially registered a
|
||||
* [mousedown]{@link Container#event:mousedown}.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* This event is specific to the Federated Events API. It does not have a capture phase, unlike most of the
|
||||
* other events. It only bubbles to the most specific ancestor of the targets of the corresponding {@code pointerdown}
|
||||
* and {@code pointerup} events, i.e. the target of the {@code click} event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseupoutside
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code mouseupoutside}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseupoutsidecapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device secondary button (usually a mouse right-button) is released
|
||||
* outside the container that initially registered a
|
||||
* [rightdown]{@link Container#event:rightdown}.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#rightupoutside
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code rightupoutside}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#rightupoutsidecapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device (usually a mouse) is moved globally over the scene.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#globalmousemove
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device (usually a mouse) is moved while over the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mousemove
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code mousemove}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mousemovecapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device (usually a mouse) is moved onto the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseover
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code mouseover}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseovercapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when the mouse pointer is moved over a Container and its descendant's hit testing boundaries.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseenter
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code mouseenter}
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseentercapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device (usually a mouse) is moved off the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* This may be fired on a Container that was removed from the scene graph immediately after
|
||||
* a {@code mouseover} event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseout
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code mouseout}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseoutcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when the mouse pointer exits a Container and its descendants.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseleave
|
||||
* @param {FederatedPointerEvent} event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code mouseleave}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#mouseleavecapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device button is pressed on the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerdown
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code pointerdown}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerdowncapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device button is released over the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerup
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code pointerup}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerupcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when the operating system cancels a pointer event.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointercancel
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code pointercancel}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointercancelcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device button is pressed and released on the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointertap
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code pointertap}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointertapcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device button is released outside the container that initially
|
||||
* registered a [pointerdown]{@link Container#event:pointerdown}.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* This event is specific to the Federated Events API. It does not have a capture phase, unlike most of the
|
||||
* other events. It only bubbles to the most specific ancestor of the targets of the corresponding {@code pointerdown}
|
||||
* and {@code pointerup} events, i.e. the target of the {@code click} event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerupoutside
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code pointerupoutside}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerupoutsidecapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device is moved globally over the scene.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#globalpointermove
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device is moved while over the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointermove
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code pointermove}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointermovecapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device is moved onto the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerover
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code pointerover}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerovercapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when the pointer is moved over a Container and its descendant's hit testing boundaries.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerenter
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code pointerenter}
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerentercapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a pointer device is moved off the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerout
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code pointerout}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointeroutcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when the pointer leaves the hit testing boundaries of a Container and its descendants.
|
||||
*
|
||||
* This event notifies only the target and does not bubble.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerleave
|
||||
* @param {FederatedPointerEvent} event - The `pointerleave` event.
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code pointerleave}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#pointerleavecapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a touch point is placed on the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#touchstart
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code touchstart}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#touchstartcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a touch point is removed from the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#touchend
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code touchend}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#touchendcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when the operating system cancels a touch.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#touchcancel
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code touchcancel}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#touchcancelcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a touch point is placed and removed from the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#tap
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code tap}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#tapcapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a touch point is removed outside of the container that initially
|
||||
* registered a [touchstart]{@link Container#event:touchstart}.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#touchendoutside
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code touchendoutside}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#touchendoutsidecapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a touch point is moved globally over the scene.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#globaltouchmove
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a touch point is moved along the container.
|
||||
* Container's `eventMode` property must be set to `static` or 'dynamic' to fire event.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#touchmove
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code touchmove}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#touchmovecapture
|
||||
* @param {FederatedPointerEvent} event - Event
|
||||
*/
|
||||
/**
|
||||
* Fired when a the user scrolls with the mouse cursor over a Container.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#wheel
|
||||
* @type {FederatedWheelEvent}
|
||||
*/
|
||||
/**
|
||||
* Capture phase equivalent of {@code wheel}.
|
||||
*
|
||||
* These events are propagating from the {@link EventSystem EventSystem}.
|
||||
* @event Container#wheelcapture
|
||||
* @type {FederatedWheelEvent}
|
||||
*/
|
4
node_modules/pixi.js/lib/events/EventBoundaryTypes.js
generated
vendored
Normal file
4
node_modules/pixi.js/lib/events/EventBoundaryTypes.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
"use strict";
|
||||
//# sourceMappingURL=EventBoundaryTypes.js.map
|
1
node_modules/pixi.js/lib/events/EventBoundaryTypes.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/EventBoundaryTypes.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"EventBoundaryTypes.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
2
node_modules/pixi.js/lib/events/EventBoundaryTypes.mjs
generated
vendored
Normal file
2
node_modules/pixi.js/lib/events/EventBoundaryTypes.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=EventBoundaryTypes.mjs.map
|
1
node_modules/pixi.js/lib/events/EventBoundaryTypes.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/EventBoundaryTypes.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"EventBoundaryTypes.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
246
node_modules/pixi.js/lib/events/EventSystem.d.ts
generated
vendored
Normal file
246
node_modules/pixi.js/lib/events/EventSystem.d.ts
generated
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
import { EventBoundary } from './EventBoundary';
|
||||
import { FederatedPointerEvent } from './FederatedPointerEvent';
|
||||
import { FederatedWheelEvent } from './FederatedWheelEvent';
|
||||
import type { ExtensionMetadata } from '../extensions/Extensions';
|
||||
import type { PointData } from '../maths/point/PointData';
|
||||
import type { System } from '../rendering/renderers/shared/system/System';
|
||||
import type { Renderer } from '../rendering/renderers/types';
|
||||
import type { EventMode } from './FederatedEventTarget';
|
||||
/** @ignore */
|
||||
export interface EventSystemOptions {
|
||||
/**
|
||||
* The default event mode mode for all display objects.
|
||||
* (included in the **pixi.js** and **pixi.js-legacy** bundle), otherwise it will be ignored.
|
||||
*/
|
||||
eventMode?: EventMode;
|
||||
/**
|
||||
* The event features that are enabled by the EventSystem
|
||||
* (included in the **pixi.js** and **pixi.js-legacy** bundle), otherwise it will be ignored.
|
||||
* @example
|
||||
* const app = new Application({
|
||||
* view: canvas,
|
||||
* events: {
|
||||
* move: true,
|
||||
* globalMove: false,
|
||||
* click: true,
|
||||
* wheel: true,
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
eventFeatures?: Partial<EventSystemFeatures>;
|
||||
}
|
||||
/**
|
||||
* The event features that are enabled by the EventSystem
|
||||
* (included in the **pixi.js** and **pixi.js-legacy** bundle), otherwise it will be ignored.
|
||||
* @since 7.2.0
|
||||
* @memberof events
|
||||
*/
|
||||
export interface EventSystemFeatures {
|
||||
/**
|
||||
* Enables pointer events associated with pointer movement:
|
||||
* - `pointermove` / `mousemove` / `touchmove`
|
||||
* - `pointerout` / `mouseout`
|
||||
* - `pointerover` / `mouseover`
|
||||
*/
|
||||
move: boolean;
|
||||
/**
|
||||
* Enables global pointer move events:
|
||||
* - `globalpointermove`
|
||||
* - `globalmousemove`
|
||||
* - `globaltouchemove`
|
||||
*/
|
||||
globalMove: boolean;
|
||||
/**
|
||||
* Enables pointer events associated with clicking:
|
||||
* - `pointerup` / `mouseup` / `touchend` / 'rightup'
|
||||
* - `pointerupoutside` / `mouseupoutside` / `touchendoutside` / 'rightupoutside'
|
||||
* - `pointerdown` / 'mousedown' / `touchstart` / 'rightdown'
|
||||
* - `click` / `tap`
|
||||
*/
|
||||
click: boolean;
|
||||
/** - Enables wheel events. */
|
||||
wheel: boolean;
|
||||
}
|
||||
/**
|
||||
* The system for handling UI events.
|
||||
* @memberof events
|
||||
*/
|
||||
export declare class EventSystem implements System<EventSystemOptions> {
|
||||
/** @ignore */
|
||||
static extension: ExtensionMetadata;
|
||||
/**
|
||||
* The event features that are enabled by the EventSystem
|
||||
* (included in the **pixi.js** and **pixi.js-legacy** bundle), otherwise it will be ignored.
|
||||
* @since 7.2.0
|
||||
*/
|
||||
static defaultEventFeatures: EventSystemFeatures;
|
||||
private static _defaultEventMode;
|
||||
/**
|
||||
* The default interaction mode for all display objects.
|
||||
* @see Container.eventMode
|
||||
* @type {EventMode}
|
||||
* @readonly
|
||||
* @since 7.2.0
|
||||
*/
|
||||
static get defaultEventMode(): EventMode;
|
||||
/**
|
||||
* The {@link EventBoundary} for the stage.
|
||||
*
|
||||
* The {@link EventBoundary#rootTarget rootTarget} of this root boundary is automatically set to
|
||||
* the last rendered object before any event processing is initiated. This means the main scene
|
||||
* needs to be rendered atleast once before UI events will start propagating.
|
||||
*
|
||||
* The root boundary should only be changed during initialization. Otherwise, any state held by the
|
||||
* event boundary may be lost (like hovered & pressed Containers).
|
||||
*/
|
||||
readonly rootBoundary: EventBoundary;
|
||||
/** Does the device support touch events https://www.w3.org/TR/touch-events/ */
|
||||
readonly supportsTouchEvents: boolean;
|
||||
/** Does the device support pointer events https://www.w3.org/Submission/pointer-events/ */
|
||||
readonly supportsPointerEvents: boolean;
|
||||
/**
|
||||
* Should default browser actions automatically be prevented.
|
||||
* Does not apply to pointer events for backwards compatibility
|
||||
* preventDefault on pointer events stops mouse events from firing
|
||||
* Thus, for every pointer event, there will always be either a mouse of touch event alongside it.
|
||||
* @default true
|
||||
*/
|
||||
autoPreventDefault: boolean;
|
||||
/**
|
||||
* Dictionary of how different cursor modes are handled. Strings are handled as CSS cursor
|
||||
* values, objects are handled as dictionaries of CSS values for {@code domElement},
|
||||
* and functions are called instead of changing the CSS.
|
||||
* Default CSS cursor values are provided for 'default' and 'pointer' modes.
|
||||
*/
|
||||
cursorStyles: Record<string, string | ((mode: string) => void) | CSSStyleDeclaration>;
|
||||
/**
|
||||
* The DOM element to which the root event listeners are bound. This is automatically set to
|
||||
* the renderer's {@link Renderer#view view}.
|
||||
*/
|
||||
domElement: HTMLElement;
|
||||
/** The resolution used to convert between the DOM client space into world space. */
|
||||
resolution: number;
|
||||
/** The renderer managing this {@link EventSystem}. */
|
||||
renderer: Renderer;
|
||||
/**
|
||||
* The event features that are enabled by the EventSystem
|
||||
* (included in the **pixi.js** and **pixi.js-legacy** bundle), otherwise it will be ignored.
|
||||
* @since 7.2.0
|
||||
* @example
|
||||
* const app = new Application()
|
||||
* app.renderer.events.features.globalMove = false
|
||||
*
|
||||
* // to override all features use Object.assign
|
||||
* Object.assign(app.renderer.events.features, {
|
||||
* move: false,
|
||||
* globalMove: false,
|
||||
* click: false,
|
||||
* wheel: false,
|
||||
* })
|
||||
*/
|
||||
readonly features: EventSystemFeatures;
|
||||
private _currentCursor;
|
||||
private readonly _rootPointerEvent;
|
||||
private readonly _rootWheelEvent;
|
||||
private _eventsAdded;
|
||||
/**
|
||||
* @param {Renderer} renderer
|
||||
*/
|
||||
constructor(renderer: Renderer);
|
||||
/**
|
||||
* Runner init called, view is available at this point.
|
||||
* @ignore
|
||||
*/
|
||||
init(options: EventSystemOptions): void;
|
||||
/**
|
||||
* Handle changing resolution.
|
||||
* @ignore
|
||||
*/
|
||||
resolutionChange(resolution: number): void;
|
||||
/** Destroys all event listeners and detaches the renderer. */
|
||||
destroy(): void;
|
||||
/**
|
||||
* Sets the current cursor mode, handling any callbacks or CSS style changes.
|
||||
* @param mode - cursor mode, a key from the cursorStyles dictionary
|
||||
*/
|
||||
setCursor(mode: string): void;
|
||||
/**
|
||||
* The global pointer event.
|
||||
* Useful for getting the pointer position without listening to events.
|
||||
* @since 7.2.0
|
||||
*/
|
||||
get pointer(): Readonly<FederatedPointerEvent>;
|
||||
/**
|
||||
* Event handler for pointer down events on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch event.
|
||||
*/
|
||||
private _onPointerDown;
|
||||
/**
|
||||
* Event handler for pointer move events on on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch events.
|
||||
*/
|
||||
private _onPointerMove;
|
||||
/**
|
||||
* Event handler for pointer up events on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch event.
|
||||
*/
|
||||
private _onPointerUp;
|
||||
/**
|
||||
* Event handler for pointer over & out events on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch event.
|
||||
*/
|
||||
private _onPointerOverOut;
|
||||
/**
|
||||
* Passive handler for `wheel` events on {@link EventSystem.domElement this.domElement}.
|
||||
* @param nativeEvent - The native wheel event.
|
||||
*/
|
||||
protected onWheel(nativeEvent: WheelEvent): void;
|
||||
/**
|
||||
* Sets the {@link EventSystem#domElement domElement} and binds event listeners.
|
||||
*
|
||||
* To deregister the current DOM element without setting a new one, pass {@code null}.
|
||||
* @param element - The new DOM element.
|
||||
*/
|
||||
setTargetElement(element: HTMLElement): void;
|
||||
/** Register event listeners on {@link Renderer#domElement this.domElement}. */
|
||||
private _addEvents;
|
||||
/** Unregister event listeners on {@link EventSystem#domElement this.domElement}. */
|
||||
private _removeEvents;
|
||||
/**
|
||||
* 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.
|
||||
* @param {PointData} point - the point that the result will be stored in
|
||||
* @param {number} x - the x coord of the position to map
|
||||
* @param {number} y - the y coord of the position to map
|
||||
*/
|
||||
mapPositionToPoint(point: PointData, x: number, y: number): void;
|
||||
/**
|
||||
* Ensures that the original event object contains all data that a regular pointer event would have
|
||||
* @param event - 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 _normalizeToPointerData;
|
||||
/**
|
||||
* Normalizes the native {@link https://w3c.github.io/uievents/#interface-wheelevent WheelEvent}.
|
||||
*
|
||||
* The returned {@link FederatedWheelEvent} is a shared instance. It will not persist across
|
||||
* multiple native wheel events.
|
||||
* @param nativeEvent - The native wheel event that occurred on the canvas.
|
||||
* @returns A federated wheel event.
|
||||
*/
|
||||
protected normalizeWheelEvent(nativeEvent: WheelEvent): FederatedWheelEvent;
|
||||
/**
|
||||
* Normalizes the `nativeEvent` into a federateed {@link FederatedPointerEvent}.
|
||||
* @param event
|
||||
* @param nativeEvent
|
||||
*/
|
||||
private _bootstrapEvent;
|
||||
/**
|
||||
* Transfers base & mouse event data from the {@code nativeEvent} to the federated event.
|
||||
* @param event
|
||||
* @param nativeEvent
|
||||
*/
|
||||
private _transferMouseData;
|
||||
}
|
514
node_modules/pixi.js/lib/events/EventSystem.js
generated
vendored
Normal file
514
node_modules/pixi.js/lib/events/EventSystem.js
generated
vendored
Normal file
@@ -0,0 +1,514 @@
|
||||
'use strict';
|
||||
|
||||
var Extensions = require('../extensions/Extensions.js');
|
||||
var EventBoundary = require('./EventBoundary.js');
|
||||
var EventTicker = require('./EventTicker.js');
|
||||
var FederatedPointerEvent = require('./FederatedPointerEvent.js');
|
||||
var FederatedWheelEvent = require('./FederatedWheelEvent.js');
|
||||
|
||||
"use strict";
|
||||
const MOUSE_POINTER_ID = 1;
|
||||
const TOUCH_TO_POINTER = {
|
||||
touchstart: "pointerdown",
|
||||
touchend: "pointerup",
|
||||
touchendoutside: "pointerupoutside",
|
||||
touchmove: "pointermove",
|
||||
touchcancel: "pointercancel"
|
||||
};
|
||||
const _EventSystem = class _EventSystem {
|
||||
/**
|
||||
* @param {Renderer} renderer
|
||||
*/
|
||||
constructor(renderer) {
|
||||
/** Does the device support touch events https://www.w3.org/TR/touch-events/ */
|
||||
this.supportsTouchEvents = "ontouchstart" in globalThis;
|
||||
/** Does the device support pointer events https://www.w3.org/Submission/pointer-events/ */
|
||||
this.supportsPointerEvents = !!globalThis.PointerEvent;
|
||||
/**
|
||||
* The DOM element to which the root event listeners are bound. This is automatically set to
|
||||
* the renderer's {@link Renderer#view view}.
|
||||
*/
|
||||
this.domElement = null;
|
||||
/** The resolution used to convert between the DOM client space into world space. */
|
||||
this.resolution = 1;
|
||||
this.renderer = renderer;
|
||||
this.rootBoundary = new EventBoundary.EventBoundary(null);
|
||||
EventTicker.EventsTicker.init(this);
|
||||
this.autoPreventDefault = true;
|
||||
this._eventsAdded = false;
|
||||
this._rootPointerEvent = new FederatedPointerEvent.FederatedPointerEvent(null);
|
||||
this._rootWheelEvent = new FederatedWheelEvent.FederatedWheelEvent(null);
|
||||
this.cursorStyles = {
|
||||
default: "inherit",
|
||||
pointer: "pointer"
|
||||
};
|
||||
this.features = new Proxy({ ..._EventSystem.defaultEventFeatures }, {
|
||||
set: (target, key, value) => {
|
||||
if (key === "globalMove") {
|
||||
this.rootBoundary.enableGlobalMoveEvents = value;
|
||||
}
|
||||
target[key] = value;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
this._onPointerDown = this._onPointerDown.bind(this);
|
||||
this._onPointerMove = this._onPointerMove.bind(this);
|
||||
this._onPointerUp = this._onPointerUp.bind(this);
|
||||
this._onPointerOverOut = this._onPointerOverOut.bind(this);
|
||||
this.onWheel = this.onWheel.bind(this);
|
||||
}
|
||||
/**
|
||||
* The default interaction mode for all display objects.
|
||||
* @see Container.eventMode
|
||||
* @type {EventMode}
|
||||
* @readonly
|
||||
* @since 7.2.0
|
||||
*/
|
||||
static get defaultEventMode() {
|
||||
return this._defaultEventMode;
|
||||
}
|
||||
/**
|
||||
* Runner init called, view is available at this point.
|
||||
* @ignore
|
||||
*/
|
||||
init(options) {
|
||||
const { canvas, resolution } = this.renderer;
|
||||
this.setTargetElement(canvas);
|
||||
this.resolution = resolution;
|
||||
_EventSystem._defaultEventMode = options.eventMode ?? "passive";
|
||||
Object.assign(this.features, options.eventFeatures ?? {});
|
||||
this.rootBoundary.enableGlobalMoveEvents = this.features.globalMove;
|
||||
}
|
||||
/**
|
||||
* Handle changing resolution.
|
||||
* @ignore
|
||||
*/
|
||||
resolutionChange(resolution) {
|
||||
this.resolution = resolution;
|
||||
}
|
||||
/** Destroys all event listeners and detaches the renderer. */
|
||||
destroy() {
|
||||
this.setTargetElement(null);
|
||||
this.renderer = null;
|
||||
this._currentCursor = null;
|
||||
}
|
||||
/**
|
||||
* Sets the current cursor mode, handling any callbacks or CSS style changes.
|
||||
* @param mode - cursor mode, a key from the cursorStyles dictionary
|
||||
*/
|
||||
setCursor(mode) {
|
||||
mode = mode || "default";
|
||||
let applyStyles = true;
|
||||
if (globalThis.OffscreenCanvas && this.domElement instanceof OffscreenCanvas) {
|
||||
applyStyles = false;
|
||||
}
|
||||
if (this._currentCursor === mode) {
|
||||
return;
|
||||
}
|
||||
this._currentCursor = mode;
|
||||
const style = this.cursorStyles[mode];
|
||||
if (style) {
|
||||
switch (typeof style) {
|
||||
case "string":
|
||||
if (applyStyles) {
|
||||
this.domElement.style.cursor = style;
|
||||
}
|
||||
break;
|
||||
case "function":
|
||||
style(mode);
|
||||
break;
|
||||
case "object":
|
||||
if (applyStyles) {
|
||||
Object.assign(this.domElement.style, style);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (applyStyles && typeof mode === "string" && !Object.prototype.hasOwnProperty.call(this.cursorStyles, mode)) {
|
||||
this.domElement.style.cursor = mode;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The global pointer event.
|
||||
* Useful for getting the pointer position without listening to events.
|
||||
* @since 7.2.0
|
||||
*/
|
||||
get pointer() {
|
||||
return this._rootPointerEvent;
|
||||
}
|
||||
/**
|
||||
* Event handler for pointer down events on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch event.
|
||||
*/
|
||||
_onPointerDown(nativeEvent) {
|
||||
if (!this.features.click)
|
||||
return;
|
||||
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
||||
const events = this._normalizeToPointerData(nativeEvent);
|
||||
if (this.autoPreventDefault && events[0].isNormalized) {
|
||||
const cancelable = nativeEvent.cancelable || !("cancelable" in nativeEvent);
|
||||
if (cancelable) {
|
||||
nativeEvent.preventDefault();
|
||||
}
|
||||
}
|
||||
for (let i = 0, j = events.length; i < j; i++) {
|
||||
const nativeEvent2 = events[i];
|
||||
const federatedEvent = this._bootstrapEvent(this._rootPointerEvent, nativeEvent2);
|
||||
this.rootBoundary.mapEvent(federatedEvent);
|
||||
}
|
||||
this.setCursor(this.rootBoundary.cursor);
|
||||
}
|
||||
/**
|
||||
* Event handler for pointer move events on on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch events.
|
||||
*/
|
||||
_onPointerMove(nativeEvent) {
|
||||
if (!this.features.move)
|
||||
return;
|
||||
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
||||
EventTicker.EventsTicker.pointerMoved();
|
||||
const normalizedEvents = this._normalizeToPointerData(nativeEvent);
|
||||
for (let i = 0, j = normalizedEvents.length; i < j; i++) {
|
||||
const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
|
||||
this.rootBoundary.mapEvent(event);
|
||||
}
|
||||
this.setCursor(this.rootBoundary.cursor);
|
||||
}
|
||||
/**
|
||||
* Event handler for pointer up events on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch event.
|
||||
*/
|
||||
_onPointerUp(nativeEvent) {
|
||||
if (!this.features.click)
|
||||
return;
|
||||
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
||||
let target = nativeEvent.target;
|
||||
if (nativeEvent.composedPath && nativeEvent.composedPath().length > 0) {
|
||||
target = nativeEvent.composedPath()[0];
|
||||
}
|
||||
const outside = target !== this.domElement ? "outside" : "";
|
||||
const normalizedEvents = this._normalizeToPointerData(nativeEvent);
|
||||
for (let i = 0, j = normalizedEvents.length; i < j; i++) {
|
||||
const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
|
||||
event.type += outside;
|
||||
this.rootBoundary.mapEvent(event);
|
||||
}
|
||||
this.setCursor(this.rootBoundary.cursor);
|
||||
}
|
||||
/**
|
||||
* Event handler for pointer over & out events on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch event.
|
||||
*/
|
||||
_onPointerOverOut(nativeEvent) {
|
||||
if (!this.features.click)
|
||||
return;
|
||||
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
||||
const normalizedEvents = this._normalizeToPointerData(nativeEvent);
|
||||
for (let i = 0, j = normalizedEvents.length; i < j; i++) {
|
||||
const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
|
||||
this.rootBoundary.mapEvent(event);
|
||||
}
|
||||
this.setCursor(this.rootBoundary.cursor);
|
||||
}
|
||||
/**
|
||||
* Passive handler for `wheel` events on {@link EventSystem.domElement this.domElement}.
|
||||
* @param nativeEvent - The native wheel event.
|
||||
*/
|
||||
onWheel(nativeEvent) {
|
||||
if (!this.features.wheel)
|
||||
return;
|
||||
const wheelEvent = this.normalizeWheelEvent(nativeEvent);
|
||||
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
||||
this.rootBoundary.mapEvent(wheelEvent);
|
||||
}
|
||||
/**
|
||||
* Sets the {@link EventSystem#domElement domElement} and binds event listeners.
|
||||
*
|
||||
* To deregister the current DOM element without setting a new one, pass {@code null}.
|
||||
* @param element - The new DOM element.
|
||||
*/
|
||||
setTargetElement(element) {
|
||||
this._removeEvents();
|
||||
this.domElement = element;
|
||||
EventTicker.EventsTicker.domElement = element;
|
||||
this._addEvents();
|
||||
}
|
||||
/** Register event listeners on {@link Renderer#domElement this.domElement}. */
|
||||
_addEvents() {
|
||||
if (this._eventsAdded || !this.domElement) {
|
||||
return;
|
||||
}
|
||||
EventTicker.EventsTicker.addTickerListener();
|
||||
const style = this.domElement.style;
|
||||
if (style) {
|
||||
if (globalThis.navigator.msPointerEnabled) {
|
||||
style.msContentZooming = "none";
|
||||
style.msTouchAction = "none";
|
||||
} else if (this.supportsPointerEvents) {
|
||||
style.touchAction = "none";
|
||||
}
|
||||
}
|
||||
if (this.supportsPointerEvents) {
|
||||
globalThis.document.addEventListener("pointermove", this._onPointerMove, true);
|
||||
this.domElement.addEventListener("pointerdown", this._onPointerDown, true);
|
||||
this.domElement.addEventListener("pointerleave", this._onPointerOverOut, true);
|
||||
this.domElement.addEventListener("pointerover", this._onPointerOverOut, true);
|
||||
globalThis.addEventListener("pointerup", this._onPointerUp, true);
|
||||
} else {
|
||||
globalThis.document.addEventListener("mousemove", this._onPointerMove, true);
|
||||
this.domElement.addEventListener("mousedown", this._onPointerDown, true);
|
||||
this.domElement.addEventListener("mouseout", this._onPointerOverOut, true);
|
||||
this.domElement.addEventListener("mouseover", this._onPointerOverOut, true);
|
||||
globalThis.addEventListener("mouseup", this._onPointerUp, true);
|
||||
if (this.supportsTouchEvents) {
|
||||
this.domElement.addEventListener("touchstart", this._onPointerDown, true);
|
||||
this.domElement.addEventListener("touchend", this._onPointerUp, true);
|
||||
this.domElement.addEventListener("touchmove", this._onPointerMove, true);
|
||||
}
|
||||
}
|
||||
this.domElement.addEventListener("wheel", this.onWheel, {
|
||||
passive: true,
|
||||
capture: true
|
||||
});
|
||||
this._eventsAdded = true;
|
||||
}
|
||||
/** Unregister event listeners on {@link EventSystem#domElement this.domElement}. */
|
||||
_removeEvents() {
|
||||
if (!this._eventsAdded || !this.domElement) {
|
||||
return;
|
||||
}
|
||||
EventTicker.EventsTicker.removeTickerListener();
|
||||
const style = this.domElement.style;
|
||||
if (style) {
|
||||
if (globalThis.navigator.msPointerEnabled) {
|
||||
style.msContentZooming = "";
|
||||
style.msTouchAction = "";
|
||||
} else if (this.supportsPointerEvents) {
|
||||
style.touchAction = "";
|
||||
}
|
||||
}
|
||||
if (this.supportsPointerEvents) {
|
||||
globalThis.document.removeEventListener("pointermove", this._onPointerMove, true);
|
||||
this.domElement.removeEventListener("pointerdown", this._onPointerDown, true);
|
||||
this.domElement.removeEventListener("pointerleave", this._onPointerOverOut, true);
|
||||
this.domElement.removeEventListener("pointerover", this._onPointerOverOut, true);
|
||||
globalThis.removeEventListener("pointerup", this._onPointerUp, true);
|
||||
} else {
|
||||
globalThis.document.removeEventListener("mousemove", this._onPointerMove, true);
|
||||
this.domElement.removeEventListener("mousedown", this._onPointerDown, true);
|
||||
this.domElement.removeEventListener("mouseout", this._onPointerOverOut, true);
|
||||
this.domElement.removeEventListener("mouseover", this._onPointerOverOut, true);
|
||||
globalThis.removeEventListener("mouseup", this._onPointerUp, true);
|
||||
if (this.supportsTouchEvents) {
|
||||
this.domElement.removeEventListener("touchstart", this._onPointerDown, true);
|
||||
this.domElement.removeEventListener("touchend", this._onPointerUp, true);
|
||||
this.domElement.removeEventListener("touchmove", this._onPointerMove, true);
|
||||
}
|
||||
}
|
||||
this.domElement.removeEventListener("wheel", this.onWheel, true);
|
||||
this.domElement = null;
|
||||
this._eventsAdded = false;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param {PointData} point - the point that the result will be stored in
|
||||
* @param {number} x - the x coord of the position to map
|
||||
* @param {number} y - the y coord of the position to map
|
||||
*/
|
||||
mapPositionToPoint(point, x, y) {
|
||||
const rect = this.domElement.isConnected ? this.domElement.getBoundingClientRect() : {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: this.domElement.width,
|
||||
height: this.domElement.height,
|
||||
left: 0,
|
||||
top: 0
|
||||
};
|
||||
const resolutionMultiplier = 1 / this.resolution;
|
||||
point.x = (x - rect.left) * (this.domElement.width / rect.width) * resolutionMultiplier;
|
||||
point.y = (y - rect.top) * (this.domElement.height / rect.height) * resolutionMultiplier;
|
||||
}
|
||||
/**
|
||||
* Ensures that the original event object contains all data that a regular pointer event would have
|
||||
* @param event - 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
|
||||
*/
|
||||
_normalizeToPointerData(event) {
|
||||
const normalizedEvents = [];
|
||||
if (this.supportsTouchEvents && event instanceof TouchEvent) {
|
||||
for (let i = 0, li = event.changedTouches.length; i < li; i++) {
|
||||
const touch = event.changedTouches[i];
|
||||
if (typeof touch.button === "undefined")
|
||||
touch.button = 0;
|
||||
if (typeof touch.buttons === "undefined")
|
||||
touch.buttons = 1;
|
||||
if (typeof touch.isPrimary === "undefined") {
|
||||
touch.isPrimary = event.touches.length === 1 && event.type === "touchstart";
|
||||
}
|
||||
if (typeof touch.width === "undefined")
|
||||
touch.width = touch.radiusX || 1;
|
||||
if (typeof touch.height === "undefined")
|
||||
touch.height = touch.radiusY || 1;
|
||||
if (typeof touch.tiltX === "undefined")
|
||||
touch.tiltX = 0;
|
||||
if (typeof touch.tiltY === "undefined")
|
||||
touch.tiltY = 0;
|
||||
if (typeof touch.pointerType === "undefined")
|
||||
touch.pointerType = "touch";
|
||||
if (typeof touch.pointerId === "undefined")
|
||||
touch.pointerId = touch.identifier || 0;
|
||||
if (typeof touch.pressure === "undefined")
|
||||
touch.pressure = touch.force || 0.5;
|
||||
if (typeof touch.twist === "undefined")
|
||||
touch.twist = 0;
|
||||
if (typeof touch.tangentialPressure === "undefined")
|
||||
touch.tangentialPressure = 0;
|
||||
if (typeof touch.layerX === "undefined")
|
||||
touch.layerX = touch.offsetX = touch.clientX;
|
||||
if (typeof touch.layerY === "undefined")
|
||||
touch.layerY = touch.offsetY = touch.clientY;
|
||||
touch.isNormalized = true;
|
||||
touch.type = event.type;
|
||||
normalizedEvents.push(touch);
|
||||
}
|
||||
} else if (!globalThis.MouseEvent || event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof globalThis.PointerEvent))) {
|
||||
const tempEvent = event;
|
||||
if (typeof tempEvent.isPrimary === "undefined")
|
||||
tempEvent.isPrimary = true;
|
||||
if (typeof tempEvent.width === "undefined")
|
||||
tempEvent.width = 1;
|
||||
if (typeof tempEvent.height === "undefined")
|
||||
tempEvent.height = 1;
|
||||
if (typeof tempEvent.tiltX === "undefined")
|
||||
tempEvent.tiltX = 0;
|
||||
if (typeof tempEvent.tiltY === "undefined")
|
||||
tempEvent.tiltY = 0;
|
||||
if (typeof tempEvent.pointerType === "undefined")
|
||||
tempEvent.pointerType = "mouse";
|
||||
if (typeof tempEvent.pointerId === "undefined")
|
||||
tempEvent.pointerId = MOUSE_POINTER_ID;
|
||||
if (typeof tempEvent.pressure === "undefined")
|
||||
tempEvent.pressure = 0.5;
|
||||
if (typeof tempEvent.twist === "undefined")
|
||||
tempEvent.twist = 0;
|
||||
if (typeof tempEvent.tangentialPressure === "undefined")
|
||||
tempEvent.tangentialPressure = 0;
|
||||
tempEvent.isNormalized = true;
|
||||
normalizedEvents.push(tempEvent);
|
||||
} else {
|
||||
normalizedEvents.push(event);
|
||||
}
|
||||
return normalizedEvents;
|
||||
}
|
||||
/**
|
||||
* Normalizes the native {@link https://w3c.github.io/uievents/#interface-wheelevent WheelEvent}.
|
||||
*
|
||||
* The returned {@link FederatedWheelEvent} is a shared instance. It will not persist across
|
||||
* multiple native wheel events.
|
||||
* @param nativeEvent - The native wheel event that occurred on the canvas.
|
||||
* @returns A federated wheel event.
|
||||
*/
|
||||
normalizeWheelEvent(nativeEvent) {
|
||||
const event = this._rootWheelEvent;
|
||||
this._transferMouseData(event, nativeEvent);
|
||||
event.deltaX = nativeEvent.deltaX;
|
||||
event.deltaY = nativeEvent.deltaY;
|
||||
event.deltaZ = nativeEvent.deltaZ;
|
||||
event.deltaMode = nativeEvent.deltaMode;
|
||||
this.mapPositionToPoint(event.screen, nativeEvent.clientX, nativeEvent.clientY);
|
||||
event.global.copyFrom(event.screen);
|
||||
event.offset.copyFrom(event.screen);
|
||||
event.nativeEvent = nativeEvent;
|
||||
event.type = nativeEvent.type;
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* Normalizes the `nativeEvent` into a federateed {@link FederatedPointerEvent}.
|
||||
* @param event
|
||||
* @param nativeEvent
|
||||
*/
|
||||
_bootstrapEvent(event, nativeEvent) {
|
||||
event.originalEvent = null;
|
||||
event.nativeEvent = nativeEvent;
|
||||
event.pointerId = nativeEvent.pointerId;
|
||||
event.width = nativeEvent.width;
|
||||
event.height = nativeEvent.height;
|
||||
event.isPrimary = nativeEvent.isPrimary;
|
||||
event.pointerType = nativeEvent.pointerType;
|
||||
event.pressure = nativeEvent.pressure;
|
||||
event.tangentialPressure = nativeEvent.tangentialPressure;
|
||||
event.tiltX = nativeEvent.tiltX;
|
||||
event.tiltY = nativeEvent.tiltY;
|
||||
event.twist = nativeEvent.twist;
|
||||
this._transferMouseData(event, nativeEvent);
|
||||
this.mapPositionToPoint(event.screen, nativeEvent.clientX, nativeEvent.clientY);
|
||||
event.global.copyFrom(event.screen);
|
||||
event.offset.copyFrom(event.screen);
|
||||
event.isTrusted = nativeEvent.isTrusted;
|
||||
if (event.type === "pointerleave") {
|
||||
event.type = "pointerout";
|
||||
}
|
||||
if (event.type.startsWith("mouse")) {
|
||||
event.type = event.type.replace("mouse", "pointer");
|
||||
}
|
||||
if (event.type.startsWith("touch")) {
|
||||
event.type = TOUCH_TO_POINTER[event.type] || event.type;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* Transfers base & mouse event data from the {@code nativeEvent} to the federated event.
|
||||
* @param event
|
||||
* @param nativeEvent
|
||||
*/
|
||||
_transferMouseData(event, nativeEvent) {
|
||||
event.isTrusted = nativeEvent.isTrusted;
|
||||
event.srcElement = nativeEvent.srcElement;
|
||||
event.timeStamp = performance.now();
|
||||
event.type = nativeEvent.type;
|
||||
event.altKey = nativeEvent.altKey;
|
||||
event.button = nativeEvent.button;
|
||||
event.buttons = nativeEvent.buttons;
|
||||
event.client.x = nativeEvent.clientX;
|
||||
event.client.y = nativeEvent.clientY;
|
||||
event.ctrlKey = nativeEvent.ctrlKey;
|
||||
event.metaKey = nativeEvent.metaKey;
|
||||
event.movement.x = nativeEvent.movementX;
|
||||
event.movement.y = nativeEvent.movementY;
|
||||
event.page.x = nativeEvent.pageX;
|
||||
event.page.y = nativeEvent.pageY;
|
||||
event.relatedTarget = null;
|
||||
event.shiftKey = nativeEvent.shiftKey;
|
||||
}
|
||||
};
|
||||
/** @ignore */
|
||||
_EventSystem.extension = {
|
||||
name: "events",
|
||||
type: [
|
||||
Extensions.ExtensionType.WebGLSystem,
|
||||
Extensions.ExtensionType.CanvasSystem,
|
||||
Extensions.ExtensionType.WebGPUSystem
|
||||
],
|
||||
priority: -1
|
||||
};
|
||||
/**
|
||||
* The event features that are enabled by the EventSystem
|
||||
* (included in the **pixi.js** and **pixi.js-legacy** bundle), otherwise it will be ignored.
|
||||
* @since 7.2.0
|
||||
*/
|
||||
_EventSystem.defaultEventFeatures = {
|
||||
/** Enables pointer events associated with pointer movement. */
|
||||
move: true,
|
||||
/** Enables global pointer move events. */
|
||||
globalMove: true,
|
||||
/** Enables pointer events associated with clicking. */
|
||||
click: true,
|
||||
/** Enables wheel events. */
|
||||
wheel: true
|
||||
};
|
||||
let EventSystem = _EventSystem;
|
||||
|
||||
exports.EventSystem = EventSystem;
|
||||
//# sourceMappingURL=EventSystem.js.map
|
1
node_modules/pixi.js/lib/events/EventSystem.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/EventSystem.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
512
node_modules/pixi.js/lib/events/EventSystem.mjs
generated
vendored
Normal file
512
node_modules/pixi.js/lib/events/EventSystem.mjs
generated
vendored
Normal file
@@ -0,0 +1,512 @@
|
||||
import { ExtensionType } from '../extensions/Extensions.mjs';
|
||||
import { EventBoundary } from './EventBoundary.mjs';
|
||||
import { EventsTicker } from './EventTicker.mjs';
|
||||
import { FederatedPointerEvent } from './FederatedPointerEvent.mjs';
|
||||
import { FederatedWheelEvent } from './FederatedWheelEvent.mjs';
|
||||
|
||||
"use strict";
|
||||
const MOUSE_POINTER_ID = 1;
|
||||
const TOUCH_TO_POINTER = {
|
||||
touchstart: "pointerdown",
|
||||
touchend: "pointerup",
|
||||
touchendoutside: "pointerupoutside",
|
||||
touchmove: "pointermove",
|
||||
touchcancel: "pointercancel"
|
||||
};
|
||||
const _EventSystem = class _EventSystem {
|
||||
/**
|
||||
* @param {Renderer} renderer
|
||||
*/
|
||||
constructor(renderer) {
|
||||
/** Does the device support touch events https://www.w3.org/TR/touch-events/ */
|
||||
this.supportsTouchEvents = "ontouchstart" in globalThis;
|
||||
/** Does the device support pointer events https://www.w3.org/Submission/pointer-events/ */
|
||||
this.supportsPointerEvents = !!globalThis.PointerEvent;
|
||||
/**
|
||||
* The DOM element to which the root event listeners are bound. This is automatically set to
|
||||
* the renderer's {@link Renderer#view view}.
|
||||
*/
|
||||
this.domElement = null;
|
||||
/** The resolution used to convert between the DOM client space into world space. */
|
||||
this.resolution = 1;
|
||||
this.renderer = renderer;
|
||||
this.rootBoundary = new EventBoundary(null);
|
||||
EventsTicker.init(this);
|
||||
this.autoPreventDefault = true;
|
||||
this._eventsAdded = false;
|
||||
this._rootPointerEvent = new FederatedPointerEvent(null);
|
||||
this._rootWheelEvent = new FederatedWheelEvent(null);
|
||||
this.cursorStyles = {
|
||||
default: "inherit",
|
||||
pointer: "pointer"
|
||||
};
|
||||
this.features = new Proxy({ ..._EventSystem.defaultEventFeatures }, {
|
||||
set: (target, key, value) => {
|
||||
if (key === "globalMove") {
|
||||
this.rootBoundary.enableGlobalMoveEvents = value;
|
||||
}
|
||||
target[key] = value;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
this._onPointerDown = this._onPointerDown.bind(this);
|
||||
this._onPointerMove = this._onPointerMove.bind(this);
|
||||
this._onPointerUp = this._onPointerUp.bind(this);
|
||||
this._onPointerOverOut = this._onPointerOverOut.bind(this);
|
||||
this.onWheel = this.onWheel.bind(this);
|
||||
}
|
||||
/**
|
||||
* The default interaction mode for all display objects.
|
||||
* @see Container.eventMode
|
||||
* @type {EventMode}
|
||||
* @readonly
|
||||
* @since 7.2.0
|
||||
*/
|
||||
static get defaultEventMode() {
|
||||
return this._defaultEventMode;
|
||||
}
|
||||
/**
|
||||
* Runner init called, view is available at this point.
|
||||
* @ignore
|
||||
*/
|
||||
init(options) {
|
||||
const { canvas, resolution } = this.renderer;
|
||||
this.setTargetElement(canvas);
|
||||
this.resolution = resolution;
|
||||
_EventSystem._defaultEventMode = options.eventMode ?? "passive";
|
||||
Object.assign(this.features, options.eventFeatures ?? {});
|
||||
this.rootBoundary.enableGlobalMoveEvents = this.features.globalMove;
|
||||
}
|
||||
/**
|
||||
* Handle changing resolution.
|
||||
* @ignore
|
||||
*/
|
||||
resolutionChange(resolution) {
|
||||
this.resolution = resolution;
|
||||
}
|
||||
/** Destroys all event listeners and detaches the renderer. */
|
||||
destroy() {
|
||||
this.setTargetElement(null);
|
||||
this.renderer = null;
|
||||
this._currentCursor = null;
|
||||
}
|
||||
/**
|
||||
* Sets the current cursor mode, handling any callbacks or CSS style changes.
|
||||
* @param mode - cursor mode, a key from the cursorStyles dictionary
|
||||
*/
|
||||
setCursor(mode) {
|
||||
mode = mode || "default";
|
||||
let applyStyles = true;
|
||||
if (globalThis.OffscreenCanvas && this.domElement instanceof OffscreenCanvas) {
|
||||
applyStyles = false;
|
||||
}
|
||||
if (this._currentCursor === mode) {
|
||||
return;
|
||||
}
|
||||
this._currentCursor = mode;
|
||||
const style = this.cursorStyles[mode];
|
||||
if (style) {
|
||||
switch (typeof style) {
|
||||
case "string":
|
||||
if (applyStyles) {
|
||||
this.domElement.style.cursor = style;
|
||||
}
|
||||
break;
|
||||
case "function":
|
||||
style(mode);
|
||||
break;
|
||||
case "object":
|
||||
if (applyStyles) {
|
||||
Object.assign(this.domElement.style, style);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (applyStyles && typeof mode === "string" && !Object.prototype.hasOwnProperty.call(this.cursorStyles, mode)) {
|
||||
this.domElement.style.cursor = mode;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The global pointer event.
|
||||
* Useful for getting the pointer position without listening to events.
|
||||
* @since 7.2.0
|
||||
*/
|
||||
get pointer() {
|
||||
return this._rootPointerEvent;
|
||||
}
|
||||
/**
|
||||
* Event handler for pointer down events on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch event.
|
||||
*/
|
||||
_onPointerDown(nativeEvent) {
|
||||
if (!this.features.click)
|
||||
return;
|
||||
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
||||
const events = this._normalizeToPointerData(nativeEvent);
|
||||
if (this.autoPreventDefault && events[0].isNormalized) {
|
||||
const cancelable = nativeEvent.cancelable || !("cancelable" in nativeEvent);
|
||||
if (cancelable) {
|
||||
nativeEvent.preventDefault();
|
||||
}
|
||||
}
|
||||
for (let i = 0, j = events.length; i < j; i++) {
|
||||
const nativeEvent2 = events[i];
|
||||
const federatedEvent = this._bootstrapEvent(this._rootPointerEvent, nativeEvent2);
|
||||
this.rootBoundary.mapEvent(federatedEvent);
|
||||
}
|
||||
this.setCursor(this.rootBoundary.cursor);
|
||||
}
|
||||
/**
|
||||
* Event handler for pointer move events on on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch events.
|
||||
*/
|
||||
_onPointerMove(nativeEvent) {
|
||||
if (!this.features.move)
|
||||
return;
|
||||
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
||||
EventsTicker.pointerMoved();
|
||||
const normalizedEvents = this._normalizeToPointerData(nativeEvent);
|
||||
for (let i = 0, j = normalizedEvents.length; i < j; i++) {
|
||||
const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
|
||||
this.rootBoundary.mapEvent(event);
|
||||
}
|
||||
this.setCursor(this.rootBoundary.cursor);
|
||||
}
|
||||
/**
|
||||
* Event handler for pointer up events on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch event.
|
||||
*/
|
||||
_onPointerUp(nativeEvent) {
|
||||
if (!this.features.click)
|
||||
return;
|
||||
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
||||
let target = nativeEvent.target;
|
||||
if (nativeEvent.composedPath && nativeEvent.composedPath().length > 0) {
|
||||
target = nativeEvent.composedPath()[0];
|
||||
}
|
||||
const outside = target !== this.domElement ? "outside" : "";
|
||||
const normalizedEvents = this._normalizeToPointerData(nativeEvent);
|
||||
for (let i = 0, j = normalizedEvents.length; i < j; i++) {
|
||||
const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
|
||||
event.type += outside;
|
||||
this.rootBoundary.mapEvent(event);
|
||||
}
|
||||
this.setCursor(this.rootBoundary.cursor);
|
||||
}
|
||||
/**
|
||||
* Event handler for pointer over & out events on {@link EventSystem#domElement this.domElement}.
|
||||
* @param nativeEvent - The native mouse/pointer/touch event.
|
||||
*/
|
||||
_onPointerOverOut(nativeEvent) {
|
||||
if (!this.features.click)
|
||||
return;
|
||||
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
||||
const normalizedEvents = this._normalizeToPointerData(nativeEvent);
|
||||
for (let i = 0, j = normalizedEvents.length; i < j; i++) {
|
||||
const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
|
||||
this.rootBoundary.mapEvent(event);
|
||||
}
|
||||
this.setCursor(this.rootBoundary.cursor);
|
||||
}
|
||||
/**
|
||||
* Passive handler for `wheel` events on {@link EventSystem.domElement this.domElement}.
|
||||
* @param nativeEvent - The native wheel event.
|
||||
*/
|
||||
onWheel(nativeEvent) {
|
||||
if (!this.features.wheel)
|
||||
return;
|
||||
const wheelEvent = this.normalizeWheelEvent(nativeEvent);
|
||||
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
||||
this.rootBoundary.mapEvent(wheelEvent);
|
||||
}
|
||||
/**
|
||||
* Sets the {@link EventSystem#domElement domElement} and binds event listeners.
|
||||
*
|
||||
* To deregister the current DOM element without setting a new one, pass {@code null}.
|
||||
* @param element - The new DOM element.
|
||||
*/
|
||||
setTargetElement(element) {
|
||||
this._removeEvents();
|
||||
this.domElement = element;
|
||||
EventsTicker.domElement = element;
|
||||
this._addEvents();
|
||||
}
|
||||
/** Register event listeners on {@link Renderer#domElement this.domElement}. */
|
||||
_addEvents() {
|
||||
if (this._eventsAdded || !this.domElement) {
|
||||
return;
|
||||
}
|
||||
EventsTicker.addTickerListener();
|
||||
const style = this.domElement.style;
|
||||
if (style) {
|
||||
if (globalThis.navigator.msPointerEnabled) {
|
||||
style.msContentZooming = "none";
|
||||
style.msTouchAction = "none";
|
||||
} else if (this.supportsPointerEvents) {
|
||||
style.touchAction = "none";
|
||||
}
|
||||
}
|
||||
if (this.supportsPointerEvents) {
|
||||
globalThis.document.addEventListener("pointermove", this._onPointerMove, true);
|
||||
this.domElement.addEventListener("pointerdown", this._onPointerDown, true);
|
||||
this.domElement.addEventListener("pointerleave", this._onPointerOverOut, true);
|
||||
this.domElement.addEventListener("pointerover", this._onPointerOverOut, true);
|
||||
globalThis.addEventListener("pointerup", this._onPointerUp, true);
|
||||
} else {
|
||||
globalThis.document.addEventListener("mousemove", this._onPointerMove, true);
|
||||
this.domElement.addEventListener("mousedown", this._onPointerDown, true);
|
||||
this.domElement.addEventListener("mouseout", this._onPointerOverOut, true);
|
||||
this.domElement.addEventListener("mouseover", this._onPointerOverOut, true);
|
||||
globalThis.addEventListener("mouseup", this._onPointerUp, true);
|
||||
if (this.supportsTouchEvents) {
|
||||
this.domElement.addEventListener("touchstart", this._onPointerDown, true);
|
||||
this.domElement.addEventListener("touchend", this._onPointerUp, true);
|
||||
this.domElement.addEventListener("touchmove", this._onPointerMove, true);
|
||||
}
|
||||
}
|
||||
this.domElement.addEventListener("wheel", this.onWheel, {
|
||||
passive: true,
|
||||
capture: true
|
||||
});
|
||||
this._eventsAdded = true;
|
||||
}
|
||||
/** Unregister event listeners on {@link EventSystem#domElement this.domElement}. */
|
||||
_removeEvents() {
|
||||
if (!this._eventsAdded || !this.domElement) {
|
||||
return;
|
||||
}
|
||||
EventsTicker.removeTickerListener();
|
||||
const style = this.domElement.style;
|
||||
if (style) {
|
||||
if (globalThis.navigator.msPointerEnabled) {
|
||||
style.msContentZooming = "";
|
||||
style.msTouchAction = "";
|
||||
} else if (this.supportsPointerEvents) {
|
||||
style.touchAction = "";
|
||||
}
|
||||
}
|
||||
if (this.supportsPointerEvents) {
|
||||
globalThis.document.removeEventListener("pointermove", this._onPointerMove, true);
|
||||
this.domElement.removeEventListener("pointerdown", this._onPointerDown, true);
|
||||
this.domElement.removeEventListener("pointerleave", this._onPointerOverOut, true);
|
||||
this.domElement.removeEventListener("pointerover", this._onPointerOverOut, true);
|
||||
globalThis.removeEventListener("pointerup", this._onPointerUp, true);
|
||||
} else {
|
||||
globalThis.document.removeEventListener("mousemove", this._onPointerMove, true);
|
||||
this.domElement.removeEventListener("mousedown", this._onPointerDown, true);
|
||||
this.domElement.removeEventListener("mouseout", this._onPointerOverOut, true);
|
||||
this.domElement.removeEventListener("mouseover", this._onPointerOverOut, true);
|
||||
globalThis.removeEventListener("mouseup", this._onPointerUp, true);
|
||||
if (this.supportsTouchEvents) {
|
||||
this.domElement.removeEventListener("touchstart", this._onPointerDown, true);
|
||||
this.domElement.removeEventListener("touchend", this._onPointerUp, true);
|
||||
this.domElement.removeEventListener("touchmove", this._onPointerMove, true);
|
||||
}
|
||||
}
|
||||
this.domElement.removeEventListener("wheel", this.onWheel, true);
|
||||
this.domElement = null;
|
||||
this._eventsAdded = false;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param {PointData} point - the point that the result will be stored in
|
||||
* @param {number} x - the x coord of the position to map
|
||||
* @param {number} y - the y coord of the position to map
|
||||
*/
|
||||
mapPositionToPoint(point, x, y) {
|
||||
const rect = this.domElement.isConnected ? this.domElement.getBoundingClientRect() : {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: this.domElement.width,
|
||||
height: this.domElement.height,
|
||||
left: 0,
|
||||
top: 0
|
||||
};
|
||||
const resolutionMultiplier = 1 / this.resolution;
|
||||
point.x = (x - rect.left) * (this.domElement.width / rect.width) * resolutionMultiplier;
|
||||
point.y = (y - rect.top) * (this.domElement.height / rect.height) * resolutionMultiplier;
|
||||
}
|
||||
/**
|
||||
* Ensures that the original event object contains all data that a regular pointer event would have
|
||||
* @param event - 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
|
||||
*/
|
||||
_normalizeToPointerData(event) {
|
||||
const normalizedEvents = [];
|
||||
if (this.supportsTouchEvents && event instanceof TouchEvent) {
|
||||
for (let i = 0, li = event.changedTouches.length; i < li; i++) {
|
||||
const touch = event.changedTouches[i];
|
||||
if (typeof touch.button === "undefined")
|
||||
touch.button = 0;
|
||||
if (typeof touch.buttons === "undefined")
|
||||
touch.buttons = 1;
|
||||
if (typeof touch.isPrimary === "undefined") {
|
||||
touch.isPrimary = event.touches.length === 1 && event.type === "touchstart";
|
||||
}
|
||||
if (typeof touch.width === "undefined")
|
||||
touch.width = touch.radiusX || 1;
|
||||
if (typeof touch.height === "undefined")
|
||||
touch.height = touch.radiusY || 1;
|
||||
if (typeof touch.tiltX === "undefined")
|
||||
touch.tiltX = 0;
|
||||
if (typeof touch.tiltY === "undefined")
|
||||
touch.tiltY = 0;
|
||||
if (typeof touch.pointerType === "undefined")
|
||||
touch.pointerType = "touch";
|
||||
if (typeof touch.pointerId === "undefined")
|
||||
touch.pointerId = touch.identifier || 0;
|
||||
if (typeof touch.pressure === "undefined")
|
||||
touch.pressure = touch.force || 0.5;
|
||||
if (typeof touch.twist === "undefined")
|
||||
touch.twist = 0;
|
||||
if (typeof touch.tangentialPressure === "undefined")
|
||||
touch.tangentialPressure = 0;
|
||||
if (typeof touch.layerX === "undefined")
|
||||
touch.layerX = touch.offsetX = touch.clientX;
|
||||
if (typeof touch.layerY === "undefined")
|
||||
touch.layerY = touch.offsetY = touch.clientY;
|
||||
touch.isNormalized = true;
|
||||
touch.type = event.type;
|
||||
normalizedEvents.push(touch);
|
||||
}
|
||||
} else if (!globalThis.MouseEvent || event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof globalThis.PointerEvent))) {
|
||||
const tempEvent = event;
|
||||
if (typeof tempEvent.isPrimary === "undefined")
|
||||
tempEvent.isPrimary = true;
|
||||
if (typeof tempEvent.width === "undefined")
|
||||
tempEvent.width = 1;
|
||||
if (typeof tempEvent.height === "undefined")
|
||||
tempEvent.height = 1;
|
||||
if (typeof tempEvent.tiltX === "undefined")
|
||||
tempEvent.tiltX = 0;
|
||||
if (typeof tempEvent.tiltY === "undefined")
|
||||
tempEvent.tiltY = 0;
|
||||
if (typeof tempEvent.pointerType === "undefined")
|
||||
tempEvent.pointerType = "mouse";
|
||||
if (typeof tempEvent.pointerId === "undefined")
|
||||
tempEvent.pointerId = MOUSE_POINTER_ID;
|
||||
if (typeof tempEvent.pressure === "undefined")
|
||||
tempEvent.pressure = 0.5;
|
||||
if (typeof tempEvent.twist === "undefined")
|
||||
tempEvent.twist = 0;
|
||||
if (typeof tempEvent.tangentialPressure === "undefined")
|
||||
tempEvent.tangentialPressure = 0;
|
||||
tempEvent.isNormalized = true;
|
||||
normalizedEvents.push(tempEvent);
|
||||
} else {
|
||||
normalizedEvents.push(event);
|
||||
}
|
||||
return normalizedEvents;
|
||||
}
|
||||
/**
|
||||
* Normalizes the native {@link https://w3c.github.io/uievents/#interface-wheelevent WheelEvent}.
|
||||
*
|
||||
* The returned {@link FederatedWheelEvent} is a shared instance. It will not persist across
|
||||
* multiple native wheel events.
|
||||
* @param nativeEvent - The native wheel event that occurred on the canvas.
|
||||
* @returns A federated wheel event.
|
||||
*/
|
||||
normalizeWheelEvent(nativeEvent) {
|
||||
const event = this._rootWheelEvent;
|
||||
this._transferMouseData(event, nativeEvent);
|
||||
event.deltaX = nativeEvent.deltaX;
|
||||
event.deltaY = nativeEvent.deltaY;
|
||||
event.deltaZ = nativeEvent.deltaZ;
|
||||
event.deltaMode = nativeEvent.deltaMode;
|
||||
this.mapPositionToPoint(event.screen, nativeEvent.clientX, nativeEvent.clientY);
|
||||
event.global.copyFrom(event.screen);
|
||||
event.offset.copyFrom(event.screen);
|
||||
event.nativeEvent = nativeEvent;
|
||||
event.type = nativeEvent.type;
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* Normalizes the `nativeEvent` into a federateed {@link FederatedPointerEvent}.
|
||||
* @param event
|
||||
* @param nativeEvent
|
||||
*/
|
||||
_bootstrapEvent(event, nativeEvent) {
|
||||
event.originalEvent = null;
|
||||
event.nativeEvent = nativeEvent;
|
||||
event.pointerId = nativeEvent.pointerId;
|
||||
event.width = nativeEvent.width;
|
||||
event.height = nativeEvent.height;
|
||||
event.isPrimary = nativeEvent.isPrimary;
|
||||
event.pointerType = nativeEvent.pointerType;
|
||||
event.pressure = nativeEvent.pressure;
|
||||
event.tangentialPressure = nativeEvent.tangentialPressure;
|
||||
event.tiltX = nativeEvent.tiltX;
|
||||
event.tiltY = nativeEvent.tiltY;
|
||||
event.twist = nativeEvent.twist;
|
||||
this._transferMouseData(event, nativeEvent);
|
||||
this.mapPositionToPoint(event.screen, nativeEvent.clientX, nativeEvent.clientY);
|
||||
event.global.copyFrom(event.screen);
|
||||
event.offset.copyFrom(event.screen);
|
||||
event.isTrusted = nativeEvent.isTrusted;
|
||||
if (event.type === "pointerleave") {
|
||||
event.type = "pointerout";
|
||||
}
|
||||
if (event.type.startsWith("mouse")) {
|
||||
event.type = event.type.replace("mouse", "pointer");
|
||||
}
|
||||
if (event.type.startsWith("touch")) {
|
||||
event.type = TOUCH_TO_POINTER[event.type] || event.type;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* Transfers base & mouse event data from the {@code nativeEvent} to the federated event.
|
||||
* @param event
|
||||
* @param nativeEvent
|
||||
*/
|
||||
_transferMouseData(event, nativeEvent) {
|
||||
event.isTrusted = nativeEvent.isTrusted;
|
||||
event.srcElement = nativeEvent.srcElement;
|
||||
event.timeStamp = performance.now();
|
||||
event.type = nativeEvent.type;
|
||||
event.altKey = nativeEvent.altKey;
|
||||
event.button = nativeEvent.button;
|
||||
event.buttons = nativeEvent.buttons;
|
||||
event.client.x = nativeEvent.clientX;
|
||||
event.client.y = nativeEvent.clientY;
|
||||
event.ctrlKey = nativeEvent.ctrlKey;
|
||||
event.metaKey = nativeEvent.metaKey;
|
||||
event.movement.x = nativeEvent.movementX;
|
||||
event.movement.y = nativeEvent.movementY;
|
||||
event.page.x = nativeEvent.pageX;
|
||||
event.page.y = nativeEvent.pageY;
|
||||
event.relatedTarget = null;
|
||||
event.shiftKey = nativeEvent.shiftKey;
|
||||
}
|
||||
};
|
||||
/** @ignore */
|
||||
_EventSystem.extension = {
|
||||
name: "events",
|
||||
type: [
|
||||
ExtensionType.WebGLSystem,
|
||||
ExtensionType.CanvasSystem,
|
||||
ExtensionType.WebGPUSystem
|
||||
],
|
||||
priority: -1
|
||||
};
|
||||
/**
|
||||
* The event features that are enabled by the EventSystem
|
||||
* (included in the **pixi.js** and **pixi.js-legacy** bundle), otherwise it will be ignored.
|
||||
* @since 7.2.0
|
||||
*/
|
||||
_EventSystem.defaultEventFeatures = {
|
||||
/** Enables pointer events associated with pointer movement. */
|
||||
move: true,
|
||||
/** Enables global pointer move events. */
|
||||
globalMove: true,
|
||||
/** Enables pointer events associated with clicking. */
|
||||
click: true,
|
||||
/** Enables wheel events. */
|
||||
wheel: true
|
||||
};
|
||||
let EventSystem = _EventSystem;
|
||||
|
||||
export { EventSystem };
|
||||
//# sourceMappingURL=EventSystem.mjs.map
|
1
node_modules/pixi.js/lib/events/EventSystem.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/EventSystem.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
47
node_modules/pixi.js/lib/events/EventTicker.d.ts
generated
vendored
Normal file
47
node_modules/pixi.js/lib/events/EventTicker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import type { EventSystem } from './EventSystem';
|
||||
/**
|
||||
* This class handles automatic firing of PointerEvents
|
||||
* in the case where the pointer is stationary for too long.
|
||||
* This is to ensure that hit-tests are still run on moving objects.
|
||||
* @since 7.2.0
|
||||
* @memberof events
|
||||
* @class EventsTicker
|
||||
*/
|
||||
declare class EventsTickerClass {
|
||||
/** The event system. */
|
||||
events: EventSystem;
|
||||
/** The DOM element to listen to events on. */
|
||||
domElement: HTMLElement;
|
||||
/** The frequency that fake events will be fired. */
|
||||
interactionFrequency: number;
|
||||
private _deltaTime;
|
||||
private _didMove;
|
||||
private _tickerAdded;
|
||||
private _pauseUpdate;
|
||||
/**
|
||||
* Initializes the event ticker.
|
||||
* @param events - The event system.
|
||||
*/
|
||||
init(events: EventSystem): void;
|
||||
/** Whether to pause the update checks or not. */
|
||||
get pauseUpdate(): boolean;
|
||||
set pauseUpdate(paused: boolean);
|
||||
/** Adds the ticker listener. */
|
||||
addTickerListener(): void;
|
||||
/** Removes the ticker listener. */
|
||||
removeTickerListener(): void;
|
||||
/** Sets flag to not fire extra events when the user has already moved there mouse */
|
||||
pointerMoved(): void;
|
||||
/** Updates the state of interactive objects. */
|
||||
private _update;
|
||||
/**
|
||||
* Updates the state of interactive objects if at least {@link interactionFrequency}
|
||||
* milliseconds have passed since the last invocation.
|
||||
*
|
||||
* Invoked by a throttled ticker update from {@link Ticker.system}.
|
||||
* @param ticker - The throttled ticker.
|
||||
*/
|
||||
private _tickerUpdate;
|
||||
}
|
||||
export declare const EventsTicker: EventsTickerClass;
|
||||
export {};
|
95
node_modules/pixi.js/lib/events/EventTicker.js
generated
vendored
Normal file
95
node_modules/pixi.js/lib/events/EventTicker.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
'use strict';
|
||||
|
||||
var _const = require('../ticker/const.js');
|
||||
var Ticker = require('../ticker/Ticker.js');
|
||||
|
||||
"use strict";
|
||||
class EventsTickerClass {
|
||||
constructor() {
|
||||
/** The frequency that fake events will be fired. */
|
||||
this.interactionFrequency = 10;
|
||||
this._deltaTime = 0;
|
||||
this._didMove = false;
|
||||
this._tickerAdded = false;
|
||||
this._pauseUpdate = true;
|
||||
}
|
||||
/**
|
||||
* Initializes the event ticker.
|
||||
* @param events - The event system.
|
||||
*/
|
||||
init(events) {
|
||||
this.removeTickerListener();
|
||||
this.events = events;
|
||||
this.interactionFrequency = 10;
|
||||
this._deltaTime = 0;
|
||||
this._didMove = false;
|
||||
this._tickerAdded = false;
|
||||
this._pauseUpdate = true;
|
||||
}
|
||||
/** Whether to pause the update checks or not. */
|
||||
get pauseUpdate() {
|
||||
return this._pauseUpdate;
|
||||
}
|
||||
set pauseUpdate(paused) {
|
||||
this._pauseUpdate = paused;
|
||||
}
|
||||
/** Adds the ticker listener. */
|
||||
addTickerListener() {
|
||||
if (this._tickerAdded || !this.domElement) {
|
||||
return;
|
||||
}
|
||||
Ticker.Ticker.system.add(this._tickerUpdate, this, _const.UPDATE_PRIORITY.INTERACTION);
|
||||
this._tickerAdded = true;
|
||||
}
|
||||
/** Removes the ticker listener. */
|
||||
removeTickerListener() {
|
||||
if (!this._tickerAdded) {
|
||||
return;
|
||||
}
|
||||
Ticker.Ticker.system.remove(this._tickerUpdate, this);
|
||||
this._tickerAdded = false;
|
||||
}
|
||||
/** Sets flag to not fire extra events when the user has already moved there mouse */
|
||||
pointerMoved() {
|
||||
this._didMove = true;
|
||||
}
|
||||
/** Updates the state of interactive objects. */
|
||||
_update() {
|
||||
if (!this.domElement || this._pauseUpdate) {
|
||||
return;
|
||||
}
|
||||
if (this._didMove) {
|
||||
this._didMove = false;
|
||||
return;
|
||||
}
|
||||
const rootPointerEvent = this.events["_rootPointerEvent"];
|
||||
if (this.events.supportsTouchEvents && rootPointerEvent.pointerType === "touch") {
|
||||
return;
|
||||
}
|
||||
globalThis.document.dispatchEvent(new PointerEvent("pointermove", {
|
||||
clientX: rootPointerEvent.clientX,
|
||||
clientY: rootPointerEvent.clientY,
|
||||
pointerType: rootPointerEvent.pointerType,
|
||||
pointerId: rootPointerEvent.pointerId
|
||||
}));
|
||||
}
|
||||
/**
|
||||
* Updates the state of interactive objects if at least {@link interactionFrequency}
|
||||
* milliseconds have passed since the last invocation.
|
||||
*
|
||||
* Invoked by a throttled ticker update from {@link Ticker.system}.
|
||||
* @param ticker - The throttled ticker.
|
||||
*/
|
||||
_tickerUpdate(ticker) {
|
||||
this._deltaTime += ticker.deltaTime;
|
||||
if (this._deltaTime < this.interactionFrequency) {
|
||||
return;
|
||||
}
|
||||
this._deltaTime = 0;
|
||||
this._update();
|
||||
}
|
||||
}
|
||||
const EventsTicker = new EventsTickerClass();
|
||||
|
||||
exports.EventsTicker = EventsTicker;
|
||||
//# sourceMappingURL=EventTicker.js.map
|
1
node_modules/pixi.js/lib/events/EventTicker.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/EventTicker.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
93
node_modules/pixi.js/lib/events/EventTicker.mjs
generated
vendored
Normal file
93
node_modules/pixi.js/lib/events/EventTicker.mjs
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
import { UPDATE_PRIORITY } from '../ticker/const.mjs';
|
||||
import { Ticker } from '../ticker/Ticker.mjs';
|
||||
|
||||
"use strict";
|
||||
class EventsTickerClass {
|
||||
constructor() {
|
||||
/** The frequency that fake events will be fired. */
|
||||
this.interactionFrequency = 10;
|
||||
this._deltaTime = 0;
|
||||
this._didMove = false;
|
||||
this._tickerAdded = false;
|
||||
this._pauseUpdate = true;
|
||||
}
|
||||
/**
|
||||
* Initializes the event ticker.
|
||||
* @param events - The event system.
|
||||
*/
|
||||
init(events) {
|
||||
this.removeTickerListener();
|
||||
this.events = events;
|
||||
this.interactionFrequency = 10;
|
||||
this._deltaTime = 0;
|
||||
this._didMove = false;
|
||||
this._tickerAdded = false;
|
||||
this._pauseUpdate = true;
|
||||
}
|
||||
/** Whether to pause the update checks or not. */
|
||||
get pauseUpdate() {
|
||||
return this._pauseUpdate;
|
||||
}
|
||||
set pauseUpdate(paused) {
|
||||
this._pauseUpdate = paused;
|
||||
}
|
||||
/** Adds the ticker listener. */
|
||||
addTickerListener() {
|
||||
if (this._tickerAdded || !this.domElement) {
|
||||
return;
|
||||
}
|
||||
Ticker.system.add(this._tickerUpdate, this, UPDATE_PRIORITY.INTERACTION);
|
||||
this._tickerAdded = true;
|
||||
}
|
||||
/** Removes the ticker listener. */
|
||||
removeTickerListener() {
|
||||
if (!this._tickerAdded) {
|
||||
return;
|
||||
}
|
||||
Ticker.system.remove(this._tickerUpdate, this);
|
||||
this._tickerAdded = false;
|
||||
}
|
||||
/** Sets flag to not fire extra events when the user has already moved there mouse */
|
||||
pointerMoved() {
|
||||
this._didMove = true;
|
||||
}
|
||||
/** Updates the state of interactive objects. */
|
||||
_update() {
|
||||
if (!this.domElement || this._pauseUpdate) {
|
||||
return;
|
||||
}
|
||||
if (this._didMove) {
|
||||
this._didMove = false;
|
||||
return;
|
||||
}
|
||||
const rootPointerEvent = this.events["_rootPointerEvent"];
|
||||
if (this.events.supportsTouchEvents && rootPointerEvent.pointerType === "touch") {
|
||||
return;
|
||||
}
|
||||
globalThis.document.dispatchEvent(new PointerEvent("pointermove", {
|
||||
clientX: rootPointerEvent.clientX,
|
||||
clientY: rootPointerEvent.clientY,
|
||||
pointerType: rootPointerEvent.pointerType,
|
||||
pointerId: rootPointerEvent.pointerId
|
||||
}));
|
||||
}
|
||||
/**
|
||||
* Updates the state of interactive objects if at least {@link interactionFrequency}
|
||||
* milliseconds have passed since the last invocation.
|
||||
*
|
||||
* Invoked by a throttled ticker update from {@link Ticker.system}.
|
||||
* @param ticker - The throttled ticker.
|
||||
*/
|
||||
_tickerUpdate(ticker) {
|
||||
this._deltaTime += ticker.deltaTime;
|
||||
if (this._deltaTime < this.interactionFrequency) {
|
||||
return;
|
||||
}
|
||||
this._deltaTime = 0;
|
||||
this._update();
|
||||
}
|
||||
}
|
||||
const EventsTicker = new EventsTickerClass();
|
||||
|
||||
export { EventsTicker };
|
||||
//# sourceMappingURL=EventTicker.mjs.map
|
1
node_modules/pixi.js/lib/events/EventTicker.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/EventTicker.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
37
node_modules/pixi.js/lib/events/EventsMixins.d.ts
generated
vendored
Normal file
37
node_modules/pixi.js/lib/events/EventsMixins.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import type { FederatedEventEmitterTypes } from './FederatedEventMap';
|
||||
import type { FederatedOptions, IFederatedContainer } from './FederatedEventTarget';
|
||||
|
||||
declare global
|
||||
{
|
||||
namespace PixiMixins
|
||||
{
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
interface Container extends IFederatedContainer {}
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
interface ContainerOptions extends FederatedOptions {}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
interface ContainerEvents extends FederatedEventEmitterTypes {}
|
||||
|
||||
interface RendererOptions
|
||||
{
|
||||
/**
|
||||
* The default event mode for all display objects.
|
||||
* @since 7.2.0
|
||||
*/
|
||||
eventMode?: import('./FederatedEventTarget').EventMode;
|
||||
/**
|
||||
* The event features that are enabled by the EventSystem.
|
||||
* @since 7.2.0
|
||||
*/
|
||||
eventFeatures?: import('./EventSystem').EventSystemOptions['eventFeatures'];
|
||||
}
|
||||
|
||||
interface RendererSystems
|
||||
{
|
||||
events: import('./EventSystem').EventSystem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
151
node_modules/pixi.js/lib/events/FederatedEvent.d.ts
generated
vendored
Normal file
151
node_modules/pixi.js/lib/events/FederatedEvent.d.ts
generated
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
import { Point } from '../maths/point/Point';
|
||||
import type { Container } from '../scene/container/Container';
|
||||
import type { EventBoundary } from './EventBoundary';
|
||||
/**
|
||||
* A PixiJS compatible {@code Touch} event.
|
||||
* @memberof events
|
||||
*/
|
||||
export interface PixiTouch extends Touch {
|
||||
button: number;
|
||||
buttons: number;
|
||||
isPrimary: boolean;
|
||||
width: number;
|
||||
height: number;
|
||||
tiltX: number;
|
||||
tiltY: number;
|
||||
pointerType: string;
|
||||
pointerId: number;
|
||||
pressure: number;
|
||||
twist: number;
|
||||
tangentialPressure: number;
|
||||
layerX: number;
|
||||
layerY: number;
|
||||
offsetX: number;
|
||||
offsetY: number;
|
||||
isNormalized: boolean;
|
||||
type: string;
|
||||
}
|
||||
/**
|
||||
* An DOM-compatible synthetic event implementation that is "forwarded" on behalf of an original
|
||||
* FederatedEvent or native {@link https://dom.spec.whatwg.org/#event Event}.
|
||||
* @typeParam N - The type of native event held.
|
||||
* @memberof events
|
||||
*/
|
||||
export declare class FederatedEvent<N extends UIEvent | PixiTouch = UIEvent | PixiTouch> implements UIEvent {
|
||||
/** Flags whether this event bubbles. This will take effect only if it is set before propagation. */
|
||||
bubbles: boolean;
|
||||
/** @deprecated since 7.0.0 */
|
||||
cancelBubble: boolean;
|
||||
/**
|
||||
* Flags whether this event can be canceled using {@link FederatedEvent.preventDefault}. This is always
|
||||
* false (for now).
|
||||
*/
|
||||
readonly cancelable = false;
|
||||
/**
|
||||
* Flag added for compatibility with DOM {@code Event}. It is not used in the Federated Events
|
||||
* API.
|
||||
* @see https://dom.spec.whatwg.org/#dom-event-composed
|
||||
*/
|
||||
readonly composed = false;
|
||||
/** The listeners of the event target that are being notified. */
|
||||
currentTarget: Container;
|
||||
/** Flags whether the default response of the user agent was prevent through this event. */
|
||||
defaultPrevented: boolean;
|
||||
/**
|
||||
* The propagation phase.
|
||||
* @default {@link FederatedEvent.NONE}
|
||||
*/
|
||||
eventPhase: number;
|
||||
/** Flags whether this is a user-trusted event */
|
||||
isTrusted: boolean;
|
||||
/** @deprecated since 7.0.0 */
|
||||
returnValue: boolean;
|
||||
/** @deprecated since 7.0.0 */
|
||||
srcElement: EventTarget;
|
||||
/** The event target that this will be dispatched to. */
|
||||
target: Container;
|
||||
/** The timestamp of when the event was created. */
|
||||
timeStamp: number;
|
||||
/** The type of event, e.g. {@code "mouseup"}. */
|
||||
type: string;
|
||||
/** The native event that caused the foremost original event. */
|
||||
nativeEvent: N;
|
||||
/** The original event that caused this event, if any. */
|
||||
originalEvent: FederatedEvent<N>;
|
||||
/** Flags whether propagation was stopped. */
|
||||
propagationStopped: boolean;
|
||||
/** Flags whether propagation was immediately stopped. */
|
||||
propagationImmediatelyStopped: boolean;
|
||||
/** The composed path of the event's propagation. The {@code target} is at the end. */
|
||||
path: Container[];
|
||||
/** The {@link EventBoundary} that manages this event. Null for root events. */
|
||||
readonly manager: EventBoundary;
|
||||
/** Event-specific detail */
|
||||
detail: number;
|
||||
/** The global Window object. */
|
||||
view: WindowProxy;
|
||||
/**
|
||||
* Not supported.
|
||||
* @deprecated since 7.0.0
|
||||
*/
|
||||
which: number;
|
||||
/** The coordinates of the event relative to the nearest DOM layer. This is a non-standard property. */
|
||||
layer: Point;
|
||||
/** @readonly */
|
||||
get layerX(): number;
|
||||
/** @readonly */
|
||||
get layerY(): number;
|
||||
/** The coordinates of the event relative to the DOM document. This is a non-standard property. */
|
||||
page: Point;
|
||||
/** @readonly */
|
||||
get pageX(): number;
|
||||
/** @readonly */
|
||||
get pageY(): number;
|
||||
/**
|
||||
* @param manager - The event boundary which manages this event. Propagation can only occur
|
||||
* within the boundary's jurisdiction.
|
||||
*/
|
||||
constructor(manager: EventBoundary);
|
||||
/**
|
||||
* Fallback for the deprecated @code{InteractionEvent.data}.
|
||||
* @deprecated since 7.0.0
|
||||
*/
|
||||
get data(): this;
|
||||
/** The propagation path for this event. Alias for {@link EventBoundary.propagationPath}. */
|
||||
composedPath(): Container[];
|
||||
/**
|
||||
* Unimplemented method included for implementing the DOM interface {@code Event}. It will throw an {@code Error}.
|
||||
* @deprecated
|
||||
* @param _type
|
||||
* @param _bubbles
|
||||
* @param _cancelable
|
||||
*/
|
||||
initEvent(_type: string, _bubbles?: boolean, _cancelable?: boolean): void;
|
||||
/**
|
||||
* Unimplemented method included for implementing the DOM interface {@code UIEvent}. It will throw an {@code Error}.
|
||||
* @deprecated
|
||||
* @param _typeArg
|
||||
* @param _bubblesArg
|
||||
* @param _cancelableArg
|
||||
* @param _viewArg
|
||||
* @param _detailArg
|
||||
*/
|
||||
initUIEvent(_typeArg: string, _bubblesArg?: boolean, _cancelableArg?: boolean, _viewArg?: Window | null, _detailArg?: number): void;
|
||||
/** Prevent default behavior of PixiJS and the user agent. */
|
||||
preventDefault(): void;
|
||||
/**
|
||||
* Stop this event from propagating to any addition listeners, including on the
|
||||
* {@link FederatedEventTarget.currentTarget currentTarget} and also the following
|
||||
* event targets on the propagation path.
|
||||
*/
|
||||
stopImmediatePropagation(): void;
|
||||
/**
|
||||
* Stop this event from propagating to the next {@link FederatedEventTarget}. The rest of the listeners
|
||||
* on the {@link FederatedEventTarget.currentTarget currentTarget} will still be notified.
|
||||
*/
|
||||
stopPropagation(): void;
|
||||
readonly NONE = 0;
|
||||
readonly CAPTURING_PHASE = 1;
|
||||
readonly AT_TARGET = 2;
|
||||
readonly BUBBLING_PHASE = 3;
|
||||
}
|
125
node_modules/pixi.js/lib/events/FederatedEvent.js
generated
vendored
Normal file
125
node_modules/pixi.js/lib/events/FederatedEvent.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
'use strict';
|
||||
|
||||
var Point = require('../maths/point/Point.js');
|
||||
|
||||
"use strict";
|
||||
class FederatedEvent {
|
||||
/**
|
||||
* @param manager - The event boundary which manages this event. Propagation can only occur
|
||||
* within the boundary's jurisdiction.
|
||||
*/
|
||||
constructor(manager) {
|
||||
/** Flags whether this event bubbles. This will take effect only if it is set before propagation. */
|
||||
this.bubbles = true;
|
||||
/** @deprecated since 7.0.0 */
|
||||
this.cancelBubble = true;
|
||||
/**
|
||||
* Flags whether this event can be canceled using {@link FederatedEvent.preventDefault}. This is always
|
||||
* false (for now).
|
||||
*/
|
||||
this.cancelable = false;
|
||||
/**
|
||||
* Flag added for compatibility with DOM {@code Event}. It is not used in the Federated Events
|
||||
* API.
|
||||
* @see https://dom.spec.whatwg.org/#dom-event-composed
|
||||
*/
|
||||
this.composed = false;
|
||||
/** Flags whether the default response of the user agent was prevent through this event. */
|
||||
this.defaultPrevented = false;
|
||||
/**
|
||||
* The propagation phase.
|
||||
* @default {@link FederatedEvent.NONE}
|
||||
*/
|
||||
this.eventPhase = FederatedEvent.prototype.NONE;
|
||||
/** Flags whether propagation was stopped. */
|
||||
this.propagationStopped = false;
|
||||
/** Flags whether propagation was immediately stopped. */
|
||||
this.propagationImmediatelyStopped = false;
|
||||
/** The coordinates of the event relative to the nearest DOM layer. This is a non-standard property. */
|
||||
this.layer = new Point.Point();
|
||||
/** The coordinates of the event relative to the DOM document. This is a non-standard property. */
|
||||
this.page = new Point.Point();
|
||||
this.NONE = 0;
|
||||
this.CAPTURING_PHASE = 1;
|
||||
this.AT_TARGET = 2;
|
||||
this.BUBBLING_PHASE = 3;
|
||||
this.manager = manager;
|
||||
}
|
||||
/** @readonly */
|
||||
get layerX() {
|
||||
return this.layer.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get layerY() {
|
||||
return this.layer.y;
|
||||
}
|
||||
/** @readonly */
|
||||
get pageX() {
|
||||
return this.page.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get pageY() {
|
||||
return this.page.y;
|
||||
}
|
||||
/**
|
||||
* Fallback for the deprecated @code{InteractionEvent.data}.
|
||||
* @deprecated since 7.0.0
|
||||
*/
|
||||
get data() {
|
||||
return this;
|
||||
}
|
||||
/** The propagation path for this event. Alias for {@link EventBoundary.propagationPath}. */
|
||||
composedPath() {
|
||||
if (this.manager && (!this.path || this.path[this.path.length - 1] !== this.target)) {
|
||||
this.path = this.target ? this.manager.propagationPath(this.target) : [];
|
||||
}
|
||||
return this.path;
|
||||
}
|
||||
/**
|
||||
* Unimplemented method included for implementing the DOM interface {@code Event}. It will throw an {@code Error}.
|
||||
* @deprecated
|
||||
* @param _type
|
||||
* @param _bubbles
|
||||
* @param _cancelable
|
||||
*/
|
||||
initEvent(_type, _bubbles, _cancelable) {
|
||||
throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.");
|
||||
}
|
||||
/**
|
||||
* Unimplemented method included for implementing the DOM interface {@code UIEvent}. It will throw an {@code Error}.
|
||||
* @deprecated
|
||||
* @param _typeArg
|
||||
* @param _bubblesArg
|
||||
* @param _cancelableArg
|
||||
* @param _viewArg
|
||||
* @param _detailArg
|
||||
*/
|
||||
initUIEvent(_typeArg, _bubblesArg, _cancelableArg, _viewArg, _detailArg) {
|
||||
throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.");
|
||||
}
|
||||
/** Prevent default behavior of PixiJS and the user agent. */
|
||||
preventDefault() {
|
||||
if (this.nativeEvent instanceof Event && this.nativeEvent.cancelable) {
|
||||
this.nativeEvent.preventDefault();
|
||||
}
|
||||
this.defaultPrevented = true;
|
||||
}
|
||||
/**
|
||||
* Stop this event from propagating to any addition listeners, including on the
|
||||
* {@link FederatedEventTarget.currentTarget currentTarget} and also the following
|
||||
* event targets on the propagation path.
|
||||
*/
|
||||
stopImmediatePropagation() {
|
||||
this.propagationImmediatelyStopped = true;
|
||||
}
|
||||
/**
|
||||
* Stop this event from propagating to the next {@link FederatedEventTarget}. The rest of the listeners
|
||||
* on the {@link FederatedEventTarget.currentTarget currentTarget} will still be notified.
|
||||
*/
|
||||
stopPropagation() {
|
||||
this.propagationStopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
exports.FederatedEvent = FederatedEvent;
|
||||
//# sourceMappingURL=FederatedEvent.js.map
|
1
node_modules/pixi.js/lib/events/FederatedEvent.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedEvent.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
123
node_modules/pixi.js/lib/events/FederatedEvent.mjs
generated
vendored
Normal file
123
node_modules/pixi.js/lib/events/FederatedEvent.mjs
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
import { Point } from '../maths/point/Point.mjs';
|
||||
|
||||
"use strict";
|
||||
class FederatedEvent {
|
||||
/**
|
||||
* @param manager - The event boundary which manages this event. Propagation can only occur
|
||||
* within the boundary's jurisdiction.
|
||||
*/
|
||||
constructor(manager) {
|
||||
/** Flags whether this event bubbles. This will take effect only if it is set before propagation. */
|
||||
this.bubbles = true;
|
||||
/** @deprecated since 7.0.0 */
|
||||
this.cancelBubble = true;
|
||||
/**
|
||||
* Flags whether this event can be canceled using {@link FederatedEvent.preventDefault}. This is always
|
||||
* false (for now).
|
||||
*/
|
||||
this.cancelable = false;
|
||||
/**
|
||||
* Flag added for compatibility with DOM {@code Event}. It is not used in the Federated Events
|
||||
* API.
|
||||
* @see https://dom.spec.whatwg.org/#dom-event-composed
|
||||
*/
|
||||
this.composed = false;
|
||||
/** Flags whether the default response of the user agent was prevent through this event. */
|
||||
this.defaultPrevented = false;
|
||||
/**
|
||||
* The propagation phase.
|
||||
* @default {@link FederatedEvent.NONE}
|
||||
*/
|
||||
this.eventPhase = FederatedEvent.prototype.NONE;
|
||||
/** Flags whether propagation was stopped. */
|
||||
this.propagationStopped = false;
|
||||
/** Flags whether propagation was immediately stopped. */
|
||||
this.propagationImmediatelyStopped = false;
|
||||
/** The coordinates of the event relative to the nearest DOM layer. This is a non-standard property. */
|
||||
this.layer = new Point();
|
||||
/** The coordinates of the event relative to the DOM document. This is a non-standard property. */
|
||||
this.page = new Point();
|
||||
this.NONE = 0;
|
||||
this.CAPTURING_PHASE = 1;
|
||||
this.AT_TARGET = 2;
|
||||
this.BUBBLING_PHASE = 3;
|
||||
this.manager = manager;
|
||||
}
|
||||
/** @readonly */
|
||||
get layerX() {
|
||||
return this.layer.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get layerY() {
|
||||
return this.layer.y;
|
||||
}
|
||||
/** @readonly */
|
||||
get pageX() {
|
||||
return this.page.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get pageY() {
|
||||
return this.page.y;
|
||||
}
|
||||
/**
|
||||
* Fallback for the deprecated @code{InteractionEvent.data}.
|
||||
* @deprecated since 7.0.0
|
||||
*/
|
||||
get data() {
|
||||
return this;
|
||||
}
|
||||
/** The propagation path for this event. Alias for {@link EventBoundary.propagationPath}. */
|
||||
composedPath() {
|
||||
if (this.manager && (!this.path || this.path[this.path.length - 1] !== this.target)) {
|
||||
this.path = this.target ? this.manager.propagationPath(this.target) : [];
|
||||
}
|
||||
return this.path;
|
||||
}
|
||||
/**
|
||||
* Unimplemented method included for implementing the DOM interface {@code Event}. It will throw an {@code Error}.
|
||||
* @deprecated
|
||||
* @param _type
|
||||
* @param _bubbles
|
||||
* @param _cancelable
|
||||
*/
|
||||
initEvent(_type, _bubbles, _cancelable) {
|
||||
throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.");
|
||||
}
|
||||
/**
|
||||
* Unimplemented method included for implementing the DOM interface {@code UIEvent}. It will throw an {@code Error}.
|
||||
* @deprecated
|
||||
* @param _typeArg
|
||||
* @param _bubblesArg
|
||||
* @param _cancelableArg
|
||||
* @param _viewArg
|
||||
* @param _detailArg
|
||||
*/
|
||||
initUIEvent(_typeArg, _bubblesArg, _cancelableArg, _viewArg, _detailArg) {
|
||||
throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.");
|
||||
}
|
||||
/** Prevent default behavior of PixiJS and the user agent. */
|
||||
preventDefault() {
|
||||
if (this.nativeEvent instanceof Event && this.nativeEvent.cancelable) {
|
||||
this.nativeEvent.preventDefault();
|
||||
}
|
||||
this.defaultPrevented = true;
|
||||
}
|
||||
/**
|
||||
* Stop this event from propagating to any addition listeners, including on the
|
||||
* {@link FederatedEventTarget.currentTarget currentTarget} and also the following
|
||||
* event targets on the propagation path.
|
||||
*/
|
||||
stopImmediatePropagation() {
|
||||
this.propagationImmediatelyStopped = true;
|
||||
}
|
||||
/**
|
||||
* Stop this event from propagating to the next {@link FederatedEventTarget}. The rest of the listeners
|
||||
* on the {@link FederatedEventTarget.currentTarget currentTarget} will still be notified.
|
||||
*/
|
||||
stopPropagation() {
|
||||
this.propagationStopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
export { FederatedEvent };
|
||||
//# sourceMappingURL=FederatedEvent.mjs.map
|
1
node_modules/pixi.js/lib/events/FederatedEvent.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedEvent.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
45
node_modules/pixi.js/lib/events/FederatedEventMap.d.ts
generated
vendored
Normal file
45
node_modules/pixi.js/lib/events/FederatedEventMap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { FederatedPointerEvent } from './FederatedPointerEvent';
|
||||
import type { FederatedWheelEvent } from './FederatedWheelEvent';
|
||||
export type FederatedEventMap = {
|
||||
click: FederatedPointerEvent;
|
||||
mousedown: FederatedPointerEvent;
|
||||
mouseenter: FederatedPointerEvent;
|
||||
mouseleave: FederatedPointerEvent;
|
||||
mousemove: FederatedPointerEvent;
|
||||
mouseout: FederatedPointerEvent;
|
||||
mouseover: FederatedPointerEvent;
|
||||
mouseup: FederatedPointerEvent;
|
||||
mouseupoutside: FederatedPointerEvent;
|
||||
pointercancel: FederatedPointerEvent;
|
||||
pointerdown: FederatedPointerEvent;
|
||||
pointerenter: FederatedPointerEvent;
|
||||
pointerleave: FederatedPointerEvent;
|
||||
pointermove: FederatedPointerEvent;
|
||||
pointerout: FederatedPointerEvent;
|
||||
pointerover: FederatedPointerEvent;
|
||||
pointertap: FederatedPointerEvent;
|
||||
pointerup: FederatedPointerEvent;
|
||||
pointerupoutside: FederatedPointerEvent;
|
||||
rightclick: FederatedPointerEvent;
|
||||
rightdown: FederatedPointerEvent;
|
||||
rightup: FederatedPointerEvent;
|
||||
rightupoutside: FederatedPointerEvent;
|
||||
tap: FederatedPointerEvent;
|
||||
touchcancel: FederatedPointerEvent;
|
||||
touchend: FederatedPointerEvent;
|
||||
touchendoutside: FederatedPointerEvent;
|
||||
touchmove: FederatedPointerEvent;
|
||||
touchstart: FederatedPointerEvent;
|
||||
wheel: FederatedWheelEvent;
|
||||
};
|
||||
export type GlobalFederatedEventMap = {
|
||||
globalmousemove: FederatedPointerEvent;
|
||||
globalpointermove: FederatedPointerEvent;
|
||||
globaltouchmove: FederatedPointerEvent;
|
||||
};
|
||||
export type AllFederatedEventMap = FederatedEventMap & GlobalFederatedEventMap;
|
||||
export type FederatedEventEmitterTypes = {
|
||||
[K in keyof FederatedEventMap as K | `${K}capture`]: [event: FederatedEventMap[K]];
|
||||
} & {
|
||||
[K in keyof GlobalFederatedEventMap]: [event: GlobalFederatedEventMap[K]];
|
||||
};
|
4
node_modules/pixi.js/lib/events/FederatedEventMap.js
generated
vendored
Normal file
4
node_modules/pixi.js/lib/events/FederatedEventMap.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
"use strict";
|
||||
//# sourceMappingURL=FederatedEventMap.js.map
|
1
node_modules/pixi.js/lib/events/FederatedEventMap.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedEventMap.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FederatedEventMap.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
2
node_modules/pixi.js/lib/events/FederatedEventMap.mjs
generated
vendored
Normal file
2
node_modules/pixi.js/lib/events/FederatedEventMap.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=FederatedEventMap.mjs.map
|
1
node_modules/pixi.js/lib/events/FederatedEventMap.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedEventMap.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FederatedEventMap.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
154
node_modules/pixi.js/lib/events/FederatedEventTarget.d.ts
generated
vendored
Normal file
154
node_modules/pixi.js/lib/events/FederatedEventTarget.d.ts
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
import { FederatedEvent } from './FederatedEvent';
|
||||
import type { Container } from '../scene/container/Container';
|
||||
import type { AllFederatedEventMap } from './FederatedEventMap';
|
||||
import type { FederatedPointerEvent } from './FederatedPointerEvent';
|
||||
import type { FederatedWheelEvent } from './FederatedWheelEvent';
|
||||
/**
|
||||
* The type of cursor to use when the mouse pointer is hovering over.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
|
||||
*
|
||||
* Can be any valid CSS cursor value:
|
||||
* `auto`, `default`, `none`, `context-menu`, `help`, `pointer`, `progress`,
|
||||
* `wait`, `cell`, `crosshair`, `text`, `verticaltext`, `alias`, `copy`, `move`,
|
||||
* `nodrop`, `notallowed`, `eresize`, `nresize`, `neresize`, `nwresize`, `sresize`,
|
||||
* `seresize`, `swresize`, `wresize`, `nsresize`, `ewresize`, `neswresize`, `colresize`,
|
||||
* `nwseresize`, `rowresize`, `allscroll`, `zoomin`, `zoomout`, `grab`, `grabbing`
|
||||
* @memberof events
|
||||
*/
|
||||
export type Cursor = 'auto' | 'default' | 'none' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'alias' | 'copy' | 'move' | 'no-drop' | 'not-allowed' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ns-resize' | 'ew-resize' | 'nesw-resize' | 'col-resize' | 'nwse-resize' | 'row-resize' | 'all-scroll' | 'zoom-in' | 'zoom-out' | 'grab' | 'grabbing';
|
||||
/**
|
||||
* The hit area specifies the area for which pointer events should be captured by this event target.
|
||||
* @memberof events
|
||||
*/
|
||||
export interface IHitArea {
|
||||
/**
|
||||
* Checks if the x and y coordinates given are contained within this hit area.
|
||||
* @returns Whether the x and y coordinates are contained within this hit area.
|
||||
*/
|
||||
contains(x: number, y: number): boolean;
|
||||
}
|
||||
/**
|
||||
* Function type for handlers, e.g., onclick
|
||||
* @memberof events
|
||||
*/
|
||||
export type FederatedEventHandler<T = FederatedPointerEvent> = (event: T) => void;
|
||||
/**
|
||||
* The type of interaction a Container can be.
|
||||
* This is the {@link scene.Container#eventMode|Container.eventMode} property of any {@link scene.Container}.
|
||||
*
|
||||
* Can be one of the following:
|
||||
* - `'none'`: Ignores all interaction events, even on its children.
|
||||
* - `'passive'`: **(default)** Does not emit events and ignores all hit testing on itself and non-interactive children.
|
||||
* Interactive children will still emit events.
|
||||
* - `'auto'`: Does not emit events but is hit tested if parent is interactive. Same as `interactive = false` in v7
|
||||
* - `'static'`: Emit events and is hit tested. Same as `interaction = true` in v7
|
||||
* - `'dynamic'`: Emits events and is hit tested but will also receive mock interaction events fired from a ticker to
|
||||
* allow for interaction when the mouse isn't moving
|
||||
*
|
||||
* `none` and `passive` are useful for optimizing interaction events on objects as it reduces the number of hit tests
|
||||
* PixiJS has to do. `auto` is useful for when you want to recreate how the DOM handles interaction events with
|
||||
* `pointer-events: auto`.
|
||||
* @since 7.2.0
|
||||
* @memberof events
|
||||
*/
|
||||
export type EventMode = 'none' | 'passive' | 'auto' | 'static' | 'dynamic';
|
||||
/**
|
||||
* The properties available for any interactive object.
|
||||
* @memberof events
|
||||
*/
|
||||
export interface FederatedOptions {
|
||||
/** The cursor preferred when the mouse pointer is hovering over. */
|
||||
cursor?: Cursor | string;
|
||||
/** The mode of interaction for this object */
|
||||
eventMode?: EventMode;
|
||||
/** Whether this event target should fire UI events. */
|
||||
interactive?: boolean;
|
||||
/** Whether this event target has any children that need UI events. This can be used optimize event propagation. */
|
||||
interactiveChildren?: boolean;
|
||||
/** The hit-area specifies the area for which pointer events should be captured by this event target. */
|
||||
hitArea?: IHitArea | null;
|
||||
/** Handler for 'click' event */
|
||||
onclick?: FederatedEventHandler | null;
|
||||
/** Handler for 'mousedown' event */
|
||||
onmousedown?: FederatedEventHandler | null;
|
||||
/** Handler for 'mouseenter' event */
|
||||
onmouseenter?: FederatedEventHandler | null;
|
||||
/** Handler for 'mouseleave' event */
|
||||
onmouseleave?: FederatedEventHandler | null;
|
||||
/** Handler for 'mousemove' event */
|
||||
onmousemove?: FederatedEventHandler | null;
|
||||
/** Handler for 'globalmousemove' event */
|
||||
onglobalmousemove?: FederatedEventHandler | null;
|
||||
/** Handler for 'mouseout' event */
|
||||
onmouseout?: FederatedEventHandler | null;
|
||||
/** Handler for 'mouseover' event */
|
||||
onmouseover?: FederatedEventHandler | null;
|
||||
/** Handler for 'mouseup' event */
|
||||
onmouseup?: FederatedEventHandler | null;
|
||||
/** Handler for 'mouseupoutside' event */
|
||||
onmouseupoutside?: FederatedEventHandler | null;
|
||||
/** Handler for 'pointercancel' event */
|
||||
onpointercancel?: FederatedEventHandler | null;
|
||||
/** Handler for 'pointerdown' event */
|
||||
onpointerdown?: FederatedEventHandler | null;
|
||||
/** Handler for 'pointerenter' event */
|
||||
onpointerenter?: FederatedEventHandler | null;
|
||||
/** Handler for 'pointerleave' event */
|
||||
onpointerleave?: FederatedEventHandler | null;
|
||||
/** Handler for 'pointermove' event */
|
||||
onpointermove?: FederatedEventHandler | null;
|
||||
/** Handler for 'globalpointermove' event */
|
||||
onglobalpointermove?: FederatedEventHandler | null;
|
||||
/** Handler for 'pointerout' event */
|
||||
onpointerout?: FederatedEventHandler | null;
|
||||
/** Handler for 'pointerover' event */
|
||||
onpointerover?: FederatedEventHandler | null;
|
||||
/** Handler for 'pointertap' event */
|
||||
onpointertap?: FederatedEventHandler | null;
|
||||
/** Handler for 'pointerup' event */
|
||||
onpointerup?: FederatedEventHandler | null;
|
||||
/** Handler for 'pointerupoutside' event */
|
||||
onpointerupoutside?: FederatedEventHandler | null;
|
||||
/** Handler for 'rightclick' event */
|
||||
onrightclick?: FederatedEventHandler | null;
|
||||
/** Handler for 'rightdown' event */
|
||||
onrightdown?: FederatedEventHandler | null;
|
||||
/** Handler for 'rightup' event */
|
||||
onrightup?: FederatedEventHandler | null;
|
||||
/** Handler for 'rightupoutside' event */
|
||||
onrightupoutside?: FederatedEventHandler | null;
|
||||
/** Handler for 'tap' event */
|
||||
ontap?: FederatedEventHandler | null;
|
||||
/** Handler for 'touchcancel' event */
|
||||
ontouchcancel?: FederatedEventHandler | null;
|
||||
/** Handler for 'touchend' event */
|
||||
ontouchend?: FederatedEventHandler | null;
|
||||
/** Handler for 'touchendoutside' event */
|
||||
ontouchendoutside?: FederatedEventHandler | null;
|
||||
/** Handler for 'touchmove' event */
|
||||
ontouchmove?: FederatedEventHandler | null;
|
||||
/** Handler for 'globaltouchmove' event */
|
||||
onglobaltouchmove?: FederatedEventHandler | null;
|
||||
/** Handler for 'touchstart' event */
|
||||
ontouchstart?: FederatedEventHandler | null;
|
||||
/** Handler for 'wheel' event */
|
||||
onwheel?: FederatedEventHandler<FederatedWheelEvent> | null;
|
||||
}
|
||||
type AddListenerOptions = boolean | AddEventListenerOptions;
|
||||
type RemoveListenerOptions = boolean | EventListenerOptions;
|
||||
export interface IFederatedContainer extends FederatedOptions {
|
||||
/** The parent of this event target. */
|
||||
readonly parent?: Container;
|
||||
/** The children of this event target. */
|
||||
readonly children?: ReadonlyArray<Container>;
|
||||
_internalEventMode: EventMode;
|
||||
/** Returns true if the Container has interactive 'static' or 'dynamic' */
|
||||
isInteractive: () => boolean;
|
||||
addEventListener<K extends keyof AllFederatedEventMap>(type: K, listener: (e: AllFederatedEventMap[K]) => any, options?: AddListenerOptions): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: AddListenerOptions): void;
|
||||
removeEventListener<K extends keyof AllFederatedEventMap>(type: K, listener: (e: AllFederatedEventMap[K]) => any, options?: RemoveListenerOptions): void;
|
||||
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: RemoveListenerOptions): void;
|
||||
dispatchEvent(e: FederatedEvent): boolean;
|
||||
}
|
||||
export declare const FederatedContainer: IFederatedContainer;
|
||||
export {};
|
515
node_modules/pixi.js/lib/events/FederatedEventTarget.js
generated
vendored
Normal file
515
node_modules/pixi.js/lib/events/FederatedEventTarget.js
generated
vendored
Normal file
@@ -0,0 +1,515 @@
|
||||
'use strict';
|
||||
|
||||
var EventSystem = require('./EventSystem.js');
|
||||
var FederatedEvent = require('./FederatedEvent.js');
|
||||
|
||||
"use strict";
|
||||
const FederatedContainer = {
|
||||
/**
|
||||
* Property-based event handler for the `click` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onclick = (event) => {
|
||||
* //some function here that happens on click
|
||||
* }
|
||||
*/
|
||||
onclick: null,
|
||||
/**
|
||||
* Property-based event handler for the `mousedown` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmousedown = (event) => {
|
||||
* //some function here that happens on mousedown
|
||||
* }
|
||||
*/
|
||||
onmousedown: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseenter` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseenter = (event) => {
|
||||
* //some function here that happens on mouseenter
|
||||
* }
|
||||
*/
|
||||
onmouseenter: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseleave` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseleave = (event) => {
|
||||
* //some function here that happens on mouseleave
|
||||
* }
|
||||
*/
|
||||
onmouseleave: null,
|
||||
/**
|
||||
* Property-based event handler for the `mousemove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmousemove = (event) => {
|
||||
* //some function here that happens on mousemove
|
||||
* }
|
||||
*/
|
||||
onmousemove: null,
|
||||
/**
|
||||
* Property-based event handler for the `globalmousemove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onglobalmousemove = (event) => {
|
||||
* //some function here that happens on globalmousemove
|
||||
* }
|
||||
*/
|
||||
onglobalmousemove: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseout` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseout = (event) => {
|
||||
* //some function here that happens on mouseout
|
||||
* }
|
||||
*/
|
||||
onmouseout: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseover` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseover = (event) => {
|
||||
* //some function here that happens on mouseover
|
||||
* }
|
||||
*/
|
||||
onmouseover: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseup` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseup = (event) => {
|
||||
* //some function here that happens on mouseup
|
||||
* }
|
||||
*/
|
||||
onmouseup: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseupoutside` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseupoutside = (event) => {
|
||||
* //some function here that happens on mouseupoutside
|
||||
* }
|
||||
*/
|
||||
onmouseupoutside: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointercancel` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointercancel = (event) => {
|
||||
* //some function here that happens on pointercancel
|
||||
* }
|
||||
*/
|
||||
onpointercancel: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerdown` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerdown = (event) => {
|
||||
* //some function here that happens on pointerdown
|
||||
* }
|
||||
*/
|
||||
onpointerdown: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerenter` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerenter = (event) => {
|
||||
* //some function here that happens on pointerenter
|
||||
* }
|
||||
*/
|
||||
onpointerenter: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerleave` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerleave = (event) => {
|
||||
* //some function here that happens on pointerleave
|
||||
* }
|
||||
*/
|
||||
onpointerleave: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointermove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointermove = (event) => {
|
||||
* //some function here that happens on pointermove
|
||||
* }
|
||||
*/
|
||||
onpointermove: null,
|
||||
/**
|
||||
* Property-based event handler for the `globalpointermove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onglobalpointermove = (event) => {
|
||||
* //some function here that happens on globalpointermove
|
||||
* }
|
||||
*/
|
||||
onglobalpointermove: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerout` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerout = (event) => {
|
||||
* //some function here that happens on pointerout
|
||||
* }
|
||||
*/
|
||||
onpointerout: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerover` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerover = (event) => {
|
||||
* //some function here that happens on pointerover
|
||||
* }
|
||||
*/
|
||||
onpointerover: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointertap` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointertap = (event) => {
|
||||
* //some function here that happens on pointertap
|
||||
* }
|
||||
*/
|
||||
onpointertap: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerup` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerup = (event) => {
|
||||
* //some function here that happens on pointerup
|
||||
* }
|
||||
*/
|
||||
onpointerup: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerupoutside` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerupoutside = (event) => {
|
||||
* //some function here that happens on pointerupoutside
|
||||
* }
|
||||
*/
|
||||
onpointerupoutside: null,
|
||||
/**
|
||||
* Property-based event handler for the `rightclick` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onrightclick = (event) => {
|
||||
* //some function here that happens on rightclick
|
||||
* }
|
||||
*/
|
||||
onrightclick: null,
|
||||
/**
|
||||
* Property-based event handler for the `rightdown` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onrightdown = (event) => {
|
||||
* //some function here that happens on rightdown
|
||||
* }
|
||||
*/
|
||||
onrightdown: null,
|
||||
/**
|
||||
* Property-based event handler for the `rightup` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onrightup = (event) => {
|
||||
* //some function here that happens on rightup
|
||||
* }
|
||||
*/
|
||||
onrightup: null,
|
||||
/**
|
||||
* Property-based event handler for the `rightupoutside` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onrightupoutside = (event) => {
|
||||
* //some function here that happens on rightupoutside
|
||||
* }
|
||||
*/
|
||||
onrightupoutside: null,
|
||||
/**
|
||||
* Property-based event handler for the `tap` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontap = (event) => {
|
||||
* //some function here that happens on tap
|
||||
* }
|
||||
*/
|
||||
ontap: null,
|
||||
/**
|
||||
* Property-based event handler for the `touchcancel` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontouchcancel = (event) => {
|
||||
* //some function here that happens on touchcancel
|
||||
* }
|
||||
*/
|
||||
ontouchcancel: null,
|
||||
/**
|
||||
* Property-based event handler for the `touchend` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontouchend = (event) => {
|
||||
* //some function here that happens on touchend
|
||||
* }
|
||||
*/
|
||||
ontouchend: null,
|
||||
/**
|
||||
* Property-based event handler for the `touchendoutside` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontouchendoutside = (event) => {
|
||||
* //some function here that happens on touchendoutside
|
||||
* }
|
||||
*/
|
||||
ontouchendoutside: null,
|
||||
/**
|
||||
* Property-based event handler for the `touchmove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontouchmove = (event) => {
|
||||
* //some function here that happens on touchmove
|
||||
* }
|
||||
*/
|
||||
ontouchmove: null,
|
||||
/**
|
||||
* Property-based event handler for the `globaltouchmove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onglobaltouchmove = (event) => {
|
||||
* //some function here that happens on globaltouchmove
|
||||
* }
|
||||
*/
|
||||
onglobaltouchmove: null,
|
||||
/**
|
||||
* Property-based event handler for the `touchstart` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontouchstart = (event) => {
|
||||
* //some function here that happens on touchstart
|
||||
* }
|
||||
*/
|
||||
ontouchstart: null,
|
||||
/**
|
||||
* Property-based event handler for the `wheel` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onwheel = (event) => {
|
||||
* //some function here that happens on wheel
|
||||
* }
|
||||
*/
|
||||
onwheel: null,
|
||||
/**
|
||||
* Enable interaction events for the Container. Touch, pointer and mouse
|
||||
* @memberof scene.Container#
|
||||
*/
|
||||
get interactive() {
|
||||
return this.eventMode === "dynamic" || this.eventMode === "static";
|
||||
},
|
||||
set interactive(value) {
|
||||
this.eventMode = value ? "static" : "passive";
|
||||
},
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
_internalEventMode: void 0,
|
||||
/**
|
||||
* Enable interaction events for the Container. Touch, pointer and mouse.
|
||||
* There are 5 types of interaction settings:
|
||||
* - `'none'`: Ignores all interaction events, even on its children.
|
||||
* - `'passive'`: **(default)** Does not emit events and ignores all hit testing on itself and non-interactive children.
|
||||
* Interactive children will still emit events.
|
||||
* - `'auto'`: Does not emit events but is hit tested if parent is interactive. Same as `interactive = false` in v7
|
||||
* - `'static'`: Emit events and is hit tested. Same as `interaction = true` in v7
|
||||
* - `'dynamic'`: Emits events and is hit tested but will also receive mock interaction events fired from a ticker to
|
||||
* allow for interaction when the mouse isn't moving
|
||||
* @example
|
||||
* import { Sprite } from 'pixi.js';
|
||||
*
|
||||
* const sprite = new Sprite(texture);
|
||||
* sprite.eventMode = 'static';
|
||||
* sprite.on('tap', (event) => {
|
||||
* // Handle event
|
||||
* });
|
||||
* @memberof scene.Container#
|
||||
* @since 7.2.0
|
||||
*/
|
||||
get eventMode() {
|
||||
return this._internalEventMode ?? EventSystem.EventSystem.defaultEventMode;
|
||||
},
|
||||
set eventMode(value) {
|
||||
this._internalEventMode = value;
|
||||
},
|
||||
/**
|
||||
* Determines if the container is interactive or not
|
||||
* @returns {boolean} Whether the container is interactive or not
|
||||
* @memberof scene.Container#
|
||||
* @since 7.2.0
|
||||
* @example
|
||||
* import { Sprite } from 'pixi.js';
|
||||
*
|
||||
* const sprite = new Sprite(texture);
|
||||
* sprite.eventMode = 'static';
|
||||
* sprite.isInteractive(); // true
|
||||
*
|
||||
* sprite.eventMode = 'dynamic';
|
||||
* sprite.isInteractive(); // true
|
||||
*
|
||||
* sprite.eventMode = 'none';
|
||||
* sprite.isInteractive(); // false
|
||||
*
|
||||
* sprite.eventMode = 'passive';
|
||||
* sprite.isInteractive(); // false
|
||||
*
|
||||
* sprite.eventMode = 'auto';
|
||||
* sprite.isInteractive(); // false
|
||||
*/
|
||||
isInteractive() {
|
||||
return this.eventMode === "static" || this.eventMode === "dynamic";
|
||||
},
|
||||
/**
|
||||
* Determines if the children to the container can be clicked/touched
|
||||
* Setting this to false allows PixiJS to bypass a recursive `hitTest` function
|
||||
* @memberof scene.Container#
|
||||
*/
|
||||
interactiveChildren: true,
|
||||
/**
|
||||
* Interaction shape. Children will be hit first, then this shape will be checked.
|
||||
* Setting this will cause this shape to be checked in hit tests rather than the container's bounds.
|
||||
* @example
|
||||
* import { Rectangle, Sprite } from 'pixi.js';
|
||||
*
|
||||
* const sprite = new Sprite(texture);
|
||||
* sprite.interactive = true;
|
||||
* sprite.hitArea = new Rectangle(0, 0, 100, 100);
|
||||
* @member {IHitArea}
|
||||
* @memberof scene.Container#
|
||||
*/
|
||||
hitArea: null,
|
||||
/**
|
||||
* Unlike `on` or `addListener` which are methods from EventEmitter, `addEventListener`
|
||||
* seeks to be compatible with the DOM's `addEventListener` with support for options.
|
||||
* @memberof scene.Container
|
||||
* @param type - The type of event to listen to.
|
||||
* @param listener - The listener callback or object.
|
||||
* @param options - Listener options, used for capture phase.
|
||||
* @example
|
||||
* // Tell the user whether they did a single, double, triple, or nth click.
|
||||
* button.addEventListener('click', {
|
||||
* handleEvent(e): {
|
||||
* let prefix;
|
||||
*
|
||||
* switch (e.detail) {
|
||||
* case 1: prefix = 'single'; break;
|
||||
* case 2: prefix = 'double'; break;
|
||||
* case 3: prefix = 'triple'; break;
|
||||
* default: prefix = e.detail + 'th'; break;
|
||||
* }
|
||||
*
|
||||
* console.log('That was a ' + prefix + 'click');
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // But skip the first click!
|
||||
* button.parent.addEventListener('click', function blockClickOnce(e) {
|
||||
* e.stopImmediatePropagation();
|
||||
* button.parent.removeEventListener('click', blockClickOnce, true);
|
||||
* }, {
|
||||
* capture: true,
|
||||
* });
|
||||
*/
|
||||
addEventListener(type, listener, options) {
|
||||
const capture = typeof options === "boolean" && options || typeof options === "object" && options.capture;
|
||||
const signal = typeof options === "object" ? options.signal : void 0;
|
||||
const once = typeof options === "object" ? options.once === true : false;
|
||||
const context = typeof listener === "function" ? void 0 : listener;
|
||||
type = capture ? `${type}capture` : type;
|
||||
const listenerFn = typeof listener === "function" ? listener : listener.handleEvent;
|
||||
const emitter = this;
|
||||
if (signal) {
|
||||
signal.addEventListener("abort", () => {
|
||||
emitter.off(type, listenerFn, context);
|
||||
});
|
||||
}
|
||||
if (once) {
|
||||
emitter.once(type, listenerFn, context);
|
||||
} else {
|
||||
emitter.on(type, listenerFn, context);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Unlike `off` or `removeListener` which are methods from EventEmitter, `removeEventListener`
|
||||
* seeks to be compatible with the DOM's `removeEventListener` with support for options.
|
||||
* @memberof scene.Container
|
||||
* @param type - The type of event the listener is bound to.
|
||||
* @param listener - The listener callback or object.
|
||||
* @param options - The original listener options. This is required to deregister a capture phase listener.
|
||||
*/
|
||||
removeEventListener(type, listener, options) {
|
||||
const capture = typeof options === "boolean" && options || typeof options === "object" && options.capture;
|
||||
const context = typeof listener === "function" ? void 0 : listener;
|
||||
type = capture ? `${type}capture` : type;
|
||||
listener = typeof listener === "function" ? listener : listener.handleEvent;
|
||||
this.off(type, listener, context);
|
||||
},
|
||||
/**
|
||||
* Dispatch the event on this {@link Container} using the event's {@link EventBoundary}.
|
||||
*
|
||||
* The target of the event is set to `this` and the `defaultPrevented` flag is cleared before dispatch.
|
||||
* @memberof scene.Container
|
||||
* @param e - The event to dispatch.
|
||||
* @returns Whether the {@link FederatedEvent.preventDefault preventDefault}() method was not invoked.
|
||||
* @example
|
||||
* // Reuse a click event!
|
||||
* button.dispatchEvent(clickEvent);
|
||||
*/
|
||||
dispatchEvent(e) {
|
||||
if (!(e instanceof FederatedEvent.FederatedEvent)) {
|
||||
throw new Error("Container cannot propagate events outside of the Federated Events API");
|
||||
}
|
||||
e.defaultPrevented = false;
|
||||
e.path = null;
|
||||
e.target = this;
|
||||
e.manager.dispatchEvent(e);
|
||||
return !e.defaultPrevented;
|
||||
}
|
||||
};
|
||||
|
||||
exports.FederatedContainer = FederatedContainer;
|
||||
//# sourceMappingURL=FederatedEventTarget.js.map
|
1
node_modules/pixi.js/lib/events/FederatedEventTarget.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedEventTarget.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
513
node_modules/pixi.js/lib/events/FederatedEventTarget.mjs
generated
vendored
Normal file
513
node_modules/pixi.js/lib/events/FederatedEventTarget.mjs
generated
vendored
Normal file
@@ -0,0 +1,513 @@
|
||||
import { EventSystem } from './EventSystem.mjs';
|
||||
import { FederatedEvent } from './FederatedEvent.mjs';
|
||||
|
||||
"use strict";
|
||||
const FederatedContainer = {
|
||||
/**
|
||||
* Property-based event handler for the `click` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onclick = (event) => {
|
||||
* //some function here that happens on click
|
||||
* }
|
||||
*/
|
||||
onclick: null,
|
||||
/**
|
||||
* Property-based event handler for the `mousedown` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmousedown = (event) => {
|
||||
* //some function here that happens on mousedown
|
||||
* }
|
||||
*/
|
||||
onmousedown: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseenter` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseenter = (event) => {
|
||||
* //some function here that happens on mouseenter
|
||||
* }
|
||||
*/
|
||||
onmouseenter: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseleave` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseleave = (event) => {
|
||||
* //some function here that happens on mouseleave
|
||||
* }
|
||||
*/
|
||||
onmouseleave: null,
|
||||
/**
|
||||
* Property-based event handler for the `mousemove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmousemove = (event) => {
|
||||
* //some function here that happens on mousemove
|
||||
* }
|
||||
*/
|
||||
onmousemove: null,
|
||||
/**
|
||||
* Property-based event handler for the `globalmousemove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onglobalmousemove = (event) => {
|
||||
* //some function here that happens on globalmousemove
|
||||
* }
|
||||
*/
|
||||
onglobalmousemove: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseout` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseout = (event) => {
|
||||
* //some function here that happens on mouseout
|
||||
* }
|
||||
*/
|
||||
onmouseout: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseover` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseover = (event) => {
|
||||
* //some function here that happens on mouseover
|
||||
* }
|
||||
*/
|
||||
onmouseover: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseup` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseup = (event) => {
|
||||
* //some function here that happens on mouseup
|
||||
* }
|
||||
*/
|
||||
onmouseup: null,
|
||||
/**
|
||||
* Property-based event handler for the `mouseupoutside` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onmouseupoutside = (event) => {
|
||||
* //some function here that happens on mouseupoutside
|
||||
* }
|
||||
*/
|
||||
onmouseupoutside: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointercancel` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointercancel = (event) => {
|
||||
* //some function here that happens on pointercancel
|
||||
* }
|
||||
*/
|
||||
onpointercancel: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerdown` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerdown = (event) => {
|
||||
* //some function here that happens on pointerdown
|
||||
* }
|
||||
*/
|
||||
onpointerdown: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerenter` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerenter = (event) => {
|
||||
* //some function here that happens on pointerenter
|
||||
* }
|
||||
*/
|
||||
onpointerenter: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerleave` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerleave = (event) => {
|
||||
* //some function here that happens on pointerleave
|
||||
* }
|
||||
*/
|
||||
onpointerleave: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointermove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointermove = (event) => {
|
||||
* //some function here that happens on pointermove
|
||||
* }
|
||||
*/
|
||||
onpointermove: null,
|
||||
/**
|
||||
* Property-based event handler for the `globalpointermove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onglobalpointermove = (event) => {
|
||||
* //some function here that happens on globalpointermove
|
||||
* }
|
||||
*/
|
||||
onglobalpointermove: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerout` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerout = (event) => {
|
||||
* //some function here that happens on pointerout
|
||||
* }
|
||||
*/
|
||||
onpointerout: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerover` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerover = (event) => {
|
||||
* //some function here that happens on pointerover
|
||||
* }
|
||||
*/
|
||||
onpointerover: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointertap` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointertap = (event) => {
|
||||
* //some function here that happens on pointertap
|
||||
* }
|
||||
*/
|
||||
onpointertap: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerup` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerup = (event) => {
|
||||
* //some function here that happens on pointerup
|
||||
* }
|
||||
*/
|
||||
onpointerup: null,
|
||||
/**
|
||||
* Property-based event handler for the `pointerupoutside` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onpointerupoutside = (event) => {
|
||||
* //some function here that happens on pointerupoutside
|
||||
* }
|
||||
*/
|
||||
onpointerupoutside: null,
|
||||
/**
|
||||
* Property-based event handler for the `rightclick` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onrightclick = (event) => {
|
||||
* //some function here that happens on rightclick
|
||||
* }
|
||||
*/
|
||||
onrightclick: null,
|
||||
/**
|
||||
* Property-based event handler for the `rightdown` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onrightdown = (event) => {
|
||||
* //some function here that happens on rightdown
|
||||
* }
|
||||
*/
|
||||
onrightdown: null,
|
||||
/**
|
||||
* Property-based event handler for the `rightup` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onrightup = (event) => {
|
||||
* //some function here that happens on rightup
|
||||
* }
|
||||
*/
|
||||
onrightup: null,
|
||||
/**
|
||||
* Property-based event handler for the `rightupoutside` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onrightupoutside = (event) => {
|
||||
* //some function here that happens on rightupoutside
|
||||
* }
|
||||
*/
|
||||
onrightupoutside: null,
|
||||
/**
|
||||
* Property-based event handler for the `tap` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontap = (event) => {
|
||||
* //some function here that happens on tap
|
||||
* }
|
||||
*/
|
||||
ontap: null,
|
||||
/**
|
||||
* Property-based event handler for the `touchcancel` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontouchcancel = (event) => {
|
||||
* //some function here that happens on touchcancel
|
||||
* }
|
||||
*/
|
||||
ontouchcancel: null,
|
||||
/**
|
||||
* Property-based event handler for the `touchend` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontouchend = (event) => {
|
||||
* //some function here that happens on touchend
|
||||
* }
|
||||
*/
|
||||
ontouchend: null,
|
||||
/**
|
||||
* Property-based event handler for the `touchendoutside` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontouchendoutside = (event) => {
|
||||
* //some function here that happens on touchendoutside
|
||||
* }
|
||||
*/
|
||||
ontouchendoutside: null,
|
||||
/**
|
||||
* Property-based event handler for the `touchmove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontouchmove = (event) => {
|
||||
* //some function here that happens on touchmove
|
||||
* }
|
||||
*/
|
||||
ontouchmove: null,
|
||||
/**
|
||||
* Property-based event handler for the `globaltouchmove` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onglobaltouchmove = (event) => {
|
||||
* //some function here that happens on globaltouchmove
|
||||
* }
|
||||
*/
|
||||
onglobaltouchmove: null,
|
||||
/**
|
||||
* Property-based event handler for the `touchstart` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.ontouchstart = (event) => {
|
||||
* //some function here that happens on touchstart
|
||||
* }
|
||||
*/
|
||||
ontouchstart: null,
|
||||
/**
|
||||
* Property-based event handler for the `wheel` event.
|
||||
* @memberof scene.Container#
|
||||
* @default null
|
||||
* @example
|
||||
* this.onwheel = (event) => {
|
||||
* //some function here that happens on wheel
|
||||
* }
|
||||
*/
|
||||
onwheel: null,
|
||||
/**
|
||||
* Enable interaction events for the Container. Touch, pointer and mouse
|
||||
* @memberof scene.Container#
|
||||
*/
|
||||
get interactive() {
|
||||
return this.eventMode === "dynamic" || this.eventMode === "static";
|
||||
},
|
||||
set interactive(value) {
|
||||
this.eventMode = value ? "static" : "passive";
|
||||
},
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
_internalEventMode: void 0,
|
||||
/**
|
||||
* Enable interaction events for the Container. Touch, pointer and mouse.
|
||||
* There are 5 types of interaction settings:
|
||||
* - `'none'`: Ignores all interaction events, even on its children.
|
||||
* - `'passive'`: **(default)** Does not emit events and ignores all hit testing on itself and non-interactive children.
|
||||
* Interactive children will still emit events.
|
||||
* - `'auto'`: Does not emit events but is hit tested if parent is interactive. Same as `interactive = false` in v7
|
||||
* - `'static'`: Emit events and is hit tested. Same as `interaction = true` in v7
|
||||
* - `'dynamic'`: Emits events and is hit tested but will also receive mock interaction events fired from a ticker to
|
||||
* allow for interaction when the mouse isn't moving
|
||||
* @example
|
||||
* import { Sprite } from 'pixi.js';
|
||||
*
|
||||
* const sprite = new Sprite(texture);
|
||||
* sprite.eventMode = 'static';
|
||||
* sprite.on('tap', (event) => {
|
||||
* // Handle event
|
||||
* });
|
||||
* @memberof scene.Container#
|
||||
* @since 7.2.0
|
||||
*/
|
||||
get eventMode() {
|
||||
return this._internalEventMode ?? EventSystem.defaultEventMode;
|
||||
},
|
||||
set eventMode(value) {
|
||||
this._internalEventMode = value;
|
||||
},
|
||||
/**
|
||||
* Determines if the container is interactive or not
|
||||
* @returns {boolean} Whether the container is interactive or not
|
||||
* @memberof scene.Container#
|
||||
* @since 7.2.0
|
||||
* @example
|
||||
* import { Sprite } from 'pixi.js';
|
||||
*
|
||||
* const sprite = new Sprite(texture);
|
||||
* sprite.eventMode = 'static';
|
||||
* sprite.isInteractive(); // true
|
||||
*
|
||||
* sprite.eventMode = 'dynamic';
|
||||
* sprite.isInteractive(); // true
|
||||
*
|
||||
* sprite.eventMode = 'none';
|
||||
* sprite.isInteractive(); // false
|
||||
*
|
||||
* sprite.eventMode = 'passive';
|
||||
* sprite.isInteractive(); // false
|
||||
*
|
||||
* sprite.eventMode = 'auto';
|
||||
* sprite.isInteractive(); // false
|
||||
*/
|
||||
isInteractive() {
|
||||
return this.eventMode === "static" || this.eventMode === "dynamic";
|
||||
},
|
||||
/**
|
||||
* Determines if the children to the container can be clicked/touched
|
||||
* Setting this to false allows PixiJS to bypass a recursive `hitTest` function
|
||||
* @memberof scene.Container#
|
||||
*/
|
||||
interactiveChildren: true,
|
||||
/**
|
||||
* Interaction shape. Children will be hit first, then this shape will be checked.
|
||||
* Setting this will cause this shape to be checked in hit tests rather than the container's bounds.
|
||||
* @example
|
||||
* import { Rectangle, Sprite } from 'pixi.js';
|
||||
*
|
||||
* const sprite = new Sprite(texture);
|
||||
* sprite.interactive = true;
|
||||
* sprite.hitArea = new Rectangle(0, 0, 100, 100);
|
||||
* @member {IHitArea}
|
||||
* @memberof scene.Container#
|
||||
*/
|
||||
hitArea: null,
|
||||
/**
|
||||
* Unlike `on` or `addListener` which are methods from EventEmitter, `addEventListener`
|
||||
* seeks to be compatible with the DOM's `addEventListener` with support for options.
|
||||
* @memberof scene.Container
|
||||
* @param type - The type of event to listen to.
|
||||
* @param listener - The listener callback or object.
|
||||
* @param options - Listener options, used for capture phase.
|
||||
* @example
|
||||
* // Tell the user whether they did a single, double, triple, or nth click.
|
||||
* button.addEventListener('click', {
|
||||
* handleEvent(e): {
|
||||
* let prefix;
|
||||
*
|
||||
* switch (e.detail) {
|
||||
* case 1: prefix = 'single'; break;
|
||||
* case 2: prefix = 'double'; break;
|
||||
* case 3: prefix = 'triple'; break;
|
||||
* default: prefix = e.detail + 'th'; break;
|
||||
* }
|
||||
*
|
||||
* console.log('That was a ' + prefix + 'click');
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // But skip the first click!
|
||||
* button.parent.addEventListener('click', function blockClickOnce(e) {
|
||||
* e.stopImmediatePropagation();
|
||||
* button.parent.removeEventListener('click', blockClickOnce, true);
|
||||
* }, {
|
||||
* capture: true,
|
||||
* });
|
||||
*/
|
||||
addEventListener(type, listener, options) {
|
||||
const capture = typeof options === "boolean" && options || typeof options === "object" && options.capture;
|
||||
const signal = typeof options === "object" ? options.signal : void 0;
|
||||
const once = typeof options === "object" ? options.once === true : false;
|
||||
const context = typeof listener === "function" ? void 0 : listener;
|
||||
type = capture ? `${type}capture` : type;
|
||||
const listenerFn = typeof listener === "function" ? listener : listener.handleEvent;
|
||||
const emitter = this;
|
||||
if (signal) {
|
||||
signal.addEventListener("abort", () => {
|
||||
emitter.off(type, listenerFn, context);
|
||||
});
|
||||
}
|
||||
if (once) {
|
||||
emitter.once(type, listenerFn, context);
|
||||
} else {
|
||||
emitter.on(type, listenerFn, context);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Unlike `off` or `removeListener` which are methods from EventEmitter, `removeEventListener`
|
||||
* seeks to be compatible with the DOM's `removeEventListener` with support for options.
|
||||
* @memberof scene.Container
|
||||
* @param type - The type of event the listener is bound to.
|
||||
* @param listener - The listener callback or object.
|
||||
* @param options - The original listener options. This is required to deregister a capture phase listener.
|
||||
*/
|
||||
removeEventListener(type, listener, options) {
|
||||
const capture = typeof options === "boolean" && options || typeof options === "object" && options.capture;
|
||||
const context = typeof listener === "function" ? void 0 : listener;
|
||||
type = capture ? `${type}capture` : type;
|
||||
listener = typeof listener === "function" ? listener : listener.handleEvent;
|
||||
this.off(type, listener, context);
|
||||
},
|
||||
/**
|
||||
* Dispatch the event on this {@link Container} using the event's {@link EventBoundary}.
|
||||
*
|
||||
* The target of the event is set to `this` and the `defaultPrevented` flag is cleared before dispatch.
|
||||
* @memberof scene.Container
|
||||
* @param e - The event to dispatch.
|
||||
* @returns Whether the {@link FederatedEvent.preventDefault preventDefault}() method was not invoked.
|
||||
* @example
|
||||
* // Reuse a click event!
|
||||
* button.dispatchEvent(clickEvent);
|
||||
*/
|
||||
dispatchEvent(e) {
|
||||
if (!(e instanceof FederatedEvent)) {
|
||||
throw new Error("Container cannot propagate events outside of the Federated Events API");
|
||||
}
|
||||
e.defaultPrevented = false;
|
||||
e.path = null;
|
||||
e.target = this;
|
||||
e.manager.dispatchEvent(e);
|
||||
return !e.defaultPrevented;
|
||||
}
|
||||
};
|
||||
|
||||
export { FederatedContainer };
|
||||
//# sourceMappingURL=FederatedEventTarget.mjs.map
|
1
node_modules/pixi.js/lib/events/FederatedEventTarget.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedEventTarget.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
113
node_modules/pixi.js/lib/events/FederatedMouseEvent.d.ts
generated
vendored
Normal file
113
node_modules/pixi.js/lib/events/FederatedMouseEvent.d.ts
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
import { Point } from '../maths/point/Point';
|
||||
import { FederatedEvent } from './FederatedEvent';
|
||||
import type { PointData } from '../maths/point/PointData';
|
||||
import type { Container } from '../scene/container/Container';
|
||||
import type { PixiTouch } from './FederatedEvent';
|
||||
/**
|
||||
* A {@link FederatedEvent} for mouse events.
|
||||
* @memberof events
|
||||
*/
|
||||
export declare class FederatedMouseEvent extends FederatedEvent<MouseEvent | PointerEvent | PixiTouch> implements MouseEvent {
|
||||
/** Whether the "alt" key was pressed when this mouse event occurred. */
|
||||
altKey: boolean;
|
||||
/** The specific button that was pressed in this mouse event. */
|
||||
button: number;
|
||||
/** The button depressed when this event occurred. */
|
||||
buttons: number;
|
||||
/** Whether the "control" key was pressed when this mouse event occurred. */
|
||||
ctrlKey: boolean;
|
||||
/** Whether the "meta" key was pressed when this mouse event occurred. */
|
||||
metaKey: boolean;
|
||||
/** This is currently not implemented in the Federated Events API. */
|
||||
relatedTarget: EventTarget;
|
||||
/** Whether the "shift" key was pressed when this mouse event occurred. */
|
||||
shiftKey: boolean;
|
||||
/** The coordinates of the mouse event relative to the canvas. */
|
||||
client: Point;
|
||||
/** @readonly */
|
||||
get clientX(): number;
|
||||
/** @readonly */
|
||||
get clientY(): number;
|
||||
/**
|
||||
* Alias for {@link FederatedMouseEvent.clientX this.clientX}.
|
||||
* @readonly
|
||||
*/
|
||||
get x(): number;
|
||||
/**
|
||||
* Alias for {@link FederatedMouseEvent.clientY this.clientY}.
|
||||
* @readonly
|
||||
*/
|
||||
get y(): number;
|
||||
/** This is the number of clicks that occurs in 200ms/click of each other. */
|
||||
detail: number;
|
||||
/** The movement in this pointer relative to the last `mousemove` event. */
|
||||
movement: Point;
|
||||
/** @readonly */
|
||||
get movementX(): number;
|
||||
/** @readonly */
|
||||
get movementY(): number;
|
||||
/** The offset of the pointer coordinates w.r.t. target Container in world space. This is not supported at the moment. */
|
||||
offset: Point;
|
||||
/** @readonly */
|
||||
get offsetX(): number;
|
||||
/** @readonly */
|
||||
get offsetY(): number;
|
||||
/** The pointer coordinates in world space. */
|
||||
global: Point;
|
||||
/** @readonly */
|
||||
get globalX(): number;
|
||||
/** @readonly */
|
||||
get globalY(): number;
|
||||
/**
|
||||
* The pointer coordinates in the renderer's {@link Renderer.screen screen}. This has slightly
|
||||
* different semantics than native PointerEvent screenX/screenY.
|
||||
*/
|
||||
screen: Point;
|
||||
/**
|
||||
* The pointer coordinates in the renderer's screen. Alias for {@code screen.x}.
|
||||
* @readonly
|
||||
*/
|
||||
get screenX(): number;
|
||||
/**
|
||||
* The pointer coordinates in the renderer's screen. Alias for {@code screen.y}.
|
||||
* @readonly
|
||||
*/
|
||||
get screenY(): number;
|
||||
/**
|
||||
* This will return the local coordinates of the specified container for this InteractionData
|
||||
* @param {Container} container - The Container that you would like the local
|
||||
* coords off
|
||||
* @param {PointData} point - A Point object in which to store the value, optional (otherwise
|
||||
* will create a new point)
|
||||
* @param {PointData} globalPos - A Point object containing your custom global coords, optional
|
||||
* (otherwise will use the current global coords)
|
||||
* @returns - A point containing the coordinates of the InteractionData position relative
|
||||
* to the Container
|
||||
*/
|
||||
getLocalPosition<P extends PointData = Point>(container: Container, point?: P, globalPos?: PointData): P;
|
||||
/**
|
||||
* Whether the modifier key was pressed when this event natively occurred.
|
||||
* @param key - The modifier key.
|
||||
*/
|
||||
getModifierState(key: string): boolean;
|
||||
/**
|
||||
* Not supported.
|
||||
* @param _typeArg
|
||||
* @param _canBubbleArg
|
||||
* @param _cancelableArg
|
||||
* @param _viewArg
|
||||
* @param _detailArg
|
||||
* @param _screenXArg
|
||||
* @param _screenYArg
|
||||
* @param _clientXArg
|
||||
* @param _clientYArg
|
||||
* @param _ctrlKeyArg
|
||||
* @param _altKeyArg
|
||||
* @param _shiftKeyArg
|
||||
* @param _metaKeyArg
|
||||
* @param _buttonArg
|
||||
* @param _relatedTargetArg
|
||||
* @deprecated since 7.0.0
|
||||
*/
|
||||
initMouseEvent(_typeArg: string, _canBubbleArg: boolean, _cancelableArg: boolean, _viewArg: Window, _detailArg: number, _screenXArg: number, _screenYArg: number, _clientXArg: number, _clientYArg: number, _ctrlKeyArg: boolean, _altKeyArg: boolean, _shiftKeyArg: boolean, _metaKeyArg: boolean, _buttonArg: number, _relatedTargetArg: EventTarget): void;
|
||||
}
|
131
node_modules/pixi.js/lib/events/FederatedMouseEvent.js
generated
vendored
Normal file
131
node_modules/pixi.js/lib/events/FederatedMouseEvent.js
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
'use strict';
|
||||
|
||||
var Point = require('../maths/point/Point.js');
|
||||
var FederatedEvent = require('./FederatedEvent.js');
|
||||
|
||||
"use strict";
|
||||
class FederatedMouseEvent extends FederatedEvent.FederatedEvent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
/** The coordinates of the mouse event relative to the canvas. */
|
||||
this.client = new Point.Point();
|
||||
/** The movement in this pointer relative to the last `mousemove` event. */
|
||||
this.movement = new Point.Point();
|
||||
/** The offset of the pointer coordinates w.r.t. target Container in world space. This is not supported at the moment. */
|
||||
this.offset = new Point.Point();
|
||||
/** The pointer coordinates in world space. */
|
||||
this.global = new Point.Point();
|
||||
/**
|
||||
* The pointer coordinates in the renderer's {@link Renderer.screen screen}. This has slightly
|
||||
* different semantics than native PointerEvent screenX/screenY.
|
||||
*/
|
||||
this.screen = new Point.Point();
|
||||
}
|
||||
/** @readonly */
|
||||
get clientX() {
|
||||
return this.client.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get clientY() {
|
||||
return this.client.y;
|
||||
}
|
||||
/**
|
||||
* Alias for {@link FederatedMouseEvent.clientX this.clientX}.
|
||||
* @readonly
|
||||
*/
|
||||
get x() {
|
||||
return this.clientX;
|
||||
}
|
||||
/**
|
||||
* Alias for {@link FederatedMouseEvent.clientY this.clientY}.
|
||||
* @readonly
|
||||
*/
|
||||
get y() {
|
||||
return this.clientY;
|
||||
}
|
||||
/** @readonly */
|
||||
get movementX() {
|
||||
return this.movement.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get movementY() {
|
||||
return this.movement.y;
|
||||
}
|
||||
/** @readonly */
|
||||
get offsetX() {
|
||||
return this.offset.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get offsetY() {
|
||||
return this.offset.y;
|
||||
}
|
||||
/** @readonly */
|
||||
get globalX() {
|
||||
return this.global.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get globalY() {
|
||||
return this.global.y;
|
||||
}
|
||||
/**
|
||||
* The pointer coordinates in the renderer's screen. Alias for {@code screen.x}.
|
||||
* @readonly
|
||||
*/
|
||||
get screenX() {
|
||||
return this.screen.x;
|
||||
}
|
||||
/**
|
||||
* The pointer coordinates in the renderer's screen. Alias for {@code screen.y}.
|
||||
* @readonly
|
||||
*/
|
||||
get screenY() {
|
||||
return this.screen.y;
|
||||
}
|
||||
/**
|
||||
* This will return the local coordinates of the specified container for this InteractionData
|
||||
* @param {Container} container - The Container that you would like the local
|
||||
* coords off
|
||||
* @param {PointData} point - A Point object in which to store the value, optional (otherwise
|
||||
* will create a new point)
|
||||
* @param {PointData} globalPos - A Point object containing your custom global coords, optional
|
||||
* (otherwise will use the current global coords)
|
||||
* @returns - A point containing the coordinates of the InteractionData position relative
|
||||
* to the Container
|
||||
*/
|
||||
getLocalPosition(container, point, globalPos) {
|
||||
return container.worldTransform.applyInverse(globalPos || this.global, point);
|
||||
}
|
||||
/**
|
||||
* Whether the modifier key was pressed when this event natively occurred.
|
||||
* @param key - The modifier key.
|
||||
*/
|
||||
getModifierState(key) {
|
||||
return "getModifierState" in this.nativeEvent && this.nativeEvent.getModifierState(key);
|
||||
}
|
||||
/**
|
||||
* Not supported.
|
||||
* @param _typeArg
|
||||
* @param _canBubbleArg
|
||||
* @param _cancelableArg
|
||||
* @param _viewArg
|
||||
* @param _detailArg
|
||||
* @param _screenXArg
|
||||
* @param _screenYArg
|
||||
* @param _clientXArg
|
||||
* @param _clientYArg
|
||||
* @param _ctrlKeyArg
|
||||
* @param _altKeyArg
|
||||
* @param _shiftKeyArg
|
||||
* @param _metaKeyArg
|
||||
* @param _buttonArg
|
||||
* @param _relatedTargetArg
|
||||
* @deprecated since 7.0.0
|
||||
*/
|
||||
// eslint-disable-next-line max-params
|
||||
initMouseEvent(_typeArg, _canBubbleArg, _cancelableArg, _viewArg, _detailArg, _screenXArg, _screenYArg, _clientXArg, _clientYArg, _ctrlKeyArg, _altKeyArg, _shiftKeyArg, _metaKeyArg, _buttonArg, _relatedTargetArg) {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
exports.FederatedMouseEvent = FederatedMouseEvent;
|
||||
//# sourceMappingURL=FederatedMouseEvent.js.map
|
1
node_modules/pixi.js/lib/events/FederatedMouseEvent.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedMouseEvent.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
129
node_modules/pixi.js/lib/events/FederatedMouseEvent.mjs
generated
vendored
Normal file
129
node_modules/pixi.js/lib/events/FederatedMouseEvent.mjs
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
import { Point } from '../maths/point/Point.mjs';
|
||||
import { FederatedEvent } from './FederatedEvent.mjs';
|
||||
|
||||
"use strict";
|
||||
class FederatedMouseEvent extends FederatedEvent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
/** The coordinates of the mouse event relative to the canvas. */
|
||||
this.client = new Point();
|
||||
/** The movement in this pointer relative to the last `mousemove` event. */
|
||||
this.movement = new Point();
|
||||
/** The offset of the pointer coordinates w.r.t. target Container in world space. This is not supported at the moment. */
|
||||
this.offset = new Point();
|
||||
/** The pointer coordinates in world space. */
|
||||
this.global = new Point();
|
||||
/**
|
||||
* The pointer coordinates in the renderer's {@link Renderer.screen screen}. This has slightly
|
||||
* different semantics than native PointerEvent screenX/screenY.
|
||||
*/
|
||||
this.screen = new Point();
|
||||
}
|
||||
/** @readonly */
|
||||
get clientX() {
|
||||
return this.client.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get clientY() {
|
||||
return this.client.y;
|
||||
}
|
||||
/**
|
||||
* Alias for {@link FederatedMouseEvent.clientX this.clientX}.
|
||||
* @readonly
|
||||
*/
|
||||
get x() {
|
||||
return this.clientX;
|
||||
}
|
||||
/**
|
||||
* Alias for {@link FederatedMouseEvent.clientY this.clientY}.
|
||||
* @readonly
|
||||
*/
|
||||
get y() {
|
||||
return this.clientY;
|
||||
}
|
||||
/** @readonly */
|
||||
get movementX() {
|
||||
return this.movement.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get movementY() {
|
||||
return this.movement.y;
|
||||
}
|
||||
/** @readonly */
|
||||
get offsetX() {
|
||||
return this.offset.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get offsetY() {
|
||||
return this.offset.y;
|
||||
}
|
||||
/** @readonly */
|
||||
get globalX() {
|
||||
return this.global.x;
|
||||
}
|
||||
/** @readonly */
|
||||
get globalY() {
|
||||
return this.global.y;
|
||||
}
|
||||
/**
|
||||
* The pointer coordinates in the renderer's screen. Alias for {@code screen.x}.
|
||||
* @readonly
|
||||
*/
|
||||
get screenX() {
|
||||
return this.screen.x;
|
||||
}
|
||||
/**
|
||||
* The pointer coordinates in the renderer's screen. Alias for {@code screen.y}.
|
||||
* @readonly
|
||||
*/
|
||||
get screenY() {
|
||||
return this.screen.y;
|
||||
}
|
||||
/**
|
||||
* This will return the local coordinates of the specified container for this InteractionData
|
||||
* @param {Container} container - The Container that you would like the local
|
||||
* coords off
|
||||
* @param {PointData} point - A Point object in which to store the value, optional (otherwise
|
||||
* will create a new point)
|
||||
* @param {PointData} globalPos - A Point object containing your custom global coords, optional
|
||||
* (otherwise will use the current global coords)
|
||||
* @returns - A point containing the coordinates of the InteractionData position relative
|
||||
* to the Container
|
||||
*/
|
||||
getLocalPosition(container, point, globalPos) {
|
||||
return container.worldTransform.applyInverse(globalPos || this.global, point);
|
||||
}
|
||||
/**
|
||||
* Whether the modifier key was pressed when this event natively occurred.
|
||||
* @param key - The modifier key.
|
||||
*/
|
||||
getModifierState(key) {
|
||||
return "getModifierState" in this.nativeEvent && this.nativeEvent.getModifierState(key);
|
||||
}
|
||||
/**
|
||||
* Not supported.
|
||||
* @param _typeArg
|
||||
* @param _canBubbleArg
|
||||
* @param _cancelableArg
|
||||
* @param _viewArg
|
||||
* @param _detailArg
|
||||
* @param _screenXArg
|
||||
* @param _screenYArg
|
||||
* @param _clientXArg
|
||||
* @param _clientYArg
|
||||
* @param _ctrlKeyArg
|
||||
* @param _altKeyArg
|
||||
* @param _shiftKeyArg
|
||||
* @param _metaKeyArg
|
||||
* @param _buttonArg
|
||||
* @param _relatedTargetArg
|
||||
* @deprecated since 7.0.0
|
||||
*/
|
||||
// eslint-disable-next-line max-params
|
||||
initMouseEvent(_typeArg, _canBubbleArg, _cancelableArg, _viewArg, _detailArg, _screenXArg, _screenYArg, _clientXArg, _clientYArg, _ctrlKeyArg, _altKeyArg, _shiftKeyArg, _metaKeyArg, _buttonArg, _relatedTargetArg) {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
export { FederatedMouseEvent };
|
||||
//# sourceMappingURL=FederatedMouseEvent.mjs.map
|
1
node_modules/pixi.js/lib/events/FederatedMouseEvent.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedMouseEvent.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
65
node_modules/pixi.js/lib/events/FederatedPointerEvent.d.ts
generated
vendored
Normal file
65
node_modules/pixi.js/lib/events/FederatedPointerEvent.d.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import { FederatedMouseEvent } from './FederatedMouseEvent';
|
||||
/**
|
||||
* A {@link FederatedEvent} for pointer events.
|
||||
* @memberof events
|
||||
*/
|
||||
export declare class FederatedPointerEvent extends FederatedMouseEvent implements PointerEvent {
|
||||
/**
|
||||
* The unique identifier of the pointer.
|
||||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId}
|
||||
*/
|
||||
pointerId: number;
|
||||
/**
|
||||
* The width of the pointer's contact along the x-axis, measured in CSS pixels.
|
||||
* radiusX of TouchEvents will be represented by this value.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width
|
||||
*/
|
||||
width: number;
|
||||
/**
|
||||
* The height of the pointer's contact along the y-axis, measured in CSS pixels.
|
||||
* radiusY of TouchEvents will be represented by this value.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height
|
||||
*/
|
||||
height: number;
|
||||
/**
|
||||
* Indicates whether or not the pointer device that created the event is the primary pointer.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary
|
||||
*/
|
||||
isPrimary: boolean;
|
||||
/**
|
||||
* The type of pointer that triggered the event.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType
|
||||
*/
|
||||
pointerType: string;
|
||||
/**
|
||||
* Pressure applied by the pointing device during the event.
|
||||
*s
|
||||
* A Touch's force property will be represented by this value.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure
|
||||
*/
|
||||
pressure: number;
|
||||
/**
|
||||
* Barrel pressure on a stylus pointer.
|
||||
* @see https://w3c.github.io/pointerevents/#pointerevent-interface
|
||||
*/
|
||||
tangentialPressure: number;
|
||||
/**
|
||||
* The angle, in degrees, between the pointer device and the screen.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltX
|
||||
*/
|
||||
tiltX: number;
|
||||
/**
|
||||
* The angle, in degrees, between the pointer device and the screen.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltY
|
||||
*/
|
||||
tiltY: number;
|
||||
/**
|
||||
* Twist of a stylus pointer.
|
||||
* @see https://w3c.github.io/pointerevents/#pointerevent-interface
|
||||
*/
|
||||
twist: number;
|
||||
/** This is the number of clicks that occurs in 200ms/click of each other. */
|
||||
detail: number;
|
||||
getCoalescedEvents(): PointerEvent[];
|
||||
getPredictedEvents(): PointerEvent[];
|
||||
}
|
41
node_modules/pixi.js/lib/events/FederatedPointerEvent.js
generated
vendored
Normal file
41
node_modules/pixi.js/lib/events/FederatedPointerEvent.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
var FederatedMouseEvent = require('./FederatedMouseEvent.js');
|
||||
|
||||
"use strict";
|
||||
class FederatedPointerEvent extends FederatedMouseEvent.FederatedMouseEvent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
/**
|
||||
* The width of the pointer's contact along the x-axis, measured in CSS pixels.
|
||||
* radiusX of TouchEvents will be represented by this value.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width
|
||||
*/
|
||||
this.width = 0;
|
||||
/**
|
||||
* The height of the pointer's contact along the y-axis, measured in CSS pixels.
|
||||
* radiusY of TouchEvents will be represented by this value.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height
|
||||
*/
|
||||
this.height = 0;
|
||||
/**
|
||||
* Indicates whether or not the pointer device that created the event is the primary pointer.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary
|
||||
*/
|
||||
this.isPrimary = false;
|
||||
}
|
||||
// Only included for completeness for now
|
||||
getCoalescedEvents() {
|
||||
if (this.type === "pointermove" || this.type === "mousemove" || this.type === "touchmove") {
|
||||
return [this];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
// Only included for completeness for now
|
||||
getPredictedEvents() {
|
||||
throw new Error("getPredictedEvents is not supported!");
|
||||
}
|
||||
}
|
||||
|
||||
exports.FederatedPointerEvent = FederatedPointerEvent;
|
||||
//# sourceMappingURL=FederatedPointerEvent.js.map
|
1
node_modules/pixi.js/lib/events/FederatedPointerEvent.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedPointerEvent.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FederatedPointerEvent.js","sources":["../../src/events/FederatedPointerEvent.ts"],"sourcesContent":["import { FederatedMouseEvent } from './FederatedMouseEvent';\n\n/**\n * A {@link FederatedEvent} for pointer events.\n * @memberof events\n */\nexport class FederatedPointerEvent extends FederatedMouseEvent implements PointerEvent\n{\n /**\n * The unique identifier of the pointer.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId}\n */\n public pointerId: number;\n\n /**\n * The width of the pointer's contact along the x-axis, measured in CSS pixels.\n * radiusX of TouchEvents will be represented by this value.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width\n */\n public width = 0;\n\n /**\n * The height of the pointer's contact along the y-axis, measured in CSS pixels.\n * radiusY of TouchEvents will be represented by this value.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height\n */\n public height = 0;\n\n /**\n * Indicates whether or not the pointer device that created the event is the primary pointer.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary\n */\n public isPrimary = false;\n\n /**\n * The type of pointer that triggered the event.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType\n */\n public pointerType: string;\n\n /**\n * Pressure applied by the pointing device during the event.\n *s\n * A Touch's force property will be represented by this value.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure\n */\n public pressure: number;\n\n /**\n * Barrel pressure on a stylus pointer.\n * @see https://w3c.github.io/pointerevents/#pointerevent-interface\n */\n public tangentialPressure: number;\n\n /**\n * The angle, in degrees, between the pointer device and the screen.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltX\n */\n public tiltX: number;\n\n /**\n * The angle, in degrees, between the pointer device and the screen.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltY\n */\n public tiltY: number;\n\n /**\n * Twist of a stylus pointer.\n * @see https://w3c.github.io/pointerevents/#pointerevent-interface\n */\n public twist: number;\n\n /** This is the number of clicks that occurs in 200ms/click of each other. */\n public detail: number;\n\n // Only included for completeness for now\n public getCoalescedEvents(): PointerEvent[]\n {\n if (this.type === 'pointermove' || this.type === 'mousemove' || this.type === 'touchmove')\n {\n return [this];\n }\n\n return [];\n }\n\n // Only included for completeness for now\n public getPredictedEvents(): PointerEvent[]\n {\n throw new Error('getPredictedEvents is not supported!');\n }\n}\n"],"names":["FederatedMouseEvent"],"mappings":";;;;;AAMO,MAAM,8BAA8BA,uCAC3C,CAAA;AAAA,EADO,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA,CAAA;AAaH;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAO,KAAQ,GAAA,CAAA,CAAA;AAOf;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAO,MAAS,GAAA,CAAA,CAAA;AAMhB;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAO,SAAY,GAAA,KAAA,CAAA;AAAA,GAAA;AAAA;AAAA,EA4CZ,kBACP,GAAA;AACI,IAAI,IAAA,IAAA,CAAK,SAAS,aAAiB,IAAA,IAAA,CAAK,SAAS,WAAe,IAAA,IAAA,CAAK,SAAS,WAC9E,EAAA;AACI,MAAA,OAAO,CAAC,IAAI,CAAA,CAAA;AAAA,KAChB;AAEA,IAAA,OAAO,EAAC,CAAA;AAAA,GACZ;AAAA;AAAA,EAGO,kBACP,GAAA;AACI,IAAM,MAAA,IAAI,MAAM,sCAAsC,CAAA,CAAA;AAAA,GAC1D;AACJ;;;;"}
|
39
node_modules/pixi.js/lib/events/FederatedPointerEvent.mjs
generated
vendored
Normal file
39
node_modules/pixi.js/lib/events/FederatedPointerEvent.mjs
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { FederatedMouseEvent } from './FederatedMouseEvent.mjs';
|
||||
|
||||
"use strict";
|
||||
class FederatedPointerEvent extends FederatedMouseEvent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
/**
|
||||
* The width of the pointer's contact along the x-axis, measured in CSS pixels.
|
||||
* radiusX of TouchEvents will be represented by this value.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width
|
||||
*/
|
||||
this.width = 0;
|
||||
/**
|
||||
* The height of the pointer's contact along the y-axis, measured in CSS pixels.
|
||||
* radiusY of TouchEvents will be represented by this value.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height
|
||||
*/
|
||||
this.height = 0;
|
||||
/**
|
||||
* Indicates whether or not the pointer device that created the event is the primary pointer.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary
|
||||
*/
|
||||
this.isPrimary = false;
|
||||
}
|
||||
// Only included for completeness for now
|
||||
getCoalescedEvents() {
|
||||
if (this.type === "pointermove" || this.type === "mousemove" || this.type === "touchmove") {
|
||||
return [this];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
// Only included for completeness for now
|
||||
getPredictedEvents() {
|
||||
throw new Error("getPredictedEvents is not supported!");
|
||||
}
|
||||
}
|
||||
|
||||
export { FederatedPointerEvent };
|
||||
//# sourceMappingURL=FederatedPointerEvent.mjs.map
|
1
node_modules/pixi.js/lib/events/FederatedPointerEvent.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedPointerEvent.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FederatedPointerEvent.mjs","sources":["../../src/events/FederatedPointerEvent.ts"],"sourcesContent":["import { FederatedMouseEvent } from './FederatedMouseEvent';\n\n/**\n * A {@link FederatedEvent} for pointer events.\n * @memberof events\n */\nexport class FederatedPointerEvent extends FederatedMouseEvent implements PointerEvent\n{\n /**\n * The unique identifier of the pointer.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId}\n */\n public pointerId: number;\n\n /**\n * The width of the pointer's contact along the x-axis, measured in CSS pixels.\n * radiusX of TouchEvents will be represented by this value.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width\n */\n public width = 0;\n\n /**\n * The height of the pointer's contact along the y-axis, measured in CSS pixels.\n * radiusY of TouchEvents will be represented by this value.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height\n */\n public height = 0;\n\n /**\n * Indicates whether or not the pointer device that created the event is the primary pointer.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary\n */\n public isPrimary = false;\n\n /**\n * The type of pointer that triggered the event.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType\n */\n public pointerType: string;\n\n /**\n * Pressure applied by the pointing device during the event.\n *s\n * A Touch's force property will be represented by this value.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure\n */\n public pressure: number;\n\n /**\n * Barrel pressure on a stylus pointer.\n * @see https://w3c.github.io/pointerevents/#pointerevent-interface\n */\n public tangentialPressure: number;\n\n /**\n * The angle, in degrees, between the pointer device and the screen.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltX\n */\n public tiltX: number;\n\n /**\n * The angle, in degrees, between the pointer device and the screen.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltY\n */\n public tiltY: number;\n\n /**\n * Twist of a stylus pointer.\n * @see https://w3c.github.io/pointerevents/#pointerevent-interface\n */\n public twist: number;\n\n /** This is the number of clicks that occurs in 200ms/click of each other. */\n public detail: number;\n\n // Only included for completeness for now\n public getCoalescedEvents(): PointerEvent[]\n {\n if (this.type === 'pointermove' || this.type === 'mousemove' || this.type === 'touchmove')\n {\n return [this];\n }\n\n return [];\n }\n\n // Only included for completeness for now\n public getPredictedEvents(): PointerEvent[]\n {\n throw new Error('getPredictedEvents is not supported!');\n }\n}\n"],"names":[],"mappings":";;;AAMO,MAAM,8BAA8B,mBAC3C,CAAA;AAAA,EADO,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA,CAAA;AAaH;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAO,KAAQ,GAAA,CAAA,CAAA;AAOf;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAO,MAAS,GAAA,CAAA,CAAA;AAMhB;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAO,SAAY,GAAA,KAAA,CAAA;AAAA,GAAA;AAAA;AAAA,EA4CZ,kBACP,GAAA;AACI,IAAI,IAAA,IAAA,CAAK,SAAS,aAAiB,IAAA,IAAA,CAAK,SAAS,WAAe,IAAA,IAAA,CAAK,SAAS,WAC9E,EAAA;AACI,MAAA,OAAO,CAAC,IAAI,CAAA,CAAA;AAAA,KAChB;AAEA,IAAA,OAAO,EAAC,CAAA;AAAA,GACZ;AAAA;AAAA,EAGO,kBACP,GAAA;AACI,IAAM,MAAA,IAAI,MAAM,sCAAsC,CAAA,CAAA;AAAA,GAC1D;AACJ;;;;"}
|
30
node_modules/pixi.js/lib/events/FederatedWheelEvent.d.ts
generated
vendored
Normal file
30
node_modules/pixi.js/lib/events/FederatedWheelEvent.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { FederatedMouseEvent } from './FederatedMouseEvent';
|
||||
/**
|
||||
* A {@link FederatedEvent} for wheel events.
|
||||
* @memberof events
|
||||
*/
|
||||
export declare class FederatedWheelEvent extends FederatedMouseEvent implements WheelEvent {
|
||||
/**
|
||||
* The units of `deltaX`, `deltaY`, and `deltaZ`. This is one of `DOM_DELTA_LINE`,
|
||||
* `DOM_DELTA_PAGE`, `DOM_DELTA_PIXEL`.
|
||||
*/
|
||||
deltaMode: number;
|
||||
/** Horizontal scroll amount */
|
||||
deltaX: number;
|
||||
/** Vertical scroll amount */
|
||||
deltaY: number;
|
||||
/** z-axis scroll amount. */
|
||||
deltaZ: number;
|
||||
/** Units specified in pixels. */
|
||||
static readonly DOM_DELTA_PIXEL = 0;
|
||||
/** Units specified in pixels. */
|
||||
readonly DOM_DELTA_PIXEL = 0;
|
||||
/** Units specified in lines. */
|
||||
static readonly DOM_DELTA_LINE = 1;
|
||||
/** Units specified in lines. */
|
||||
readonly DOM_DELTA_LINE = 1;
|
||||
/** Units specified in pages. */
|
||||
static readonly DOM_DELTA_PAGE = 2;
|
||||
/** Units specified in pages. */
|
||||
readonly DOM_DELTA_PAGE = 2;
|
||||
}
|
25
node_modules/pixi.js/lib/events/FederatedWheelEvent.js
generated
vendored
Normal file
25
node_modules/pixi.js/lib/events/FederatedWheelEvent.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
var FederatedMouseEvent = require('./FederatedMouseEvent.js');
|
||||
|
||||
"use strict";
|
||||
class FederatedWheelEvent extends FederatedMouseEvent.FederatedMouseEvent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
/** Units specified in pixels. */
|
||||
this.DOM_DELTA_PIXEL = 0;
|
||||
/** Units specified in lines. */
|
||||
this.DOM_DELTA_LINE = 1;
|
||||
/** Units specified in pages. */
|
||||
this.DOM_DELTA_PAGE = 2;
|
||||
}
|
||||
}
|
||||
/** Units specified in pixels. */
|
||||
FederatedWheelEvent.DOM_DELTA_PIXEL = 0;
|
||||
/** Units specified in lines. */
|
||||
FederatedWheelEvent.DOM_DELTA_LINE = 1;
|
||||
/** Units specified in pages. */
|
||||
FederatedWheelEvent.DOM_DELTA_PAGE = 2;
|
||||
|
||||
exports.FederatedWheelEvent = FederatedWheelEvent;
|
||||
//# sourceMappingURL=FederatedWheelEvent.js.map
|
1
node_modules/pixi.js/lib/events/FederatedWheelEvent.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedWheelEvent.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FederatedWheelEvent.js","sources":["../../src/events/FederatedWheelEvent.ts"],"sourcesContent":["import { FederatedMouseEvent } from './FederatedMouseEvent';\n\n/**\n * A {@link FederatedEvent} for wheel events.\n * @memberof events\n */\nexport class FederatedWheelEvent extends FederatedMouseEvent implements WheelEvent\n{\n /**\n * The units of `deltaX`, `deltaY`, and `deltaZ`. This is one of `DOM_DELTA_LINE`,\n * `DOM_DELTA_PAGE`, `DOM_DELTA_PIXEL`.\n */\n public deltaMode: number;\n\n /** Horizontal scroll amount */\n public deltaX: number;\n\n /** Vertical scroll amount */\n public deltaY: number;\n\n /** z-axis scroll amount. */\n public deltaZ: number;\n\n /** Units specified in pixels. */\n public static readonly DOM_DELTA_PIXEL = 0;\n\n /** Units specified in pixels. */\n public readonly DOM_DELTA_PIXEL = 0;\n\n /** Units specified in lines. */\n public static readonly DOM_DELTA_LINE = 1;\n\n /** Units specified in lines. */\n public readonly DOM_DELTA_LINE = 1;\n\n /** Units specified in pages. */\n public static readonly DOM_DELTA_PAGE = 2;\n\n /** Units specified in pages. */\n public readonly DOM_DELTA_PAGE = 2;\n}\n"],"names":["FederatedMouseEvent"],"mappings":";;;;;AAMO,MAAM,4BAA4BA,uCACzC,CAAA;AAAA,EADO,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA,CAAA;AAqBH;AAAA,IAAA,IAAA,CAAgB,eAAkB,GAAA,CAAA,CAAA;AAMlC;AAAA,IAAA,IAAA,CAAgB,cAAiB,GAAA,CAAA,CAAA;AAMjC;AAAA,IAAA,IAAA,CAAgB,cAAiB,GAAA,CAAA,CAAA;AAAA,GAAA;AACrC,CAAA;AAAA;AAlCa,mBAAA,CAkBc,eAAkB,GAAA,CAAA,CAAA;AAAA;AAlBhC,mBAAA,CAwBc,cAAiB,GAAA,CAAA,CAAA;AAAA;AAxB/B,mBAAA,CA8Bc,cAAiB,GAAA,CAAA;;;;"}
|
23
node_modules/pixi.js/lib/events/FederatedWheelEvent.mjs
generated
vendored
Normal file
23
node_modules/pixi.js/lib/events/FederatedWheelEvent.mjs
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { FederatedMouseEvent } from './FederatedMouseEvent.mjs';
|
||||
|
||||
"use strict";
|
||||
class FederatedWheelEvent extends FederatedMouseEvent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
/** Units specified in pixels. */
|
||||
this.DOM_DELTA_PIXEL = 0;
|
||||
/** Units specified in lines. */
|
||||
this.DOM_DELTA_LINE = 1;
|
||||
/** Units specified in pages. */
|
||||
this.DOM_DELTA_PAGE = 2;
|
||||
}
|
||||
}
|
||||
/** Units specified in pixels. */
|
||||
FederatedWheelEvent.DOM_DELTA_PIXEL = 0;
|
||||
/** Units specified in lines. */
|
||||
FederatedWheelEvent.DOM_DELTA_LINE = 1;
|
||||
/** Units specified in pages. */
|
||||
FederatedWheelEvent.DOM_DELTA_PAGE = 2;
|
||||
|
||||
export { FederatedWheelEvent };
|
||||
//# sourceMappingURL=FederatedWheelEvent.mjs.map
|
1
node_modules/pixi.js/lib/events/FederatedWheelEvent.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/FederatedWheelEvent.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FederatedWheelEvent.mjs","sources":["../../src/events/FederatedWheelEvent.ts"],"sourcesContent":["import { FederatedMouseEvent } from './FederatedMouseEvent';\n\n/**\n * A {@link FederatedEvent} for wheel events.\n * @memberof events\n */\nexport class FederatedWheelEvent extends FederatedMouseEvent implements WheelEvent\n{\n /**\n * The units of `deltaX`, `deltaY`, and `deltaZ`. This is one of `DOM_DELTA_LINE`,\n * `DOM_DELTA_PAGE`, `DOM_DELTA_PIXEL`.\n */\n public deltaMode: number;\n\n /** Horizontal scroll amount */\n public deltaX: number;\n\n /** Vertical scroll amount */\n public deltaY: number;\n\n /** z-axis scroll amount. */\n public deltaZ: number;\n\n /** Units specified in pixels. */\n public static readonly DOM_DELTA_PIXEL = 0;\n\n /** Units specified in pixels. */\n public readonly DOM_DELTA_PIXEL = 0;\n\n /** Units specified in lines. */\n public static readonly DOM_DELTA_LINE = 1;\n\n /** Units specified in lines. */\n public readonly DOM_DELTA_LINE = 1;\n\n /** Units specified in pages. */\n public static readonly DOM_DELTA_PAGE = 2;\n\n /** Units specified in pages. */\n public readonly DOM_DELTA_PAGE = 2;\n}\n"],"names":[],"mappings":";;;AAMO,MAAM,4BAA4B,mBACzC,CAAA;AAAA,EADO,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA,CAAA;AAqBH;AAAA,IAAA,IAAA,CAAgB,eAAkB,GAAA,CAAA,CAAA;AAMlC;AAAA,IAAA,IAAA,CAAgB,cAAiB,GAAA,CAAA,CAAA;AAMjC;AAAA,IAAA,IAAA,CAAgB,cAAiB,GAAA,CAAA,CAAA;AAAA,GAAA;AACrC,CAAA;AAAA;AAlCa,mBAAA,CAkBc,eAAkB,GAAA,CAAA,CAAA;AAAA;AAlBhC,mBAAA,CAwBc,cAAiB,GAAA,CAAA,CAAA;AAAA;AAxB/B,mBAAA,CA8Bc,cAAiB,GAAA,CAAA;;;;"}
|
18
node_modules/pixi.js/lib/events/deprecatedTypes.d.ts
generated
vendored
Normal file
18
node_modules/pixi.js/lib/events/deprecatedTypes.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import type EventEmitter from 'eventemitter3';
|
||||
import type { EventMode, FederatedOptions } from './FederatedEventTarget';
|
||||
/**
|
||||
* A simplified shape of an interactive object for the `eventTarget` property of a {@link FederatedEvent}
|
||||
* @memberof events
|
||||
* @deprecated since 8.1.4
|
||||
*/
|
||||
export interface FederatedEventTarget extends EventEmitter, EventTarget, Required<FederatedOptions> {
|
||||
/** The parent of this event target. */
|
||||
readonly parent?: FederatedEventTarget;
|
||||
/** The children of this event target. */
|
||||
readonly children?: ReadonlyArray<FederatedEventTarget>;
|
||||
_internalEventMode: EventMode;
|
||||
/** Returns true if the Container has interactive 'static' or 'dynamic' */
|
||||
isInteractive: () => boolean;
|
||||
/** Remove all listeners, or those of the specified event. */
|
||||
removeAllListeners(event?: string | symbol): this;
|
||||
}
|
4
node_modules/pixi.js/lib/events/deprecatedTypes.js
generated
vendored
Normal file
4
node_modules/pixi.js/lib/events/deprecatedTypes.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
"use strict";
|
||||
//# sourceMappingURL=deprecatedTypes.js.map
|
1
node_modules/pixi.js/lib/events/deprecatedTypes.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/deprecatedTypes.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"deprecatedTypes.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
2
node_modules/pixi.js/lib/events/deprecatedTypes.mjs
generated
vendored
Normal file
2
node_modules/pixi.js/lib/events/deprecatedTypes.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=deprecatedTypes.mjs.map
|
1
node_modules/pixi.js/lib/events/deprecatedTypes.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/deprecatedTypes.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"deprecatedTypes.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
11
node_modules/pixi.js/lib/events/index.d.ts
generated
vendored
Normal file
11
node_modules/pixi.js/lib/events/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export * from './deprecatedTypes';
|
||||
export * from './EventBoundary';
|
||||
export * from './EventBoundaryTypes';
|
||||
export * from './EventSystem';
|
||||
export * from './EventTicker';
|
||||
export * from './FederatedEvent';
|
||||
export * from './FederatedEventMap';
|
||||
export * from './FederatedEventTarget';
|
||||
export * from './FederatedMouseEvent';
|
||||
export * from './FederatedPointerEvent';
|
||||
export * from './FederatedWheelEvent';
|
25
node_modules/pixi.js/lib/events/index.js
generated
vendored
Normal file
25
node_modules/pixi.js/lib/events/index.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
require('./deprecatedTypes.js');
|
||||
var EventBoundary = require('./EventBoundary.js');
|
||||
require('./EventBoundaryTypes.js');
|
||||
var EventSystem = require('./EventSystem.js');
|
||||
var EventTicker = require('./EventTicker.js');
|
||||
var FederatedEvent = require('./FederatedEvent.js');
|
||||
require('./FederatedEventMap.js');
|
||||
var FederatedEventTarget = require('./FederatedEventTarget.js');
|
||||
var FederatedMouseEvent = require('./FederatedMouseEvent.js');
|
||||
var FederatedPointerEvent = require('./FederatedPointerEvent.js');
|
||||
var FederatedWheelEvent = require('./FederatedWheelEvent.js');
|
||||
|
||||
"use strict";
|
||||
|
||||
exports.EventBoundary = EventBoundary.EventBoundary;
|
||||
exports.EventSystem = EventSystem.EventSystem;
|
||||
exports.EventsTicker = EventTicker.EventsTicker;
|
||||
exports.FederatedEvent = FederatedEvent.FederatedEvent;
|
||||
exports.FederatedContainer = FederatedEventTarget.FederatedContainer;
|
||||
exports.FederatedMouseEvent = FederatedMouseEvent.FederatedMouseEvent;
|
||||
exports.FederatedPointerEvent = FederatedPointerEvent.FederatedPointerEvent;
|
||||
exports.FederatedWheelEvent = FederatedWheelEvent.FederatedWheelEvent;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/pixi.js/lib/events/index.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
14
node_modules/pixi.js/lib/events/index.mjs
generated
vendored
Normal file
14
node_modules/pixi.js/lib/events/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import './deprecatedTypes.mjs';
|
||||
export { EventBoundary } from './EventBoundary.mjs';
|
||||
import './EventBoundaryTypes.mjs';
|
||||
export { EventSystem } from './EventSystem.mjs';
|
||||
export { EventsTicker } from './EventTicker.mjs';
|
||||
export { FederatedEvent } from './FederatedEvent.mjs';
|
||||
import './FederatedEventMap.mjs';
|
||||
export { FederatedContainer } from './FederatedEventTarget.mjs';
|
||||
export { FederatedMouseEvent } from './FederatedMouseEvent.mjs';
|
||||
export { FederatedPointerEvent } from './FederatedPointerEvent.mjs';
|
||||
export { FederatedWheelEvent } from './FederatedWheelEvent.mjs';
|
||||
|
||||
"use strict";
|
||||
//# sourceMappingURL=index.mjs.map
|
1
node_modules/pixi.js/lib/events/index.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
1
node_modules/pixi.js/lib/events/init.d.ts
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/init.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
11
node_modules/pixi.js/lib/events/init.js
generated
vendored
Normal file
11
node_modules/pixi.js/lib/events/init.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
var Extensions = require('../extensions/Extensions.js');
|
||||
var Container = require('../scene/container/Container.js');
|
||||
var EventSystem = require('./EventSystem.js');
|
||||
var FederatedEventTarget = require('./FederatedEventTarget.js');
|
||||
|
||||
"use strict";
|
||||
Extensions.extensions.add(EventSystem.EventSystem);
|
||||
Container.Container.mixin(FederatedEventTarget.FederatedContainer);
|
||||
//# sourceMappingURL=init.js.map
|
1
node_modules/pixi.js/lib/events/init.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/init.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/pixi.js/lib/events/init.mjs
generated
vendored
Normal file
9
node_modules/pixi.js/lib/events/init.mjs
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { extensions } from '../extensions/Extensions.mjs';
|
||||
import { Container } from '../scene/container/Container.mjs';
|
||||
import { EventSystem } from './EventSystem.mjs';
|
||||
import { FederatedContainer } from './FederatedEventTarget.mjs';
|
||||
|
||||
"use strict";
|
||||
extensions.add(EventSystem);
|
||||
Container.mixin(FederatedContainer);
|
||||
//# sourceMappingURL=init.mjs.map
|
1
node_modules/pixi.js/lib/events/init.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/events/init.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user