- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
import type { DisplayObject } from '@pixi/display';
import type { InteractionData } from './InteractionData';
export type InteractionCallback = (interactionEvent: InteractionEvent, displayObject: DisplayObject, hit?: boolean) => void;
/**
* Event class that mimics native DOM events.
* @memberof PIXI
*/
export class InteractionEvent
{
/**
* Whether this event will continue propagating in the tree.
*
* Remaining events for the {@link stopsPropagatingAt} object
* will still be dispatched.
*/
public stopped: boolean;
/**
* At which object this event stops propagating.
* @private
*/
public stopsPropagatingAt: DisplayObject;
/**
* Whether we already reached the element we want to
* stop propagating at. This is important for delayed events,
* where we start over deeper in the tree again.
* @private
*/
public stopPropagationHint: boolean;
/**
* The object which caused this event to be dispatched.
* For listener callback see {@link PIXI.InteractionEvent.currentTarget}.
*/
public target: DisplayObject;
/** The object whose event listener’s callback is currently being invoked. */
public currentTarget: DisplayObject;
/** Type of the event. */
public type: string;
/** {@link InteractionData} related to this event */
public data: InteractionData;
constructor()
{
this.stopped = false;
this.stopsPropagatingAt = null;
this.stopPropagationHint = false;
this.target = null;
this.currentTarget = null;
this.type = null;
this.data = null;
}
/** Prevents event from reaching any objects other than the current object. */
public stopPropagation(): void
{
this.stopped = true;
this.stopPropagationHint = true;
this.stopsPropagatingAt = this.currentTarget;
}
/** Resets the event. */
public reset(): void
{
this.stopped = false;
this.stopsPropagatingAt = null;
this.stopPropagationHint = false;
this.currentTarget = null;
this.target = null;
}
}