@vunk/plus 1.6.8 → 1.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/SendOutlined.mjs +8 -6
- package/components/SharedSystems.mjs +290 -72
- package/components/WebGLRenderer.mjs +32 -20
- package/components/WebGPURenderer.mjs +48 -10
- package/components/agent-chat-provider/index.d.ts +7 -0
- package/components/agent-chat-provider/index.mjs +6 -3
- package/components/agent-chat-provider/src/api.d.ts +3 -0
- package/components/agent-chat-provider/src/const-roles.d.ts +8 -0
- package/components/agent-chat-provider/src/const.d.ts +1 -0
- package/components/agent-chat-provider/src/index.vue.d.ts +22 -0
- package/components/agent-chat-provider/src/types.d.ts +50 -0
- package/components/agent-chat-provider/src/use.d.ts +5 -0
- package/components/avatar/index.d.ts +4 -0
- package/components/avatar/index.mjs +2 -2
- package/components/avatar/src/ctx.d.ts +6 -0
- package/components/avatar/src/index.vue.d.ts +180 -0
- package/components/avatar/src/types.d.ts +1 -0
- package/components/broadcasting-markdown/index.d.ts +7 -0
- package/components/broadcasting-markdown/index.mjs +78 -158
- package/components/broadcasting-markdown/src/const.d.ts +13 -0
- package/components/broadcasting-markdown/src/ctx.d.ts +129 -0
- package/components/broadcasting-markdown/src/howler-speech.vue.d.ts +104 -0
- package/components/broadcasting-markdown/src/index.vue.d.ts +439 -0
- package/components/broadcasting-markdown/src/paragraph.vue.d.ts +79 -0
- package/components/broadcasting-markdown/src/speech-error.vue.d.ts +67 -0
- package/components/broadcasting-markdown/src/types.d.ts +26 -0
- package/components/broadcasting-markdown/src/use.d.ts +21 -0
- package/components/browserAll.mjs +333 -562
- package/components/bubble-list/index.d.ts +5 -0
- package/components/bubble-list/index.mjs +91 -72
- package/components/bubble-list/src/ctx.d.ts +32 -0
- package/components/bubble-list/src/index.vue.d.ts +810 -0
- package/components/bubble-list/src/types.d.ts +4 -0
- package/components/bubble-templates/index.d.ts +4 -0
- package/components/bubble-templates/index.mjs +83 -68
- package/components/bubble-templates/src/index.vue.d.ts +595 -0
- package/components/bubble-templates/src/types.d.ts +40 -0
- package/components/chat-independent/index.d.ts +4 -0
- package/components/chat-independent/index.mjs +136 -115
- package/components/chat-independent/src/const.d.ts +13 -0
- package/components/chat-independent/src/ctx.d.ts +21 -0
- package/components/chat-independent/src/index.vue.d.ts +2429 -0
- package/components/chat-independent/src/types.d.ts +13 -0
- package/components/colorToUniform.mjs +2 -0
- package/components/index.d.ts +0 -0
- package/components/index2.mjs +11896 -8381
- package/components/init.mjs +1724 -998
- package/components/lottie-animation/index.d.ts +4 -0
- package/components/lottie-animation/index.mjs +2 -2
- package/components/lottie-animation/src/ctx.d.ts +10 -0
- package/components/lottie-animation/src/index.vue.d.ts +21 -0
- package/components/lottie-animation/src/types.d.ts +4 -0
- package/components/metahuman-broadcasting/index.d.ts +5 -0
- package/components/metahuman-broadcasting/index.mjs +57 -40
- package/components/metahuman-broadcasting/src/ctx.d.ts +57 -0
- package/components/metahuman-broadcasting/src/index.vue.d.ts +885 -0
- package/components/metahuman-broadcasting/src/types.d.ts +1 -0
- package/components/monaco-editor/index.d.ts +5 -0
- package/components/monaco-editor/index.mjs +2 -2
- package/components/monaco-editor/src/ctx.d.ts +23 -0
- package/components/monaco-editor/src/index.vue.d.ts +40 -0
- package/components/monaco-editor/src/types.d.ts +1 -0
- package/components/monaco-environment/index.d.ts +4 -0
- package/components/monaco-environment/index.mjs +1 -1
- package/components/monaco-environment/src/ctx.d.ts +8 -0
- package/components/monaco-environment/src/index.vue.d.ts +2 -0
- package/components/monaco-environment/src/types.d.ts +1 -0
- package/components/pixi-frame/index.d.ts +11 -0
- package/components/pixi-frame/index.mjs +2 -2
- package/components/pixi-frame/src/apng.vue.d.ts +161 -0
- package/components/pixi-frame/src/bitmap.vue.d.ts +158 -0
- package/components/pixi-frame/src/core.vue.d.ts +173 -0
- package/components/pixi-frame/src/ctx.d.ts +55 -0
- package/components/pixi-frame/src/index.vue.d.ts +591 -0
- package/components/pixi-frame/src/provider.vue.d.ts +2 -0
- package/components/pixi-frame/src/types.d.ts +17 -0
- package/components/pixi-frame/src/use.d.ts +16 -0
- package/components/pixi-frame/src/useSprite.d.ts +12 -0
- package/components/pixi-frame/src/video.vue.d.ts +159 -0
- package/components/pixi-frame/src/view.vue.d.ts +29 -0
- package/components/recorder-button/index.d.ts +4 -0
- package/components/recorder-button/index.mjs +2 -2
- package/components/recorder-button/src/ctx.d.ts +41 -0
- package/components/recorder-button/src/index.vue.d.ts +333 -0
- package/components/recorder-button/src/speech-to-text.d.ts +1 -0
- package/components/recorder-button/src/types.d.ts +7 -0
- package/components/routes-menu-content/index.d.ts +4 -0
- package/components/routes-menu-content/index.mjs +5 -5
- package/components/routes-menu-content/src/ctx.d.ts +17 -0
- package/components/routes-menu-content/src/index.vue.d.ts +350 -0
- package/components/routes-menu-content/src/item/core/ctx.d.ts +18 -0
- package/components/routes-menu-content/src/item/core/index.vue.d.ts +185 -0
- package/components/routes-menu-content/src/item/ctx.d.ts +14 -0
- package/components/routes-menu-content/src/item/index.vue.d.ts +316 -0
- package/components/routes-menu-content/src/types.d.ts +1 -0
- package/components/sender/index.d.ts +4 -0
- package/components/sender/index.mjs +180 -86
- package/components/sender/src/SenderHeader.vue.d.ts +270 -0
- package/components/sender/src/ctx.d.ts +64 -0
- package/components/sender/src/index.vue.d.ts +779 -0
- package/components/sender/src/types.d.ts +1 -0
- package/components/speech-button/index.d.ts +4 -0
- package/components/speech-button/index.mjs +13 -6
- package/components/speech-button/src/LoadingIcon.vue.d.ts +2 -0
- package/components/speech-button/src/RecordingIcon.vue.d.ts +2 -0
- package/components/speech-button/src/ctx.d.ts +10 -0
- package/components/speech-button/src/index.vue.d.ts +22 -0
- package/components/speech-button/src/types.d.ts +1 -0
- package/components/table-columns/index.d.ts +5 -0
- package/components/table-columns/index.mjs +6 -3
- package/components/table-columns/src/ctx.d.ts +59 -0
- package/components/table-columns/src/el-ctx.d.ts +57 -0
- package/components/table-columns/src/index.vue.d.ts +266 -0
- package/components/table-columns/src/types.d.ts +21 -0
- package/components/tables-v1/index.d.ts +5 -0
- package/components/tables-v1/index.mjs +3 -3
- package/components/tables-v1/src/ctx.d.ts +280 -0
- package/components/tables-v1/src/el-ctx.d.ts +262 -0
- package/components/tables-v1/src/index.vue.d.ts +3054 -0
- package/components/tables-v1/src/types.d.ts +3 -0
- package/components/tables-v1-checkbox/index.d.ts +5 -0
- package/components/tables-v1-checkbox/index.mjs +33 -269
- package/components/tables-v1-checkbox/src/ctx.d.ts +313 -0
- package/components/tables-v1-checkbox/src/index.vue.d.ts +3831 -0
- package/components/tables-v1-checkbox/src/types.d.ts +1 -0
- package/components/text/index.d.ts +4 -0
- package/components/text/index.mjs +52 -42
- package/components/text/src/ctx.d.ts +341 -0
- package/components/text/src/index.vue.d.ts +4593 -0
- package/components/text/src/types.d.ts +1 -0
- package/components/typing-markdown/index.d.ts +4 -0
- package/components/typing-markdown/index.mjs +2 -2
- package/components/typing-markdown/src/core.d.ts +2 -0
- package/components/typing-markdown/src/ctx.d.ts +41 -0
- package/components/typing-markdown/src/index.vue.d.ts +75 -0
- package/components/typing-markdown/src/types.d.ts +1 -0
- package/components/vditor/index.d.ts +5 -0
- package/components/vditor/index.mjs +9 -5
- package/components/vditor/src/ctx.d.ts +38 -0
- package/components/vditor/src/handle-fullscreen.vue.d.ts +18 -0
- package/components/vditor/src/handle-value.vue.d.ts +18 -0
- package/components/vditor/src/index.vue.d.ts +143 -0
- package/components/vditor/src/types.d.ts +9 -0
- package/components/vditor/src/use.d.ts +4 -0
- package/components/webworkerAll.mjs +1 -1
- package/composables/el-breakpoints/index.d.ts +5 -5
- package/composables/recorder/index.mjs +191 -288
- package/icons/end/index.mjs +3 -3
- package/icons/end/src/avatar.d.ts +2 -11
- package/icons/end/src/icon.d.ts +2 -56
- package/icons/keyboard/index.mjs +3 -3
- package/icons/keyboard/src/avatar.d.ts +2 -11
- package/icons/keyboard/src/icon.d.ts +2 -56
- package/icons/start/index.mjs +3 -3
- package/icons/start/src/avatar.d.ts +2 -11
- package/icons/start/src/icon.d.ts +2 -56
- package/icons/voice/index.mjs +2 -2
- package/icons/voice/src/avatar.d.ts +2 -11
- package/icons/voice/src/icon.d.ts +2 -56
- package/package.json +1 -1
- package/shared/audioToFrames/index.mjs +10 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { P as Point,
|
|
1
|
+
import { P as Point, E as ExtensionType, r as removeItems, T as Ticker, U as UPDATE_PRIORITY, a as EventEmitter, w as warn, e as extensions, C as Container } from './index2.mjs';
|
|
2
2
|
import './init.mjs';
|
|
3
3
|
import 'vue';
|
|
4
4
|
import '@vunk/shared/enum';
|
|
5
5
|
import '@vunk/shared/promise';
|
|
6
6
|
import './_commonjsHelpers.mjs';
|
|
7
|
+
import './_plugin-vue_export-helper.mjs';
|
|
7
8
|
import '@vunk/core/composables';
|
|
8
9
|
import '@vunk/shared/object';
|
|
9
|
-
import './_plugin-vue_export-helper.mjs';
|
|
10
10
|
import './colorToUniform.mjs';
|
|
11
11
|
|
|
12
12
|
class FederatedEvent {
|
|
@@ -25,9 +25,10 @@ class FederatedEvent {
|
|
|
25
25
|
*/
|
|
26
26
|
this.cancelable = false;
|
|
27
27
|
/**
|
|
28
|
-
* Flag added for compatibility with DOM
|
|
28
|
+
* Flag added for compatibility with DOM `Event`. It is not used in the Federated Events
|
|
29
29
|
* API.
|
|
30
30
|
* @see https://dom.spec.whatwg.org/#dom-event-composed
|
|
31
|
+
* @ignore
|
|
31
32
|
*/
|
|
32
33
|
this.composed = false;
|
|
33
34
|
/** Flags whether the default response of the user agent was prevent through this event. */
|
|
@@ -45,9 +46,29 @@ class FederatedEvent {
|
|
|
45
46
|
this.layer = new Point();
|
|
46
47
|
/** The coordinates of the event relative to the DOM document. This is a non-standard property. */
|
|
47
48
|
this.page = new Point();
|
|
49
|
+
/**
|
|
50
|
+
* The event propagation phase NONE that indicates that the event is not in any phase.
|
|
51
|
+
* @default 0
|
|
52
|
+
* @advanced
|
|
53
|
+
*/
|
|
48
54
|
this.NONE = 0;
|
|
55
|
+
/**
|
|
56
|
+
* The event propagation phase CAPTURING_PHASE that indicates that the event is in the capturing phase.
|
|
57
|
+
* @default 1
|
|
58
|
+
* @advanced
|
|
59
|
+
*/
|
|
49
60
|
this.CAPTURING_PHASE = 1;
|
|
61
|
+
/**
|
|
62
|
+
* The event propagation phase AT_TARGET that indicates that the event is at the target.
|
|
63
|
+
* @default 2
|
|
64
|
+
* @advanced
|
|
65
|
+
*/
|
|
50
66
|
this.AT_TARGET = 2;
|
|
67
|
+
/**
|
|
68
|
+
* The event propagation phase BUBBLING_PHASE that indicates that the event is in the bubbling phase.
|
|
69
|
+
* @default 3
|
|
70
|
+
* @advanced
|
|
71
|
+
*/
|
|
51
72
|
this.BUBBLING_PHASE = 3;
|
|
52
73
|
this.manager = manager;
|
|
53
74
|
}
|
|
@@ -68,13 +89,16 @@ class FederatedEvent {
|
|
|
68
89
|
return this.page.y;
|
|
69
90
|
}
|
|
70
91
|
/**
|
|
71
|
-
* Fallback for the deprecated
|
|
92
|
+
* Fallback for the deprecated `InteractionEvent.data`.
|
|
72
93
|
* @deprecated since 7.0.0
|
|
73
94
|
*/
|
|
74
95
|
get data() {
|
|
75
96
|
return this;
|
|
76
97
|
}
|
|
77
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* The propagation path for this event. Alias for {@link EventBoundary.propagationPath}.
|
|
100
|
+
* @advanced
|
|
101
|
+
*/
|
|
78
102
|
composedPath() {
|
|
79
103
|
if (this.manager && (!this.path || this.path[this.path.length - 1] !== this.target)) {
|
|
80
104
|
this.path = this.target ? this.manager.propagationPath(this.target) : [];
|
|
@@ -82,8 +106,9 @@ class FederatedEvent {
|
|
|
82
106
|
return this.path;
|
|
83
107
|
}
|
|
84
108
|
/**
|
|
85
|
-
* Unimplemented method included for implementing the DOM interface
|
|
109
|
+
* Unimplemented method included for implementing the DOM interface `Event`. It will throw an `Error`.
|
|
86
110
|
* @deprecated
|
|
111
|
+
* @ignore
|
|
87
112
|
* @param _type
|
|
88
113
|
* @param _bubbles
|
|
89
114
|
* @param _cancelable
|
|
@@ -92,7 +117,8 @@ class FederatedEvent {
|
|
|
92
117
|
throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.");
|
|
93
118
|
}
|
|
94
119
|
/**
|
|
95
|
-
* Unimplemented method included for implementing the DOM interface
|
|
120
|
+
* Unimplemented method included for implementing the DOM interface `UIEvent`. It will throw an `Error`.
|
|
121
|
+
* @ignore
|
|
96
122
|
* @deprecated
|
|
97
123
|
* @param _typeArg
|
|
98
124
|
* @param _bubblesArg
|
|
@@ -103,7 +129,23 @@ class FederatedEvent {
|
|
|
103
129
|
initUIEvent(_typeArg, _bubblesArg, _cancelableArg, _viewArg, _detailArg) {
|
|
104
130
|
throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.");
|
|
105
131
|
}
|
|
106
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Prevent default behavior of both PixiJS and the user agent.
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* sprite.on('click', (event) => {
|
|
137
|
+
* // Prevent both browser's default click behavior
|
|
138
|
+
* // and PixiJS's default handling
|
|
139
|
+
* event.preventDefault();
|
|
140
|
+
*
|
|
141
|
+
* // Custom handling
|
|
142
|
+
* customClickHandler();
|
|
143
|
+
* });
|
|
144
|
+
* ```
|
|
145
|
+
* @remarks
|
|
146
|
+
* - Only works if the native event is cancelable
|
|
147
|
+
* - Does not stop event propagation
|
|
148
|
+
*/
|
|
107
149
|
preventDefault() {
|
|
108
150
|
if (this.nativeEvent instanceof Event && this.nativeEvent.cancelable) {
|
|
109
151
|
this.nativeEvent.preventDefault();
|
|
@@ -111,16 +153,49 @@ class FederatedEvent {
|
|
|
111
153
|
this.defaultPrevented = true;
|
|
112
154
|
}
|
|
113
155
|
/**
|
|
114
|
-
* Stop this event from propagating to any
|
|
115
|
-
*
|
|
116
|
-
*
|
|
156
|
+
* Stop this event from propagating to any additional listeners, including those
|
|
157
|
+
* on the current target and any following targets in the propagation path.
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* container.on('pointerdown', (event) => {
|
|
161
|
+
* // Stop all further event handling
|
|
162
|
+
* event.stopImmediatePropagation();
|
|
163
|
+
*
|
|
164
|
+
* // These handlers won't be called:
|
|
165
|
+
* // - Other pointerdown listeners on this container
|
|
166
|
+
* // - Any pointerdown listeners on parent containers
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
* @remarks
|
|
170
|
+
* - Immediately stops all event propagation
|
|
171
|
+
* - Prevents other listeners on same target from being called
|
|
172
|
+
* - More aggressive than stopPropagation()
|
|
117
173
|
*/
|
|
118
174
|
stopImmediatePropagation() {
|
|
119
175
|
this.propagationImmediatelyStopped = true;
|
|
120
176
|
}
|
|
121
177
|
/**
|
|
122
|
-
* Stop this event from propagating to the next
|
|
123
|
-
* on the
|
|
178
|
+
* Stop this event from propagating to the next target in the propagation path.
|
|
179
|
+
* The rest of the listeners on the current target will still be notified.
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* child.on('pointermove', (event) => {
|
|
183
|
+
* // Handle event on child
|
|
184
|
+
* updateChild();
|
|
185
|
+
*
|
|
186
|
+
* // Prevent parent handlers from being called
|
|
187
|
+
* event.stopPropagation();
|
|
188
|
+
* });
|
|
189
|
+
*
|
|
190
|
+
* // This won't be called if child handles the event
|
|
191
|
+
* parent.on('pointermove', (event) => {
|
|
192
|
+
* updateParent();
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
* @remarks
|
|
196
|
+
* - Stops event bubbling to parent containers
|
|
197
|
+
* - Does not prevent other listeners on same target
|
|
198
|
+
* - Less aggressive than stopImmediatePropagation()
|
|
124
199
|
*/
|
|
125
200
|
stopPropagation() {
|
|
126
201
|
this.propagationStopped = true;
|
|
@@ -302,7 +377,7 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
302
377
|
}
|
|
303
378
|
/**
|
|
304
379
|
* Value of `true` if accessibility is currently active and accessibility layers are showing.
|
|
305
|
-
* @
|
|
380
|
+
* @type {boolean}
|
|
306
381
|
* @readonly
|
|
307
382
|
*/
|
|
308
383
|
get isActive() {
|
|
@@ -310,12 +385,16 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
310
385
|
}
|
|
311
386
|
/**
|
|
312
387
|
* Value of `true` if accessibility is enabled for touch devices.
|
|
313
|
-
* @
|
|
388
|
+
* @type {boolean}
|
|
314
389
|
* @readonly
|
|
315
390
|
*/
|
|
316
391
|
get isMobileAccessibility() {
|
|
317
392
|
return this._isMobileAccessibility;
|
|
318
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* The DOM element that will sit over the PixiJS element. This is where the div overlays will go.
|
|
396
|
+
* @readonly
|
|
397
|
+
*/
|
|
319
398
|
get hookDiv() {
|
|
320
399
|
return this._hookDiv;
|
|
321
400
|
}
|
|
@@ -719,7 +798,11 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
719
798
|
}
|
|
720
799
|
this._deactivate();
|
|
721
800
|
}
|
|
722
|
-
/**
|
|
801
|
+
/**
|
|
802
|
+
* Destroys the accessibility system. Removes all elements and listeners.
|
|
803
|
+
* > [!IMPORTANT] This is typically called automatically when the {@link Application} is destroyed.
|
|
804
|
+
* > A typically user should not need to call this method directly.
|
|
805
|
+
*/
|
|
723
806
|
destroy() {
|
|
724
807
|
this._deactivate();
|
|
725
808
|
this._destroyTouchHook();
|
|
@@ -734,6 +817,11 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
734
817
|
/**
|
|
735
818
|
* Enables or disables the accessibility system.
|
|
736
819
|
* @param enabled - Whether to enable or disable accessibility.
|
|
820
|
+
* @example
|
|
821
|
+
* ```js
|
|
822
|
+
* app.renderer.accessibility.setAccessibilityEnabled(true); // Enable accessibility
|
|
823
|
+
* app.renderer.accessibility.setAccessibilityEnabled(false); // Disable accessibility
|
|
824
|
+
* ```
|
|
737
825
|
*/
|
|
738
826
|
setAccessibilityEnabled(enabled) {
|
|
739
827
|
if (enabled) {
|
|
@@ -751,7 +839,19 @@ _AccessibilitySystem.extension = {
|
|
|
751
839
|
],
|
|
752
840
|
name: "accessibility"
|
|
753
841
|
};
|
|
754
|
-
/**
|
|
842
|
+
/**
|
|
843
|
+
* The default options used by the system.
|
|
844
|
+
* You can set these before initializing the {@link Application} to change the default behavior.
|
|
845
|
+
* @example
|
|
846
|
+
* ```js
|
|
847
|
+
* import { AccessibilitySystem } from 'pixi.js';
|
|
848
|
+
*
|
|
849
|
+
* AccessibilitySystem.defaultOptions.enabledByDefault = true;
|
|
850
|
+
*
|
|
851
|
+
* const app = new Application()
|
|
852
|
+
* app.init()
|
|
853
|
+
* ```
|
|
854
|
+
*/
|
|
755
855
|
_AccessibilitySystem.defaultOptions = {
|
|
756
856
|
/**
|
|
757
857
|
* Whether to enable accessibility features on initialization
|
|
@@ -777,78 +877,16 @@ _AccessibilitySystem.defaultOptions = {
|
|
|
777
877
|
let AccessibilitySystem = _AccessibilitySystem;
|
|
778
878
|
|
|
779
879
|
const accessibilityTarget = {
|
|
780
|
-
/**
|
|
781
|
-
* Flag for if the object is accessible. If true AccessibilityManager will overlay a
|
|
782
|
-
* shadow div with attributes set
|
|
783
|
-
* @member {boolean}
|
|
784
|
-
* @memberof scene.Container#
|
|
785
|
-
*/
|
|
786
880
|
accessible: false,
|
|
787
|
-
/**
|
|
788
|
-
* Sets the title attribute of the shadow div
|
|
789
|
-
* If accessibleTitle AND accessibleHint has not been this will default to 'container [tabIndex]'
|
|
790
|
-
* @member {string}
|
|
791
|
-
* @memberof scene.Container#
|
|
792
|
-
*/
|
|
793
881
|
accessibleTitle: null,
|
|
794
|
-
/**
|
|
795
|
-
* Sets the aria-label attribute of the shadow div
|
|
796
|
-
* @member {string}
|
|
797
|
-
* @memberof scene.Container#
|
|
798
|
-
*/
|
|
799
882
|
accessibleHint: null,
|
|
800
|
-
/**
|
|
801
|
-
* @member {number}
|
|
802
|
-
* @memberof scene.Container#
|
|
803
|
-
* @todo Needs docs.
|
|
804
|
-
*/
|
|
805
883
|
tabIndex: 0,
|
|
806
|
-
/**
|
|
807
|
-
* @member {boolean}
|
|
808
|
-
* @memberof scene.Container#
|
|
809
|
-
* @private
|
|
810
|
-
*/
|
|
811
|
-
_accessibleActive: false,
|
|
812
|
-
/**
|
|
813
|
-
* @memberof scene.Container#
|
|
814
|
-
* @private
|
|
815
|
-
*/
|
|
816
|
-
_accessibleDiv: null,
|
|
817
|
-
/**
|
|
818
|
-
* Specify the type of div the accessible layer is. Screen readers treat the element differently
|
|
819
|
-
* depending on this type. Defaults to button.
|
|
820
|
-
* @member {string}
|
|
821
|
-
* @memberof scene.Container#
|
|
822
|
-
* @default 'button'
|
|
823
|
-
*/
|
|
824
884
|
accessibleType: "button",
|
|
825
|
-
/**
|
|
826
|
-
* Sets the text content of the shadow div
|
|
827
|
-
* @member {string}
|
|
828
|
-
* @memberof scene.Container#
|
|
829
|
-
*/
|
|
830
885
|
accessibleText: null,
|
|
831
|
-
/**
|
|
832
|
-
* Specify the pointer-events the accessible div will use
|
|
833
|
-
* Defaults to auto.
|
|
834
|
-
* @type {PointerEvents}
|
|
835
|
-
* @memberof scene.Container#
|
|
836
|
-
* @default 'auto'
|
|
837
|
-
*/
|
|
838
886
|
accessiblePointerEvents: "auto",
|
|
839
|
-
/**
|
|
840
|
-
* Setting to false will prevent any children inside this container to
|
|
841
|
-
* be accessible. Defaults to true.
|
|
842
|
-
* @member {boolean}
|
|
843
|
-
* @memberof scene.Container#
|
|
844
|
-
* @default true
|
|
845
|
-
*/
|
|
846
887
|
accessibleChildren: true,
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
* @memberof scene.Container#
|
|
850
|
-
* @private
|
|
851
|
-
*/
|
|
888
|
+
_accessibleActive: false,
|
|
889
|
+
_accessibleDiv: null,
|
|
852
890
|
_renderId: -1
|
|
853
891
|
};
|
|
854
892
|
|
|
@@ -858,7 +896,6 @@ class DOMPipe {
|
|
|
858
896
|
* @param renderer - The renderer instance that this DOMPipe will be associated with.
|
|
859
897
|
*/
|
|
860
898
|
constructor(renderer) {
|
|
861
|
-
this._destroyRenderableBound = this.destroyRenderable.bind(this);
|
|
862
899
|
/** Array to keep track of attached DOM elements */
|
|
863
900
|
this._attachedDomElements = [];
|
|
864
901
|
this._renderer = renderer;
|
|
@@ -878,7 +915,6 @@ class DOMPipe {
|
|
|
878
915
|
addRenderable(domContainer, _instructionSet) {
|
|
879
916
|
if (!this._attachedDomElements.includes(domContainer)) {
|
|
880
917
|
this._attachedDomElements.push(domContainer);
|
|
881
|
-
domContainer.on("destroyed", this._destroyRenderableBound);
|
|
882
918
|
}
|
|
883
919
|
}
|
|
884
920
|
/**
|
|
@@ -895,17 +931,6 @@ class DOMPipe {
|
|
|
895
931
|
validateRenderable(_domContainer) {
|
|
896
932
|
return true;
|
|
897
933
|
}
|
|
898
|
-
/**
|
|
899
|
-
* Destroys a renderable DOM container, removing it from the list of attached elements.
|
|
900
|
-
* @param domContainer - The DOM container to be destroyed.
|
|
901
|
-
*/
|
|
902
|
-
destroyRenderable(domContainer) {
|
|
903
|
-
const index = this._attachedDomElements.indexOf(domContainer);
|
|
904
|
-
if (index !== -1) {
|
|
905
|
-
this._attachedDomElements.splice(index, 1);
|
|
906
|
-
}
|
|
907
|
-
domContainer.off("destroyed", this._destroyRenderableBound);
|
|
908
|
-
}
|
|
909
934
|
/** Handles the post-rendering process, ensuring DOM elements are correctly positioned and visible. */
|
|
910
935
|
postrender() {
|
|
911
936
|
const attachedDomElements = this._attachedDomElements;
|
|
@@ -917,12 +942,14 @@ class DOMPipe {
|
|
|
917
942
|
if (this._domElement.parentNode !== canvas.parentNode) {
|
|
918
943
|
canvas.parentNode?.appendChild(this._domElement);
|
|
919
944
|
}
|
|
920
|
-
|
|
945
|
+
const sx = parseFloat(canvas.style.width) / canvas.width * this._renderer.resolution;
|
|
946
|
+
const sy = parseFloat(canvas.style.height) / canvas.height * this._renderer.resolution;
|
|
947
|
+
this._domElement.style.transform = `translate(${canvas.offsetLeft}px, ${canvas.offsetTop}px) scale(${sx}, ${sy})`;
|
|
921
948
|
for (let i = 0; i < attachedDomElements.length; i++) {
|
|
922
949
|
const domContainer = attachedDomElements[i];
|
|
923
950
|
const element = domContainer.element;
|
|
924
951
|
if (!domContainer.parent || domContainer.globalDisplayStatus < 7) {
|
|
925
|
-
element
|
|
952
|
+
element?.remove();
|
|
926
953
|
attachedDomElements.splice(i, 1);
|
|
927
954
|
i--;
|
|
928
955
|
} else {
|
|
@@ -946,8 +973,7 @@ class DOMPipe {
|
|
|
946
973
|
this._renderer.runners.postrender.remove(this);
|
|
947
974
|
for (let i = 0; i < this._attachedDomElements.length; i++) {
|
|
948
975
|
const domContainer = this._attachedDomElements[i];
|
|
949
|
-
domContainer.
|
|
950
|
-
domContainer.element.remove();
|
|
976
|
+
domContainer.element?.remove();
|
|
951
977
|
}
|
|
952
978
|
this._attachedDomElements.length = 0;
|
|
953
979
|
this._domElement.remove();
|
|
@@ -1029,11 +1055,14 @@ class EventsTickerClass {
|
|
|
1029
1055
|
if (this.events.supportsTouchEvents && rootPointerEvent.pointerType === "touch") {
|
|
1030
1056
|
return;
|
|
1031
1057
|
}
|
|
1032
|
-
globalThis.document.dispatchEvent(new PointerEvent("pointermove", {
|
|
1058
|
+
globalThis.document.dispatchEvent(this.events.supportsPointerEvents ? new PointerEvent("pointermove", {
|
|
1033
1059
|
clientX: rootPointerEvent.clientX,
|
|
1034
1060
|
clientY: rootPointerEvent.clientY,
|
|
1035
1061
|
pointerType: rootPointerEvent.pointerType,
|
|
1036
1062
|
pointerId: rootPointerEvent.pointerId
|
|
1063
|
+
}) : new MouseEvent("mousemove", {
|
|
1064
|
+
clientX: rootPointerEvent.clientX,
|
|
1065
|
+
clientY: rootPointerEvent.clientY
|
|
1037
1066
|
}));
|
|
1038
1067
|
}
|
|
1039
1068
|
/**
|
|
@@ -1066,7 +1095,7 @@ class FederatedMouseEvent extends FederatedEvent {
|
|
|
1066
1095
|
/** The pointer coordinates in world space. */
|
|
1067
1096
|
this.global = new Point();
|
|
1068
1097
|
/**
|
|
1069
|
-
* The pointer coordinates in the renderer's {@link
|
|
1098
|
+
* The pointer coordinates in the renderer's {@link AbstractRenderer.screen screen}. This has slightly
|
|
1070
1099
|
* different semantics than native PointerEvent screenX/screenY.
|
|
1071
1100
|
*/
|
|
1072
1101
|
this.screen = new Point();
|
|
@@ -1118,29 +1147,46 @@ class FederatedMouseEvent extends FederatedEvent {
|
|
|
1118
1147
|
return this.global.y;
|
|
1119
1148
|
}
|
|
1120
1149
|
/**
|
|
1121
|
-
* The pointer coordinates in the renderer's screen. Alias for
|
|
1150
|
+
* The pointer coordinates in the renderer's screen. Alias for `screen.x`.
|
|
1122
1151
|
* @readonly
|
|
1123
1152
|
*/
|
|
1124
1153
|
get screenX() {
|
|
1125
1154
|
return this.screen.x;
|
|
1126
1155
|
}
|
|
1127
1156
|
/**
|
|
1128
|
-
* The pointer coordinates in the renderer's screen. Alias for
|
|
1157
|
+
* The pointer coordinates in the renderer's screen. Alias for `screen.y`.
|
|
1129
1158
|
* @readonly
|
|
1130
1159
|
*/
|
|
1131
1160
|
get screenY() {
|
|
1132
1161
|
return this.screen.y;
|
|
1133
1162
|
}
|
|
1134
1163
|
/**
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1137
|
-
*
|
|
1138
|
-
*
|
|
1139
|
-
*
|
|
1140
|
-
* @param
|
|
1141
|
-
*
|
|
1142
|
-
* @returns
|
|
1143
|
-
*
|
|
1164
|
+
* Converts global coordinates into container-local coordinates.
|
|
1165
|
+
*
|
|
1166
|
+
* This method transforms coordinates from world space to a container's local space,
|
|
1167
|
+
* useful for precise positioning and hit testing.
|
|
1168
|
+
* @param container - The Container to get local coordinates for
|
|
1169
|
+
* @param point - Optional Point object to store the result. If not provided, a new Point will be created
|
|
1170
|
+
* @param globalPos - Optional custom global coordinates. If not provided, the event's global position is used
|
|
1171
|
+
* @returns The local coordinates as a Point object
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```ts
|
|
1174
|
+
* // Basic usage - get local coordinates relative to a container
|
|
1175
|
+
* sprite.on('pointermove', (event: FederatedMouseEvent) => {
|
|
1176
|
+
* // Get position relative to the sprite
|
|
1177
|
+
* const localPos = event.getLocalPosition(sprite);
|
|
1178
|
+
* console.log('Local position:', localPos.x, localPos.y);
|
|
1179
|
+
* });
|
|
1180
|
+
* // Using custom global coordinates
|
|
1181
|
+
* const customGlobal = new Point(100, 100);
|
|
1182
|
+
* sprite.on('pointermove', (event: FederatedMouseEvent) => {
|
|
1183
|
+
* // Transform custom coordinates
|
|
1184
|
+
* const localPos = event.getLocalPosition(sprite, undefined, customGlobal);
|
|
1185
|
+
* console.log('Custom local position:', localPos.x, localPos.y);
|
|
1186
|
+
* });
|
|
1187
|
+
* ```
|
|
1188
|
+
* @see {@link Container.worldTransform} For the transformation matrix
|
|
1189
|
+
* @see {@link Point} For the point class used to store coordinates
|
|
1144
1190
|
*/
|
|
1145
1191
|
getLocalPosition(container, point, globalPos) {
|
|
1146
1192
|
return container.worldTransform.applyInverse(globalPos || this.global, point);
|
|
@@ -1170,6 +1216,7 @@ class FederatedMouseEvent extends FederatedEvent {
|
|
|
1170
1216
|
* @param _buttonArg
|
|
1171
1217
|
* @param _relatedTargetArg
|
|
1172
1218
|
* @deprecated since 7.0.0
|
|
1219
|
+
* @ignore
|
|
1173
1220
|
*/
|
|
1174
1221
|
// eslint-disable-next-line max-params
|
|
1175
1222
|
initMouseEvent(_typeArg, _canBubbleArg, _cancelableArg, _viewArg, _detailArg, _screenXArg, _screenYArg, _clientXArg, _clientYArg, _ctrlKeyArg, _altKeyArg, _shiftKeyArg, _metaKeyArg, _buttonArg, _relatedTargetArg) {
|
|
@@ -1198,14 +1245,20 @@ class FederatedPointerEvent extends FederatedMouseEvent {
|
|
|
1198
1245
|
*/
|
|
1199
1246
|
this.isPrimary = false;
|
|
1200
1247
|
}
|
|
1201
|
-
|
|
1248
|
+
/**
|
|
1249
|
+
* Only included for completeness for now
|
|
1250
|
+
* @ignore
|
|
1251
|
+
*/
|
|
1202
1252
|
getCoalescedEvents() {
|
|
1203
1253
|
if (this.type === "pointermove" || this.type === "mousemove" || this.type === "touchmove") {
|
|
1204
1254
|
return [this];
|
|
1205
1255
|
}
|
|
1206
1256
|
return [];
|
|
1207
1257
|
}
|
|
1208
|
-
|
|
1258
|
+
/**
|
|
1259
|
+
* Only included for completeness for now
|
|
1260
|
+
* @ignore
|
|
1261
|
+
*/
|
|
1209
1262
|
getPredictedEvents() {
|
|
1210
1263
|
throw new Error("getPredictedEvents is not supported!");
|
|
1211
1264
|
}
|
|
@@ -1214,19 +1267,37 @@ class FederatedPointerEvent extends FederatedMouseEvent {
|
|
|
1214
1267
|
class FederatedWheelEvent extends FederatedMouseEvent {
|
|
1215
1268
|
constructor() {
|
|
1216
1269
|
super(...arguments);
|
|
1217
|
-
/**
|
|
1270
|
+
/**
|
|
1271
|
+
* Units specified in pixels.
|
|
1272
|
+
* @ignore
|
|
1273
|
+
*/
|
|
1218
1274
|
this.DOM_DELTA_PIXEL = 0;
|
|
1219
|
-
/**
|
|
1275
|
+
/**
|
|
1276
|
+
* Units specified in lines.
|
|
1277
|
+
* @ignore
|
|
1278
|
+
*/
|
|
1220
1279
|
this.DOM_DELTA_LINE = 1;
|
|
1221
|
-
/**
|
|
1280
|
+
/**
|
|
1281
|
+
* Units specified in pages.
|
|
1282
|
+
* @ignore
|
|
1283
|
+
*/
|
|
1222
1284
|
this.DOM_DELTA_PAGE = 2;
|
|
1223
1285
|
}
|
|
1224
1286
|
}
|
|
1225
|
-
/**
|
|
1287
|
+
/**
|
|
1288
|
+
* Units specified in pixels.
|
|
1289
|
+
* @ignore
|
|
1290
|
+
*/
|
|
1226
1291
|
FederatedWheelEvent.DOM_DELTA_PIXEL = 0;
|
|
1227
|
-
/**
|
|
1292
|
+
/**
|
|
1293
|
+
* Units specified in lines.
|
|
1294
|
+
* @ignore
|
|
1295
|
+
*/
|
|
1228
1296
|
FederatedWheelEvent.DOM_DELTA_LINE = 1;
|
|
1229
|
-
/**
|
|
1297
|
+
/**
|
|
1298
|
+
* Units specified in pages.
|
|
1299
|
+
* @ignore
|
|
1300
|
+
*/
|
|
1230
1301
|
FederatedWheelEvent.DOM_DELTA_PAGE = 2;
|
|
1231
1302
|
|
|
1232
1303
|
const PROPAGATION_LIMIT = 2048;
|
|
@@ -1367,7 +1438,7 @@ class EventBoundary {
|
|
|
1367
1438
|
}
|
|
1368
1439
|
/**
|
|
1369
1440
|
* Propagate the passed event from from {@link EventBoundary.rootTarget this.rootTarget} to its
|
|
1370
|
-
* target
|
|
1441
|
+
* target `e.target`.
|
|
1371
1442
|
* @param e - The event to propagate.
|
|
1372
1443
|
* @param type - The type of event to propagate. Defaults to `e.type`.
|
|
1373
1444
|
*/
|
|
@@ -1397,7 +1468,7 @@ class EventBoundary {
|
|
|
1397
1468
|
}
|
|
1398
1469
|
}
|
|
1399
1470
|
/**
|
|
1400
|
-
* Emits the event
|
|
1471
|
+
* Emits the event `e` to all interactive containers. The event is propagated in the bubbling phase always.
|
|
1401
1472
|
*
|
|
1402
1473
|
* This is used in the `globalpointermove` event.
|
|
1403
1474
|
* @param e - The emitted event.
|
|
@@ -1418,7 +1489,7 @@ class EventBoundary {
|
|
|
1418
1489
|
}
|
|
1419
1490
|
/**
|
|
1420
1491
|
* Finds the propagation path from {@link EventBoundary.rootTarget rootTarget} to the passed
|
|
1421
|
-
*
|
|
1492
|
+
* `target`. The last element in the path is `target`.
|
|
1422
1493
|
* @param target - The target to find the propagation path to.
|
|
1423
1494
|
*/
|
|
1424
1495
|
propagationPath(target) {
|
|
@@ -1934,10 +2005,10 @@ class EventBoundary {
|
|
|
1934
2005
|
return currentTarget;
|
|
1935
2006
|
}
|
|
1936
2007
|
/**
|
|
1937
|
-
* Creates an event whose
|
|
2008
|
+
* Creates an event whose `originalEvent` is `from`, with an optional `type` and `target` override.
|
|
1938
2009
|
*
|
|
1939
2010
|
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
|
1940
|
-
* @param from - The
|
|
2011
|
+
* @param from - The `originalEvent` for the returned event.
|
|
1941
2012
|
* @param [type=from.type] - The type of the returned event.
|
|
1942
2013
|
* @param target - The target of the returned event.
|
|
1943
2014
|
*/
|
|
@@ -1955,7 +2026,7 @@ class EventBoundary {
|
|
|
1955
2026
|
return event;
|
|
1956
2027
|
}
|
|
1957
2028
|
/**
|
|
1958
|
-
* Creates a wheel event whose
|
|
2029
|
+
* Creates a wheel event whose `originalEvent` is `from`.
|
|
1959
2030
|
*
|
|
1960
2031
|
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
|
1961
2032
|
* @param from - The upstream wheel event.
|
|
@@ -1971,7 +2042,7 @@ class EventBoundary {
|
|
|
1971
2042
|
return event;
|
|
1972
2043
|
}
|
|
1973
2044
|
/**
|
|
1974
|
-
* Clones the event
|
|
2045
|
+
* Clones the event `from`, with an optional `type` override.
|
|
1975
2046
|
*
|
|
1976
2047
|
* The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
|
|
1977
2048
|
* @param from - The event to clone.
|
|
@@ -1990,7 +2061,7 @@ class EventBoundary {
|
|
|
1990
2061
|
return event;
|
|
1991
2062
|
}
|
|
1992
2063
|
/**
|
|
1993
|
-
* Copies wheel {@link FederatedWheelEvent} data from
|
|
2064
|
+
* Copies wheel {@link FederatedWheelEvent} data from `from` into `to`.
|
|
1994
2065
|
*
|
|
1995
2066
|
* The following properties are copied:
|
|
1996
2067
|
* + deltaMode
|
|
@@ -2007,7 +2078,7 @@ class EventBoundary {
|
|
|
2007
2078
|
to.deltaZ = from.deltaZ;
|
|
2008
2079
|
}
|
|
2009
2080
|
/**
|
|
2010
|
-
* Copies pointer {@link FederatedPointerEvent} data from
|
|
2081
|
+
* Copies pointer {@link FederatedPointerEvent} data from `from` into `to`.
|
|
2011
2082
|
*
|
|
2012
2083
|
* The following properties are copied:
|
|
2013
2084
|
* + pointerId
|
|
@@ -2037,7 +2108,7 @@ class EventBoundary {
|
|
|
2037
2108
|
to.twist = from.twist;
|
|
2038
2109
|
}
|
|
2039
2110
|
/**
|
|
2040
|
-
* Copies mouse {@link FederatedMouseEvent} data from
|
|
2111
|
+
* Copies mouse {@link FederatedMouseEvent} data from `from` to `to`.
|
|
2041
2112
|
*
|
|
2042
2113
|
* The following properties are copied:
|
|
2043
2114
|
* + altKey
|
|
@@ -2073,7 +2144,7 @@ class EventBoundary {
|
|
|
2073
2144
|
to.global.copyFrom(from.global);
|
|
2074
2145
|
}
|
|
2075
2146
|
/**
|
|
2076
|
-
* Copies base {@link FederatedEvent} data from
|
|
2147
|
+
* Copies base {@link FederatedEvent} data from `from` into `to`.
|
|
2077
2148
|
*
|
|
2078
2149
|
* The following properties are copied:
|
|
2079
2150
|
* + isTrusted
|
|
@@ -2185,9 +2256,21 @@ const _EventSystem = class _EventSystem {
|
|
|
2185
2256
|
* @param {Renderer} renderer
|
|
2186
2257
|
*/
|
|
2187
2258
|
constructor(renderer) {
|
|
2188
|
-
/**
|
|
2259
|
+
/**
|
|
2260
|
+
* Indicates whether the current device supports touch events according to the W3C Touch Events spec.
|
|
2261
|
+
* This is used to determine the appropriate event handling strategy.
|
|
2262
|
+
* @see {@link https://www.w3.org/TR/touch-events/} W3C Touch Events Specification
|
|
2263
|
+
* @readonly
|
|
2264
|
+
* @default 'ontouchstart' in globalThis
|
|
2265
|
+
*/
|
|
2189
2266
|
this.supportsTouchEvents = "ontouchstart" in globalThis;
|
|
2190
|
-
/**
|
|
2267
|
+
/**
|
|
2268
|
+
* Indicates whether the current device supports pointer events according to the W3C Pointer Events spec.
|
|
2269
|
+
* Used to optimize event handling and provide more consistent cross-device interaction.
|
|
2270
|
+
* @see {@link https://www.w3.org/TR/pointerevents/} W3C Pointer Events Specification
|
|
2271
|
+
* @readonly
|
|
2272
|
+
* @default !!globalThis.PointerEvent
|
|
2273
|
+
*/
|
|
2191
2274
|
this.supportsPointerEvents = !!globalThis.PointerEvent;
|
|
2192
2275
|
/**
|
|
2193
2276
|
* The DOM element to which the root event listeners are bound. This is automatically set to
|
|
@@ -2259,7 +2342,34 @@ const _EventSystem = class _EventSystem {
|
|
|
2259
2342
|
}
|
|
2260
2343
|
/**
|
|
2261
2344
|
* Sets the current cursor mode, handling any callbacks or CSS style changes.
|
|
2262
|
-
*
|
|
2345
|
+
* The cursor can be a CSS cursor string, a custom callback function, or a key from the cursorStyles dictionary.
|
|
2346
|
+
* @param mode - Cursor mode to set. Can be:
|
|
2347
|
+
* - A CSS cursor string (e.g., 'pointer', 'grab')
|
|
2348
|
+
* - A key from the cursorStyles dictionary
|
|
2349
|
+
* - null/undefined to reset to default
|
|
2350
|
+
* @example
|
|
2351
|
+
* ```ts
|
|
2352
|
+
* // Using predefined cursor styles
|
|
2353
|
+
* app.renderer.events.setCursor('pointer'); // Set standard pointer cursor
|
|
2354
|
+
* app.renderer.events.setCursor('grab'); // Set grab cursor
|
|
2355
|
+
* app.renderer.events.setCursor(null); // Reset to default
|
|
2356
|
+
*
|
|
2357
|
+
* // Using custom cursor styles
|
|
2358
|
+
* app.renderer.events.cursorStyles.custom = 'url("cursor.png"), auto';
|
|
2359
|
+
* app.renderer.events.setCursor('custom'); // Apply custom cursor
|
|
2360
|
+
*
|
|
2361
|
+
* // Using callback-based cursor
|
|
2362
|
+
* app.renderer.events.cursorStyles.dynamic = (mode) => {
|
|
2363
|
+
* document.body.style.cursor = mode === 'hover' ? 'pointer' : 'default';
|
|
2364
|
+
* };
|
|
2365
|
+
* app.renderer.events.setCursor('dynamic'); // Trigger cursor callback
|
|
2366
|
+
* ```
|
|
2367
|
+
* @remarks
|
|
2368
|
+
* - Has no effect on OffscreenCanvas except for callback-based cursors
|
|
2369
|
+
* - Caches current cursor to avoid unnecessary DOM updates
|
|
2370
|
+
* - Supports CSS cursor values, style objects, and callback functions
|
|
2371
|
+
* @see {@link EventSystem.cursorStyles} For defining custom cursor styles
|
|
2372
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/cursor} MDN Cursor Reference
|
|
2263
2373
|
*/
|
|
2264
2374
|
setCursor(mode) {
|
|
2265
2375
|
mode || (mode = "default");
|
|
@@ -2293,9 +2403,27 @@ const _EventSystem = class _EventSystem {
|
|
|
2293
2403
|
}
|
|
2294
2404
|
}
|
|
2295
2405
|
/**
|
|
2296
|
-
* The global pointer event.
|
|
2297
|
-
*
|
|
2406
|
+
* The global pointer event instance containing the most recent pointer state.
|
|
2407
|
+
* This is useful for accessing pointer information without listening to events.
|
|
2408
|
+
* @example
|
|
2409
|
+
* ```ts
|
|
2410
|
+
* // Access current pointer position at any time
|
|
2411
|
+
* const eventSystem = app.renderer.events;
|
|
2412
|
+
* const pointer = eventSystem.pointer;
|
|
2413
|
+
*
|
|
2414
|
+
* // Get global coordinates
|
|
2415
|
+
* console.log('Position:', pointer.global.x, pointer.global.y);
|
|
2416
|
+
*
|
|
2417
|
+
* // Check button state
|
|
2418
|
+
* console.log('Buttons pressed:', pointer.buttons);
|
|
2419
|
+
*
|
|
2420
|
+
* // Get pointer type and pressure
|
|
2421
|
+
* console.log('Type:', pointer.pointerType);
|
|
2422
|
+
* console.log('Pressure:', pointer.pressure);
|
|
2423
|
+
* ```
|
|
2424
|
+
* @readonly
|
|
2298
2425
|
* @since 7.2.0
|
|
2426
|
+
* @see {@link FederatedPointerEvent} For all available pointer properties
|
|
2299
2427
|
*/
|
|
2300
2428
|
get pointer() {
|
|
2301
2429
|
return this._rootPointerEvent;
|
|
@@ -2387,9 +2515,30 @@ const _EventSystem = class _EventSystem {
|
|
|
2387
2515
|
}
|
|
2388
2516
|
/**
|
|
2389
2517
|
* Sets the {@link EventSystem#domElement domElement} and binds event listeners.
|
|
2518
|
+
* This method manages the DOM event bindings for the event system, allowing you to
|
|
2519
|
+
* change or remove the target element that receives input events.
|
|
2520
|
+
* > [!IMPORTANT] This will default to the canvas element of the renderer, so you
|
|
2521
|
+
* > should not need to call this unless you are using a custom element.
|
|
2522
|
+
* @param element - The new DOM element to bind events to, or null to remove all event bindings
|
|
2523
|
+
* @example
|
|
2524
|
+
* ```ts
|
|
2525
|
+
* // Set a new canvas element as the target
|
|
2526
|
+
* const canvas = document.createElement('canvas');
|
|
2527
|
+
* app.renderer.events.setTargetElement(canvas);
|
|
2528
|
+
*
|
|
2529
|
+
* // Remove all event bindings
|
|
2530
|
+
* app.renderer.events.setTargetElement(null);
|
|
2390
2531
|
*
|
|
2391
|
-
*
|
|
2392
|
-
*
|
|
2532
|
+
* // Switch to a different canvas
|
|
2533
|
+
* const newCanvas = document.querySelector('#game-canvas');
|
|
2534
|
+
* app.renderer.events.setTargetElement(newCanvas);
|
|
2535
|
+
* ```
|
|
2536
|
+
* @remarks
|
|
2537
|
+
* - Automatically removes event listeners from previous element
|
|
2538
|
+
* - Required for the event system to function
|
|
2539
|
+
* - Safe to call multiple times
|
|
2540
|
+
* @see {@link EventSystem#domElement} The current DOM element
|
|
2541
|
+
* @see {@link EventsTicker} For the ticker system that tracks pointer movement
|
|
2393
2542
|
*/
|
|
2394
2543
|
setTargetElement(element) {
|
|
2395
2544
|
this._removeEvents();
|
|
@@ -2474,15 +2623,40 @@ const _EventSystem = class _EventSystem {
|
|
|
2474
2623
|
this._eventsAdded = false;
|
|
2475
2624
|
}
|
|
2476
2625
|
/**
|
|
2477
|
-
* Maps
|
|
2478
|
-
*
|
|
2479
|
-
*
|
|
2480
|
-
* @param
|
|
2481
|
-
* @param
|
|
2482
|
-
* @
|
|
2626
|
+
* Maps coordinates from DOM/screen space into PixiJS normalized coordinates.
|
|
2627
|
+
* This takes into account the current scale, position, and resolution of the DOM element.
|
|
2628
|
+
* @param point - The point to store the mapped coordinates in
|
|
2629
|
+
* @param x - The x coordinate in DOM/client space
|
|
2630
|
+
* @param y - The y coordinate in DOM/client space
|
|
2631
|
+
* @example
|
|
2632
|
+
* ```ts
|
|
2633
|
+
* // Map mouse coordinates to PixiJS space
|
|
2634
|
+
* const point = new Point();
|
|
2635
|
+
* app.renderer.events.mapPositionToPoint(
|
|
2636
|
+
* point,
|
|
2637
|
+
* event.clientX,
|
|
2638
|
+
* event.clientY
|
|
2639
|
+
* );
|
|
2640
|
+
* console.log('Mapped position:', point.x, point.y);
|
|
2641
|
+
*
|
|
2642
|
+
* // Using with pointer events
|
|
2643
|
+
* sprite.on('pointermove', (event) => {
|
|
2644
|
+
* // event.global already contains mapped coordinates
|
|
2645
|
+
* console.log('Global:', event.global.x, event.global.y);
|
|
2646
|
+
*
|
|
2647
|
+
* // Map to local coordinates
|
|
2648
|
+
* const local = event.getLocalPosition(sprite);
|
|
2649
|
+
* console.log('Local:', local.x, local.y);
|
|
2650
|
+
* });
|
|
2651
|
+
* ```
|
|
2652
|
+
* @remarks
|
|
2653
|
+
* - Accounts for element scaling and positioning
|
|
2654
|
+
* - Adjusts for device pixel ratio/resolution
|
|
2483
2655
|
*/
|
|
2484
2656
|
mapPositionToPoint(point, x, y) {
|
|
2485
2657
|
const rect = this.domElement.isConnected ? this.domElement.getBoundingClientRect() : {
|
|
2658
|
+
x: 0,
|
|
2659
|
+
y: 0,
|
|
2486
2660
|
width: this.domElement.width,
|
|
2487
2661
|
height: this.domElement.height,
|
|
2488
2662
|
left: 0,
|
|
@@ -2622,7 +2796,7 @@ const _EventSystem = class _EventSystem {
|
|
|
2622
2796
|
return event;
|
|
2623
2797
|
}
|
|
2624
2798
|
/**
|
|
2625
|
-
* Transfers base & mouse event data from the
|
|
2799
|
+
* Transfers base & mouse event data from the `nativeEvent` to the federated event.
|
|
2626
2800
|
* @param event
|
|
2627
2801
|
* @param nativeEvent
|
|
2628
2802
|
*/
|
|
@@ -2658,8 +2832,22 @@ _EventSystem.extension = {
|
|
|
2658
2832
|
};
|
|
2659
2833
|
/**
|
|
2660
2834
|
* The event features that are enabled by the EventSystem
|
|
2661
|
-
* (included in the **pixi.js** and **pixi.js-legacy** bundle), otherwise it will be ignored.
|
|
2662
2835
|
* @since 7.2.0
|
|
2836
|
+
* @example
|
|
2837
|
+
* ```ts
|
|
2838
|
+
* import { EventSystem, EventSystemFeatures } from 'pixi.js';
|
|
2839
|
+
* // Access the default event features
|
|
2840
|
+
* EventSystem.defaultEventFeatures = {
|
|
2841
|
+
* // Enable pointer movement events
|
|
2842
|
+
* move: true,
|
|
2843
|
+
* // Enable global pointer move events
|
|
2844
|
+
* globalMove: true,
|
|
2845
|
+
* // Enable click events
|
|
2846
|
+
* click: true,
|
|
2847
|
+
* // Enable wheel events
|
|
2848
|
+
* wheel: true,
|
|
2849
|
+
* };
|
|
2850
|
+
* ```
|
|
2663
2851
|
*/
|
|
2664
2852
|
_EventSystem.defaultEventFeatures = {
|
|
2665
2853
|
/** Enables pointer events associated with pointer movement. */
|
|
@@ -2674,455 +2862,57 @@ _EventSystem.defaultEventFeatures = {
|
|
|
2674
2862
|
let EventSystem = _EventSystem;
|
|
2675
2863
|
|
|
2676
2864
|
const FederatedContainer = {
|
|
2677
|
-
/**
|
|
2678
|
-
* Property-based event handler for the `click` event.
|
|
2679
|
-
* @memberof scene.Container#
|
|
2680
|
-
* @default null
|
|
2681
|
-
* @example
|
|
2682
|
-
* this.onclick = (event) => {
|
|
2683
|
-
* //some function here that happens on click
|
|
2684
|
-
* }
|
|
2685
|
-
*/
|
|
2686
2865
|
onclick: null,
|
|
2687
|
-
/**
|
|
2688
|
-
* Property-based event handler for the `mousedown` event.
|
|
2689
|
-
* @memberof scene.Container#
|
|
2690
|
-
* @default null
|
|
2691
|
-
* @example
|
|
2692
|
-
* this.onmousedown = (event) => {
|
|
2693
|
-
* //some function here that happens on mousedown
|
|
2694
|
-
* }
|
|
2695
|
-
*/
|
|
2696
2866
|
onmousedown: null,
|
|
2697
|
-
/**
|
|
2698
|
-
* Property-based event handler for the `mouseenter` event.
|
|
2699
|
-
* @memberof scene.Container#
|
|
2700
|
-
* @default null
|
|
2701
|
-
* @example
|
|
2702
|
-
* this.onmouseenter = (event) => {
|
|
2703
|
-
* //some function here that happens on mouseenter
|
|
2704
|
-
* }
|
|
2705
|
-
*/
|
|
2706
2867
|
onmouseenter: null,
|
|
2707
|
-
/**
|
|
2708
|
-
* Property-based event handler for the `mouseleave` event.
|
|
2709
|
-
* @memberof scene.Container#
|
|
2710
|
-
* @default null
|
|
2711
|
-
* @example
|
|
2712
|
-
* this.onmouseleave = (event) => {
|
|
2713
|
-
* //some function here that happens on mouseleave
|
|
2714
|
-
* }
|
|
2715
|
-
*/
|
|
2716
2868
|
onmouseleave: null,
|
|
2717
|
-
/**
|
|
2718
|
-
* Property-based event handler for the `mousemove` event.
|
|
2719
|
-
* @memberof scene.Container#
|
|
2720
|
-
* @default null
|
|
2721
|
-
* @example
|
|
2722
|
-
* this.onmousemove = (event) => {
|
|
2723
|
-
* //some function here that happens on mousemove
|
|
2724
|
-
* }
|
|
2725
|
-
*/
|
|
2726
2869
|
onmousemove: null,
|
|
2727
|
-
/**
|
|
2728
|
-
* Property-based event handler for the `globalmousemove` event.
|
|
2729
|
-
* @memberof scene.Container#
|
|
2730
|
-
* @default null
|
|
2731
|
-
* @example
|
|
2732
|
-
* this.onglobalmousemove = (event) => {
|
|
2733
|
-
* //some function here that happens on globalmousemove
|
|
2734
|
-
* }
|
|
2735
|
-
*/
|
|
2736
2870
|
onglobalmousemove: null,
|
|
2737
|
-
/**
|
|
2738
|
-
* Property-based event handler for the `mouseout` event.
|
|
2739
|
-
* @memberof scene.Container#
|
|
2740
|
-
* @default null
|
|
2741
|
-
* @example
|
|
2742
|
-
* this.onmouseout = (event) => {
|
|
2743
|
-
* //some function here that happens on mouseout
|
|
2744
|
-
* }
|
|
2745
|
-
*/
|
|
2746
2871
|
onmouseout: null,
|
|
2747
|
-
/**
|
|
2748
|
-
* Property-based event handler for the `mouseover` event.
|
|
2749
|
-
* @memberof scene.Container#
|
|
2750
|
-
* @default null
|
|
2751
|
-
* @example
|
|
2752
|
-
* this.onmouseover = (event) => {
|
|
2753
|
-
* //some function here that happens on mouseover
|
|
2754
|
-
* }
|
|
2755
|
-
*/
|
|
2756
2872
|
onmouseover: null,
|
|
2757
|
-
/**
|
|
2758
|
-
* Property-based event handler for the `mouseup` event.
|
|
2759
|
-
* @memberof scene.Container#
|
|
2760
|
-
* @default null
|
|
2761
|
-
* @example
|
|
2762
|
-
* this.onmouseup = (event) => {
|
|
2763
|
-
* //some function here that happens on mouseup
|
|
2764
|
-
* }
|
|
2765
|
-
*/
|
|
2766
2873
|
onmouseup: null,
|
|
2767
|
-
/**
|
|
2768
|
-
* Property-based event handler for the `mouseupoutside` event.
|
|
2769
|
-
* @memberof scene.Container#
|
|
2770
|
-
* @default null
|
|
2771
|
-
* @example
|
|
2772
|
-
* this.onmouseupoutside = (event) => {
|
|
2773
|
-
* //some function here that happens on mouseupoutside
|
|
2774
|
-
* }
|
|
2775
|
-
*/
|
|
2776
2874
|
onmouseupoutside: null,
|
|
2777
|
-
/**
|
|
2778
|
-
* Property-based event handler for the `pointercancel` event.
|
|
2779
|
-
* @memberof scene.Container#
|
|
2780
|
-
* @default null
|
|
2781
|
-
* @example
|
|
2782
|
-
* this.onpointercancel = (event) => {
|
|
2783
|
-
* //some function here that happens on pointercancel
|
|
2784
|
-
* }
|
|
2785
|
-
*/
|
|
2786
2875
|
onpointercancel: null,
|
|
2787
|
-
/**
|
|
2788
|
-
* Property-based event handler for the `pointerdown` event.
|
|
2789
|
-
* @memberof scene.Container#
|
|
2790
|
-
* @default null
|
|
2791
|
-
* @example
|
|
2792
|
-
* this.onpointerdown = (event) => {
|
|
2793
|
-
* //some function here that happens on pointerdown
|
|
2794
|
-
* }
|
|
2795
|
-
*/
|
|
2796
2876
|
onpointerdown: null,
|
|
2797
|
-
/**
|
|
2798
|
-
* Property-based event handler for the `pointerenter` event.
|
|
2799
|
-
* @memberof scene.Container#
|
|
2800
|
-
* @default null
|
|
2801
|
-
* @example
|
|
2802
|
-
* this.onpointerenter = (event) => {
|
|
2803
|
-
* //some function here that happens on pointerenter
|
|
2804
|
-
* }
|
|
2805
|
-
*/
|
|
2806
2877
|
onpointerenter: null,
|
|
2807
|
-
/**
|
|
2808
|
-
* Property-based event handler for the `pointerleave` event.
|
|
2809
|
-
* @memberof scene.Container#
|
|
2810
|
-
* @default null
|
|
2811
|
-
* @example
|
|
2812
|
-
* this.onpointerleave = (event) => {
|
|
2813
|
-
* //some function here that happens on pointerleave
|
|
2814
|
-
* }
|
|
2815
|
-
*/
|
|
2816
2878
|
onpointerleave: null,
|
|
2817
|
-
/**
|
|
2818
|
-
* Property-based event handler for the `pointermove` event.
|
|
2819
|
-
* @memberof scene.Container#
|
|
2820
|
-
* @default null
|
|
2821
|
-
* @example
|
|
2822
|
-
* this.onpointermove = (event) => {
|
|
2823
|
-
* //some function here that happens on pointermove
|
|
2824
|
-
* }
|
|
2825
|
-
*/
|
|
2826
2879
|
onpointermove: null,
|
|
2827
|
-
/**
|
|
2828
|
-
* Property-based event handler for the `globalpointermove` event.
|
|
2829
|
-
* @memberof scene.Container#
|
|
2830
|
-
* @default null
|
|
2831
|
-
* @example
|
|
2832
|
-
* this.onglobalpointermove = (event) => {
|
|
2833
|
-
* //some function here that happens on globalpointermove
|
|
2834
|
-
* }
|
|
2835
|
-
*/
|
|
2836
2880
|
onglobalpointermove: null,
|
|
2837
|
-
/**
|
|
2838
|
-
* Property-based event handler for the `pointerout` event.
|
|
2839
|
-
* @memberof scene.Container#
|
|
2840
|
-
* @default null
|
|
2841
|
-
* @example
|
|
2842
|
-
* this.onpointerout = (event) => {
|
|
2843
|
-
* //some function here that happens on pointerout
|
|
2844
|
-
* }
|
|
2845
|
-
*/
|
|
2846
2881
|
onpointerout: null,
|
|
2847
|
-
/**
|
|
2848
|
-
* Property-based event handler for the `pointerover` event.
|
|
2849
|
-
* @memberof scene.Container#
|
|
2850
|
-
* @default null
|
|
2851
|
-
* @example
|
|
2852
|
-
* this.onpointerover = (event) => {
|
|
2853
|
-
* //some function here that happens on pointerover
|
|
2854
|
-
* }
|
|
2855
|
-
*/
|
|
2856
2882
|
onpointerover: null,
|
|
2857
|
-
/**
|
|
2858
|
-
* Property-based event handler for the `pointertap` event.
|
|
2859
|
-
* @memberof scene.Container#
|
|
2860
|
-
* @default null
|
|
2861
|
-
* @example
|
|
2862
|
-
* this.onpointertap = (event) => {
|
|
2863
|
-
* //some function here that happens on pointertap
|
|
2864
|
-
* }
|
|
2865
|
-
*/
|
|
2866
2883
|
onpointertap: null,
|
|
2867
|
-
/**
|
|
2868
|
-
* Property-based event handler for the `pointerup` event.
|
|
2869
|
-
* @memberof scene.Container#
|
|
2870
|
-
* @default null
|
|
2871
|
-
* @example
|
|
2872
|
-
* this.onpointerup = (event) => {
|
|
2873
|
-
* //some function here that happens on pointerup
|
|
2874
|
-
* }
|
|
2875
|
-
*/
|
|
2876
2884
|
onpointerup: null,
|
|
2877
|
-
/**
|
|
2878
|
-
* Property-based event handler for the `pointerupoutside` event.
|
|
2879
|
-
* @memberof scene.Container#
|
|
2880
|
-
* @default null
|
|
2881
|
-
* @example
|
|
2882
|
-
* this.onpointerupoutside = (event) => {
|
|
2883
|
-
* //some function here that happens on pointerupoutside
|
|
2884
|
-
* }
|
|
2885
|
-
*/
|
|
2886
2885
|
onpointerupoutside: null,
|
|
2887
|
-
/**
|
|
2888
|
-
* Property-based event handler for the `rightclick` event.
|
|
2889
|
-
* @memberof scene.Container#
|
|
2890
|
-
* @default null
|
|
2891
|
-
* @example
|
|
2892
|
-
* this.onrightclick = (event) => {
|
|
2893
|
-
* //some function here that happens on rightclick
|
|
2894
|
-
* }
|
|
2895
|
-
*/
|
|
2896
2886
|
onrightclick: null,
|
|
2897
|
-
/**
|
|
2898
|
-
* Property-based event handler for the `rightdown` event.
|
|
2899
|
-
* @memberof scene.Container#
|
|
2900
|
-
* @default null
|
|
2901
|
-
* @example
|
|
2902
|
-
* this.onrightdown = (event) => {
|
|
2903
|
-
* //some function here that happens on rightdown
|
|
2904
|
-
* }
|
|
2905
|
-
*/
|
|
2906
2887
|
onrightdown: null,
|
|
2907
|
-
/**
|
|
2908
|
-
* Property-based event handler for the `rightup` event.
|
|
2909
|
-
* @memberof scene.Container#
|
|
2910
|
-
* @default null
|
|
2911
|
-
* @example
|
|
2912
|
-
* this.onrightup = (event) => {
|
|
2913
|
-
* //some function here that happens on rightup
|
|
2914
|
-
* }
|
|
2915
|
-
*/
|
|
2916
2888
|
onrightup: null,
|
|
2917
|
-
/**
|
|
2918
|
-
* Property-based event handler for the `rightupoutside` event.
|
|
2919
|
-
* @memberof scene.Container#
|
|
2920
|
-
* @default null
|
|
2921
|
-
* @example
|
|
2922
|
-
* this.onrightupoutside = (event) => {
|
|
2923
|
-
* //some function here that happens on rightupoutside
|
|
2924
|
-
* }
|
|
2925
|
-
*/
|
|
2926
2889
|
onrightupoutside: null,
|
|
2927
|
-
/**
|
|
2928
|
-
* Property-based event handler for the `tap` event.
|
|
2929
|
-
* @memberof scene.Container#
|
|
2930
|
-
* @default null
|
|
2931
|
-
* @example
|
|
2932
|
-
* this.ontap = (event) => {
|
|
2933
|
-
* //some function here that happens on tap
|
|
2934
|
-
* }
|
|
2935
|
-
*/
|
|
2936
2890
|
ontap: null,
|
|
2937
|
-
/**
|
|
2938
|
-
* Property-based event handler for the `touchcancel` event.
|
|
2939
|
-
* @memberof scene.Container#
|
|
2940
|
-
* @default null
|
|
2941
|
-
* @example
|
|
2942
|
-
* this.ontouchcancel = (event) => {
|
|
2943
|
-
* //some function here that happens on touchcancel
|
|
2944
|
-
* }
|
|
2945
|
-
*/
|
|
2946
2891
|
ontouchcancel: null,
|
|
2947
|
-
/**
|
|
2948
|
-
* Property-based event handler for the `touchend` event.
|
|
2949
|
-
* @memberof scene.Container#
|
|
2950
|
-
* @default null
|
|
2951
|
-
* @example
|
|
2952
|
-
* this.ontouchend = (event) => {
|
|
2953
|
-
* //some function here that happens on touchend
|
|
2954
|
-
* }
|
|
2955
|
-
*/
|
|
2956
2892
|
ontouchend: null,
|
|
2957
|
-
/**
|
|
2958
|
-
* Property-based event handler for the `touchendoutside` event.
|
|
2959
|
-
* @memberof scene.Container#
|
|
2960
|
-
* @default null
|
|
2961
|
-
* @example
|
|
2962
|
-
* this.ontouchendoutside = (event) => {
|
|
2963
|
-
* //some function here that happens on touchendoutside
|
|
2964
|
-
* }
|
|
2965
|
-
*/
|
|
2966
2893
|
ontouchendoutside: null,
|
|
2967
|
-
/**
|
|
2968
|
-
* Property-based event handler for the `touchmove` event.
|
|
2969
|
-
* @memberof scene.Container#
|
|
2970
|
-
* @default null
|
|
2971
|
-
* @example
|
|
2972
|
-
* this.ontouchmove = (event) => {
|
|
2973
|
-
* //some function here that happens on touchmove
|
|
2974
|
-
* }
|
|
2975
|
-
*/
|
|
2976
2894
|
ontouchmove: null,
|
|
2977
|
-
/**
|
|
2978
|
-
* Property-based event handler for the `globaltouchmove` event.
|
|
2979
|
-
* @memberof scene.Container#
|
|
2980
|
-
* @default null
|
|
2981
|
-
* @example
|
|
2982
|
-
* this.onglobaltouchmove = (event) => {
|
|
2983
|
-
* //some function here that happens on globaltouchmove
|
|
2984
|
-
* }
|
|
2985
|
-
*/
|
|
2986
2895
|
onglobaltouchmove: null,
|
|
2987
|
-
/**
|
|
2988
|
-
* Property-based event handler for the `touchstart` event.
|
|
2989
|
-
* @memberof scene.Container#
|
|
2990
|
-
* @default null
|
|
2991
|
-
* @example
|
|
2992
|
-
* this.ontouchstart = (event) => {
|
|
2993
|
-
* //some function here that happens on touchstart
|
|
2994
|
-
* }
|
|
2995
|
-
*/
|
|
2996
2896
|
ontouchstart: null,
|
|
2997
|
-
/**
|
|
2998
|
-
* Property-based event handler for the `wheel` event.
|
|
2999
|
-
* @memberof scene.Container#
|
|
3000
|
-
* @default null
|
|
3001
|
-
* @example
|
|
3002
|
-
* this.onwheel = (event) => {
|
|
3003
|
-
* //some function here that happens on wheel
|
|
3004
|
-
* }
|
|
3005
|
-
*/
|
|
3006
2897
|
onwheel: null,
|
|
3007
|
-
/**
|
|
3008
|
-
* Enable interaction events for the Container. Touch, pointer and mouse
|
|
3009
|
-
* @memberof scene.Container#
|
|
3010
|
-
*/
|
|
3011
2898
|
get interactive() {
|
|
3012
2899
|
return this.eventMode === "dynamic" || this.eventMode === "static";
|
|
3013
2900
|
},
|
|
3014
2901
|
set interactive(value) {
|
|
3015
2902
|
this.eventMode = value ? "static" : "passive";
|
|
3016
2903
|
},
|
|
3017
|
-
/**
|
|
3018
|
-
* @ignore
|
|
3019
|
-
*/
|
|
3020
2904
|
_internalEventMode: void 0,
|
|
3021
|
-
/**
|
|
3022
|
-
* Enable interaction events for the Container. Touch, pointer and mouse.
|
|
3023
|
-
* There are 5 types of interaction settings:
|
|
3024
|
-
* - `'none'`: Ignores all interaction events, even on its children.
|
|
3025
|
-
* - `'passive'`: **(default)** Does not emit events and ignores all hit testing on itself and non-interactive children.
|
|
3026
|
-
* Interactive children will still emit events.
|
|
3027
|
-
* - `'auto'`: Does not emit events but is hit tested if parent is interactive. Same as `interactive = false` in v7
|
|
3028
|
-
* - `'static'`: Emit events and is hit tested. Same as `interaction = true` in v7
|
|
3029
|
-
* - `'dynamic'`: Emits events and is hit tested but will also receive mock interaction events fired from a ticker to
|
|
3030
|
-
* allow for interaction when the mouse isn't moving
|
|
3031
|
-
* @example
|
|
3032
|
-
* import { Sprite } from 'pixi.js';
|
|
3033
|
-
*
|
|
3034
|
-
* const sprite = new Sprite(texture);
|
|
3035
|
-
* sprite.eventMode = 'static';
|
|
3036
|
-
* sprite.on('tap', (event) => {
|
|
3037
|
-
* // Handle event
|
|
3038
|
-
* });
|
|
3039
|
-
* @memberof scene.Container#
|
|
3040
|
-
* @since 7.2.0
|
|
3041
|
-
*/
|
|
3042
2905
|
get eventMode() {
|
|
3043
2906
|
return this._internalEventMode ?? EventSystem.defaultEventMode;
|
|
3044
2907
|
},
|
|
3045
2908
|
set eventMode(value) {
|
|
3046
2909
|
this._internalEventMode = value;
|
|
3047
2910
|
},
|
|
3048
|
-
/**
|
|
3049
|
-
* Determines if the container is interactive or not
|
|
3050
|
-
* @returns {boolean} Whether the container is interactive or not
|
|
3051
|
-
* @memberof scene.Container#
|
|
3052
|
-
* @since 7.2.0
|
|
3053
|
-
* @example
|
|
3054
|
-
* import { Sprite } from 'pixi.js';
|
|
3055
|
-
*
|
|
3056
|
-
* const sprite = new Sprite(texture);
|
|
3057
|
-
* sprite.eventMode = 'static';
|
|
3058
|
-
* sprite.isInteractive(); // true
|
|
3059
|
-
*
|
|
3060
|
-
* sprite.eventMode = 'dynamic';
|
|
3061
|
-
* sprite.isInteractive(); // true
|
|
3062
|
-
*
|
|
3063
|
-
* sprite.eventMode = 'none';
|
|
3064
|
-
* sprite.isInteractive(); // false
|
|
3065
|
-
*
|
|
3066
|
-
* sprite.eventMode = 'passive';
|
|
3067
|
-
* sprite.isInteractive(); // false
|
|
3068
|
-
*
|
|
3069
|
-
* sprite.eventMode = 'auto';
|
|
3070
|
-
* sprite.isInteractive(); // false
|
|
3071
|
-
*/
|
|
3072
2911
|
isInteractive() {
|
|
3073
2912
|
return this.eventMode === "static" || this.eventMode === "dynamic";
|
|
3074
2913
|
},
|
|
3075
|
-
/**
|
|
3076
|
-
* Determines if the children to the container can be clicked/touched
|
|
3077
|
-
* Setting this to false allows PixiJS to bypass a recursive `hitTest` function
|
|
3078
|
-
* @memberof scene.Container#
|
|
3079
|
-
*/
|
|
3080
2914
|
interactiveChildren: true,
|
|
3081
|
-
/**
|
|
3082
|
-
* Interaction shape. Children will be hit first, then this shape will be checked.
|
|
3083
|
-
* Setting this will cause this shape to be checked in hit tests rather than the container's bounds.
|
|
3084
|
-
* @example
|
|
3085
|
-
* import { Rectangle, Sprite } from 'pixi.js';
|
|
3086
|
-
*
|
|
3087
|
-
* const sprite = new Sprite(texture);
|
|
3088
|
-
* sprite.interactive = true;
|
|
3089
|
-
* sprite.hitArea = new Rectangle(0, 0, 100, 100);
|
|
3090
|
-
* @member {IHitArea}
|
|
3091
|
-
* @memberof scene.Container#
|
|
3092
|
-
*/
|
|
3093
2915
|
hitArea: null,
|
|
3094
|
-
/**
|
|
3095
|
-
* Unlike `on` or `addListener` which are methods from EventEmitter, `addEventListener`
|
|
3096
|
-
* seeks to be compatible with the DOM's `addEventListener` with support for options.
|
|
3097
|
-
* @memberof scene.Container
|
|
3098
|
-
* @param type - The type of event to listen to.
|
|
3099
|
-
* @param listener - The listener callback or object.
|
|
3100
|
-
* @param options - Listener options, used for capture phase.
|
|
3101
|
-
* @example
|
|
3102
|
-
* // Tell the user whether they did a single, double, triple, or nth click.
|
|
3103
|
-
* button.addEventListener('click', {
|
|
3104
|
-
* handleEvent(e): {
|
|
3105
|
-
* let prefix;
|
|
3106
|
-
*
|
|
3107
|
-
* switch (e.detail) {
|
|
3108
|
-
* case 1: prefix = 'single'; break;
|
|
3109
|
-
* case 2: prefix = 'double'; break;
|
|
3110
|
-
* case 3: prefix = 'triple'; break;
|
|
3111
|
-
* default: prefix = e.detail + 'th'; break;
|
|
3112
|
-
* }
|
|
3113
|
-
*
|
|
3114
|
-
* console.log('That was a ' + prefix + 'click');
|
|
3115
|
-
* }
|
|
3116
|
-
* });
|
|
3117
|
-
*
|
|
3118
|
-
* // But skip the first click!
|
|
3119
|
-
* button.parent.addEventListener('click', function blockClickOnce(e) {
|
|
3120
|
-
* e.stopImmediatePropagation();
|
|
3121
|
-
* button.parent.removeEventListener('click', blockClickOnce, true);
|
|
3122
|
-
* }, {
|
|
3123
|
-
* capture: true,
|
|
3124
|
-
* });
|
|
3125
|
-
*/
|
|
3126
2916
|
addEventListener(type, listener, options) {
|
|
3127
2917
|
const capture = typeof options === "boolean" && options || typeof options === "object" && options.capture;
|
|
3128
2918
|
const signal = typeof options === "object" ? options.signal : void 0;
|
|
@@ -3142,14 +2932,6 @@ const FederatedContainer = {
|
|
|
3142
2932
|
emitter.on(type, listenerFn, context);
|
|
3143
2933
|
}
|
|
3144
2934
|
},
|
|
3145
|
-
/**
|
|
3146
|
-
* Unlike `off` or `removeListener` which are methods from EventEmitter, `removeEventListener`
|
|
3147
|
-
* seeks to be compatible with the DOM's `removeEventListener` with support for options.
|
|
3148
|
-
* @memberof scene.Container
|
|
3149
|
-
* @param type - The type of event the listener is bound to.
|
|
3150
|
-
* @param listener - The listener callback or object.
|
|
3151
|
-
* @param options - The original listener options. This is required to deregister a capture phase listener.
|
|
3152
|
-
*/
|
|
3153
2935
|
removeEventListener(type, listener, options) {
|
|
3154
2936
|
const capture = typeof options === "boolean" && options || typeof options === "object" && options.capture;
|
|
3155
2937
|
const context = typeof listener === "function" ? void 0 : listener;
|
|
@@ -3157,17 +2939,6 @@ const FederatedContainer = {
|
|
|
3157
2939
|
listener = typeof listener === "function" ? listener : listener.handleEvent;
|
|
3158
2940
|
this.off(type, listener, context);
|
|
3159
2941
|
},
|
|
3160
|
-
/**
|
|
3161
|
-
* Dispatch the event on this {@link Container} using the event's {@link EventBoundary}.
|
|
3162
|
-
*
|
|
3163
|
-
* The target of the event is set to `this` and the `defaultPrevented` flag is cleared before dispatch.
|
|
3164
|
-
* @memberof scene.Container
|
|
3165
|
-
* @param e - The event to dispatch.
|
|
3166
|
-
* @returns Whether the {@link FederatedEvent.preventDefault preventDefault}() method was not invoked.
|
|
3167
|
-
* @example
|
|
3168
|
-
* // Reuse a click event!
|
|
3169
|
-
* button.dispatchEvent(clickEvent);
|
|
3170
|
-
*/
|
|
3171
2942
|
dispatchEvent(e) {
|
|
3172
2943
|
if (!(e instanceof FederatedEvent)) {
|
|
3173
2944
|
throw new Error("Container cannot propagate events outside of the Federated Events API");
|