@eva/plugin-worker 2.0.0-beta.16
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/README.md +6 -0
- package/dist/EVA.plugin.worker.js +1326 -0
- package/dist/EVA.plugin.worker.min.js +1 -0
- package/dist/plugin-worker.cjs.js +1202 -0
- package/dist/plugin-worker.cjs.prod.js +1 -0
- package/dist/plugin-worker.d.ts +4 -0
- package/dist/plugin-worker.esm.js +1194 -0
- package/index.js +7 -0
- package/package.json +25 -0
|
@@ -0,0 +1,1326 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
window.EVA = window.EVA || {};
|
|
3
|
+
window.EVA.plugin = window.EVA.plugin || {};
|
|
4
|
+
var _EVA_IIFE_worker = function (exports, pixi_js) {
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
function createCommonjsModule(fn) {
|
|
8
|
+
var module = {
|
|
9
|
+
exports: {}
|
|
10
|
+
};
|
|
11
|
+
return fn(module, module.exports), module.exports;
|
|
12
|
+
}
|
|
13
|
+
var eventemitter3 = createCommonjsModule(function (module) {
|
|
14
|
+
var has = Object.prototype.hasOwnProperty,
|
|
15
|
+
prefix = '~';
|
|
16
|
+
function Events() {}
|
|
17
|
+
if (Object.create) {
|
|
18
|
+
Events.prototype = Object.create(null);
|
|
19
|
+
if (!new Events().__proto__) prefix = false;
|
|
20
|
+
}
|
|
21
|
+
function EE(fn, context, once) {
|
|
22
|
+
this.fn = fn;
|
|
23
|
+
this.context = context;
|
|
24
|
+
this.once = once || false;
|
|
25
|
+
}
|
|
26
|
+
function addListener(emitter, event, fn, context, once) {
|
|
27
|
+
if (typeof fn !== 'function') {
|
|
28
|
+
throw new TypeError('The listener must be a function');
|
|
29
|
+
}
|
|
30
|
+
var listener = new EE(fn, context || emitter, once),
|
|
31
|
+
evt = prefix ? prefix + event : event;
|
|
32
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);else emitter._events[evt] = [emitter._events[evt], listener];
|
|
33
|
+
return emitter;
|
|
34
|
+
}
|
|
35
|
+
function clearEvent(emitter, evt) {
|
|
36
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();else delete emitter._events[evt];
|
|
37
|
+
}
|
|
38
|
+
function EventEmitter() {
|
|
39
|
+
this._events = new Events();
|
|
40
|
+
this._eventsCount = 0;
|
|
41
|
+
}
|
|
42
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
43
|
+
var names = [],
|
|
44
|
+
events,
|
|
45
|
+
name;
|
|
46
|
+
if (this._eventsCount === 0) return names;
|
|
47
|
+
for (name in events = this._events) {
|
|
48
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
49
|
+
}
|
|
50
|
+
if (Object.getOwnPropertySymbols) {
|
|
51
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
52
|
+
}
|
|
53
|
+
return names;
|
|
54
|
+
};
|
|
55
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
56
|
+
var evt = prefix ? prefix + event : event,
|
|
57
|
+
handlers = this._events[evt];
|
|
58
|
+
if (!handlers) return [];
|
|
59
|
+
if (handlers.fn) return [handlers.fn];
|
|
60
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
61
|
+
ee[i] = handlers[i].fn;
|
|
62
|
+
}
|
|
63
|
+
return ee;
|
|
64
|
+
};
|
|
65
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
66
|
+
var evt = prefix ? prefix + event : event,
|
|
67
|
+
listeners = this._events[evt];
|
|
68
|
+
if (!listeners) return 0;
|
|
69
|
+
if (listeners.fn) return 1;
|
|
70
|
+
return listeners.length;
|
|
71
|
+
};
|
|
72
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
73
|
+
var evt = prefix ? prefix + event : event;
|
|
74
|
+
if (!this._events[evt]) return false;
|
|
75
|
+
var listeners = this._events[evt],
|
|
76
|
+
len = arguments.length,
|
|
77
|
+
args,
|
|
78
|
+
i;
|
|
79
|
+
if (listeners.fn) {
|
|
80
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
81
|
+
switch (len) {
|
|
82
|
+
case 1:
|
|
83
|
+
return listeners.fn.call(listeners.context), true;
|
|
84
|
+
case 2:
|
|
85
|
+
return listeners.fn.call(listeners.context, a1), true;
|
|
86
|
+
case 3:
|
|
87
|
+
return listeners.fn.call(listeners.context, a1, a2), true;
|
|
88
|
+
case 4:
|
|
89
|
+
return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
90
|
+
case 5:
|
|
91
|
+
return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
92
|
+
case 6:
|
|
93
|
+
return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
94
|
+
}
|
|
95
|
+
for (i = 1, args = new Array(len - 1); i < len; i++) {
|
|
96
|
+
args[i - 1] = arguments[i];
|
|
97
|
+
}
|
|
98
|
+
listeners.fn.apply(listeners.context, args);
|
|
99
|
+
} else {
|
|
100
|
+
var length = listeners.length,
|
|
101
|
+
j;
|
|
102
|
+
for (i = 0; i < length; i++) {
|
|
103
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
104
|
+
switch (len) {
|
|
105
|
+
case 1:
|
|
106
|
+
listeners[i].fn.call(listeners[i].context);
|
|
107
|
+
break;
|
|
108
|
+
case 2:
|
|
109
|
+
listeners[i].fn.call(listeners[i].context, a1);
|
|
110
|
+
break;
|
|
111
|
+
case 3:
|
|
112
|
+
listeners[i].fn.call(listeners[i].context, a1, a2);
|
|
113
|
+
break;
|
|
114
|
+
case 4:
|
|
115
|
+
listeners[i].fn.call(listeners[i].context, a1, a2, a3);
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) {
|
|
119
|
+
args[j - 1] = arguments[j];
|
|
120
|
+
}
|
|
121
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
};
|
|
127
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
128
|
+
return addListener(this, event, fn, context, false);
|
|
129
|
+
};
|
|
130
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
131
|
+
return addListener(this, event, fn, context, true);
|
|
132
|
+
};
|
|
133
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
134
|
+
var evt = prefix ? prefix + event : event;
|
|
135
|
+
if (!this._events[evt]) return this;
|
|
136
|
+
if (!fn) {
|
|
137
|
+
clearEvent(this, evt);
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
var listeners = this._events[evt];
|
|
141
|
+
if (listeners.fn) {
|
|
142
|
+
if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
|
|
143
|
+
clearEvent(this, evt);
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
147
|
+
if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
|
|
148
|
+
events.push(listeners[i]);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;else clearEvent(this, evt);
|
|
152
|
+
}
|
|
153
|
+
return this;
|
|
154
|
+
};
|
|
155
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
156
|
+
var evt;
|
|
157
|
+
if (event) {
|
|
158
|
+
evt = prefix ? prefix + event : event;
|
|
159
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
160
|
+
} else {
|
|
161
|
+
this._events = new Events();
|
|
162
|
+
this._eventsCount = 0;
|
|
163
|
+
}
|
|
164
|
+
return this;
|
|
165
|
+
};
|
|
166
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
167
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
168
|
+
EventEmitter.prefixed = prefix;
|
|
169
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
170
|
+
{
|
|
171
|
+
module.exports = EventEmitter;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
var EventEmitter = eventemitter3;
|
|
175
|
+
class EventsTickerClass {
|
|
176
|
+
constructor() {
|
|
177
|
+
this.interactionFrequency = 10;
|
|
178
|
+
this._deltaTime = 0;
|
|
179
|
+
this._didMove = false;
|
|
180
|
+
this._tickerAdded = false;
|
|
181
|
+
this._pauseUpdate = true;
|
|
182
|
+
}
|
|
183
|
+
init(events) {
|
|
184
|
+
this.removeTickerListener();
|
|
185
|
+
this.events = events;
|
|
186
|
+
this.interactionFrequency = 10;
|
|
187
|
+
this._deltaTime = 0;
|
|
188
|
+
this._didMove = false;
|
|
189
|
+
this._tickerAdded = false;
|
|
190
|
+
this._pauseUpdate = true;
|
|
191
|
+
}
|
|
192
|
+
get pauseUpdate() {
|
|
193
|
+
return this._pauseUpdate;
|
|
194
|
+
}
|
|
195
|
+
set pauseUpdate(paused) {
|
|
196
|
+
this._pauseUpdate = paused;
|
|
197
|
+
}
|
|
198
|
+
addTickerListener() {
|
|
199
|
+
if (this._tickerAdded || !this.domElement) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
pixi_js.Ticker.system.add(this._tickerUpdate, this, pixi_js.UPDATE_PRIORITY.INTERACTION);
|
|
203
|
+
this._tickerAdded = true;
|
|
204
|
+
}
|
|
205
|
+
removeTickerListener() {
|
|
206
|
+
if (!this._tickerAdded) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
pixi_js.Ticker.system.remove(this._tickerUpdate, this);
|
|
210
|
+
this._tickerAdded = false;
|
|
211
|
+
}
|
|
212
|
+
pointerMoved() {
|
|
213
|
+
this._didMove = true;
|
|
214
|
+
}
|
|
215
|
+
_update() {
|
|
216
|
+
if (!this.domElement || this._pauseUpdate) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (this._didMove) {
|
|
220
|
+
this._didMove = false;
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const rootPointerEvent = this.events['_rootPointerEvent'];
|
|
224
|
+
if (this.events.supportsTouchEvents && rootPointerEvent.pointerType === 'touch') {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
globalThis.document.dispatchEvent(new PointerEvent('pointermove', {
|
|
228
|
+
clientX: rootPointerEvent.clientX,
|
|
229
|
+
clientY: rootPointerEvent.clientY,
|
|
230
|
+
pointerType: rootPointerEvent.pointerType,
|
|
231
|
+
pointerId: rootPointerEvent.pointerId
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
_tickerUpdate(ticker) {
|
|
235
|
+
this._deltaTime += ticker.deltaTime;
|
|
236
|
+
if (this._deltaTime < this.interactionFrequency) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
this._deltaTime = 0;
|
|
240
|
+
this._update();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const EventsTicker = new EventsTickerClass();
|
|
244
|
+
class FederatedEvent {
|
|
245
|
+
constructor(manager) {
|
|
246
|
+
this.bubbles = true;
|
|
247
|
+
this.cancelBubble = true;
|
|
248
|
+
this.cancelable = false;
|
|
249
|
+
this.composed = false;
|
|
250
|
+
this.defaultPrevented = false;
|
|
251
|
+
this.eventPhase = FederatedEvent.prototype.NONE;
|
|
252
|
+
this.propagationStopped = false;
|
|
253
|
+
this.propagationImmediatelyStopped = false;
|
|
254
|
+
this.layer = new pixi_js.Point();
|
|
255
|
+
this.page = new pixi_js.Point();
|
|
256
|
+
this.NONE = 0;
|
|
257
|
+
this.CAPTURING_PHASE = 1;
|
|
258
|
+
this.AT_TARGET = 2;
|
|
259
|
+
this.BUBBLING_PHASE = 3;
|
|
260
|
+
this.manager = manager;
|
|
261
|
+
}
|
|
262
|
+
get layerX() {
|
|
263
|
+
return this.layer.x;
|
|
264
|
+
}
|
|
265
|
+
get layerY() {
|
|
266
|
+
return this.layer.y;
|
|
267
|
+
}
|
|
268
|
+
get pageX() {
|
|
269
|
+
return this.page.x;
|
|
270
|
+
}
|
|
271
|
+
get pageY() {
|
|
272
|
+
return this.page.y;
|
|
273
|
+
}
|
|
274
|
+
get data() {
|
|
275
|
+
return this;
|
|
276
|
+
}
|
|
277
|
+
composedPath() {
|
|
278
|
+
if (this.manager && (!this.path || this.path[this.path.length - 1] !== this.target)) {
|
|
279
|
+
this.path = this.target ? this.manager.propagationPath(this.target) : [];
|
|
280
|
+
}
|
|
281
|
+
return this.path;
|
|
282
|
+
}
|
|
283
|
+
initEvent(_type, _bubbles, _cancelable) {
|
|
284
|
+
throw new Error('initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.');
|
|
285
|
+
}
|
|
286
|
+
initUIEvent(_typeArg, _bubblesArg, _cancelableArg, _viewArg, _detailArg) {
|
|
287
|
+
throw new Error('initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.');
|
|
288
|
+
}
|
|
289
|
+
preventDefault() {
|
|
290
|
+
if (this.nativeEvent instanceof Event && this.nativeEvent.cancelable) {
|
|
291
|
+
this.nativeEvent.preventDefault();
|
|
292
|
+
}
|
|
293
|
+
this.defaultPrevented = true;
|
|
294
|
+
}
|
|
295
|
+
stopImmediatePropagation() {
|
|
296
|
+
this.propagationImmediatelyStopped = true;
|
|
297
|
+
}
|
|
298
|
+
stopPropagation() {
|
|
299
|
+
this.propagationStopped = true;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
class FederatedMouseEvent extends FederatedEvent {
|
|
303
|
+
constructor() {
|
|
304
|
+
super(...arguments);
|
|
305
|
+
this.client = new pixi_js.Point();
|
|
306
|
+
this.movement = new pixi_js.Point();
|
|
307
|
+
this.offset = new pixi_js.Point();
|
|
308
|
+
this.global = new pixi_js.Point();
|
|
309
|
+
this.screen = new pixi_js.Point();
|
|
310
|
+
}
|
|
311
|
+
get clientX() {
|
|
312
|
+
return this.client.x;
|
|
313
|
+
}
|
|
314
|
+
get clientY() {
|
|
315
|
+
return this.client.y;
|
|
316
|
+
}
|
|
317
|
+
get x() {
|
|
318
|
+
return this.clientX;
|
|
319
|
+
}
|
|
320
|
+
get y() {
|
|
321
|
+
return this.clientY;
|
|
322
|
+
}
|
|
323
|
+
get movementX() {
|
|
324
|
+
return this.movement.x;
|
|
325
|
+
}
|
|
326
|
+
get movementY() {
|
|
327
|
+
return this.movement.y;
|
|
328
|
+
}
|
|
329
|
+
get offsetX() {
|
|
330
|
+
return this.offset.x;
|
|
331
|
+
}
|
|
332
|
+
get offsetY() {
|
|
333
|
+
return this.offset.y;
|
|
334
|
+
}
|
|
335
|
+
get globalX() {
|
|
336
|
+
return this.global.x;
|
|
337
|
+
}
|
|
338
|
+
get globalY() {
|
|
339
|
+
return this.global.y;
|
|
340
|
+
}
|
|
341
|
+
get screenX() {
|
|
342
|
+
return this.screen.x;
|
|
343
|
+
}
|
|
344
|
+
get screenY() {
|
|
345
|
+
return this.screen.y;
|
|
346
|
+
}
|
|
347
|
+
getLocalPosition(container, point, globalPos) {
|
|
348
|
+
return container.worldTransform.applyInverse(globalPos || this.global, point);
|
|
349
|
+
}
|
|
350
|
+
getModifierState(key) {
|
|
351
|
+
return 'getModifierState' in this.nativeEvent && this.nativeEvent.getModifierState(key);
|
|
352
|
+
}
|
|
353
|
+
initMouseEvent(_typeArg, _canBubbleArg, _cancelableArg, _viewArg, _detailArg, _screenXArg, _screenYArg, _clientXArg, _clientYArg, _ctrlKeyArg, _altKeyArg, _shiftKeyArg, _metaKeyArg, _buttonArg, _relatedTargetArg) {
|
|
354
|
+
throw new Error('Method not implemented.');
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
class FederatedPointerEvent extends FederatedMouseEvent {
|
|
358
|
+
constructor() {
|
|
359
|
+
super(...arguments);
|
|
360
|
+
this.width = 0;
|
|
361
|
+
this.height = 0;
|
|
362
|
+
this.isPrimary = false;
|
|
363
|
+
}
|
|
364
|
+
getCoalescedEvents() {
|
|
365
|
+
if (this.type === 'pointermove' || this.type === 'mousemove' || this.type === 'touchmove') {
|
|
366
|
+
return [this];
|
|
367
|
+
}
|
|
368
|
+
return [];
|
|
369
|
+
}
|
|
370
|
+
getPredictedEvents() {
|
|
371
|
+
throw new Error('getPredictedEvents is not supported!');
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
class FederatedWheelEvent extends FederatedMouseEvent {
|
|
375
|
+
constructor() {
|
|
376
|
+
super(...arguments);
|
|
377
|
+
this.DOM_DELTA_PIXEL = 0;
|
|
378
|
+
this.DOM_DELTA_LINE = 1;
|
|
379
|
+
this.DOM_DELTA_PAGE = 2;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
FederatedWheelEvent.DOM_DELTA_PIXEL = 0;
|
|
383
|
+
FederatedWheelEvent.DOM_DELTA_LINE = 1;
|
|
384
|
+
FederatedWheelEvent.DOM_DELTA_PAGE = 2;
|
|
385
|
+
const PROPAGATION_LIMIT = 2048;
|
|
386
|
+
const tempHitLocation = new pixi_js.Point();
|
|
387
|
+
const tempLocalMapping = new pixi_js.Point();
|
|
388
|
+
class EventBoundary {
|
|
389
|
+
constructor(rootTarget) {
|
|
390
|
+
this.dispatch = new EventEmitter();
|
|
391
|
+
this.moveOnAll = false;
|
|
392
|
+
this.enableGlobalMoveEvents = true;
|
|
393
|
+
this.mappingState = {
|
|
394
|
+
trackingData: {}
|
|
395
|
+
};
|
|
396
|
+
this.eventPool = new Map();
|
|
397
|
+
this._allInteractiveElements = [];
|
|
398
|
+
this._hitElements = [];
|
|
399
|
+
this._isPointerMoveEvent = false;
|
|
400
|
+
this.rootTarget = rootTarget;
|
|
401
|
+
this.hitPruneFn = this.hitPruneFn.bind(this);
|
|
402
|
+
this.hitTestFn = this.hitTestFn.bind(this);
|
|
403
|
+
this.mapPointerDown = this.mapPointerDown.bind(this);
|
|
404
|
+
this.mapPointerMove = this.mapPointerMove.bind(this);
|
|
405
|
+
this.mapPointerOut = this.mapPointerOut.bind(this);
|
|
406
|
+
this.mapPointerOver = this.mapPointerOver.bind(this);
|
|
407
|
+
this.mapPointerUp = this.mapPointerUp.bind(this);
|
|
408
|
+
this.mapPointerUpOutside = this.mapPointerUpOutside.bind(this);
|
|
409
|
+
this.mapWheel = this.mapWheel.bind(this);
|
|
410
|
+
this.mappingTable = {};
|
|
411
|
+
this.addEventMapping('pointerdown', this.mapPointerDown);
|
|
412
|
+
this.addEventMapping('pointermove', this.mapPointerMove);
|
|
413
|
+
this.addEventMapping('pointerout', this.mapPointerOut);
|
|
414
|
+
this.addEventMapping('pointerleave', this.mapPointerOut);
|
|
415
|
+
this.addEventMapping('pointerover', this.mapPointerOver);
|
|
416
|
+
this.addEventMapping('pointerup', this.mapPointerUp);
|
|
417
|
+
this.addEventMapping('pointerupoutside', this.mapPointerUpOutside);
|
|
418
|
+
this.addEventMapping('wheel', this.mapWheel);
|
|
419
|
+
}
|
|
420
|
+
addEventMapping(type, fn) {
|
|
421
|
+
if (!this.mappingTable[type]) {
|
|
422
|
+
this.mappingTable[type] = [];
|
|
423
|
+
}
|
|
424
|
+
this.mappingTable[type].push({
|
|
425
|
+
fn,
|
|
426
|
+
priority: 0
|
|
427
|
+
});
|
|
428
|
+
this.mappingTable[type].sort((a, b) => a.priority - b.priority);
|
|
429
|
+
}
|
|
430
|
+
dispatchEvent(e, type) {
|
|
431
|
+
e.propagationStopped = false;
|
|
432
|
+
e.propagationImmediatelyStopped = false;
|
|
433
|
+
this.propagate(e, type);
|
|
434
|
+
this.dispatch.emit(type || e.type, e);
|
|
435
|
+
}
|
|
436
|
+
mapEvent(e) {
|
|
437
|
+
if (!this.rootTarget) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
const mappers = this.mappingTable[e.type];
|
|
441
|
+
if (mappers) {
|
|
442
|
+
for (let i = 0, j = mappers.length; i < j; i++) {
|
|
443
|
+
mappers[i].fn(e);
|
|
444
|
+
}
|
|
445
|
+
} else {
|
|
446
|
+
pixi_js.warn(`[EventBoundary]: Event mapping not defined for ${e.type}`);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
hitTest(x, y) {
|
|
450
|
+
EventsTicker.pauseUpdate = true;
|
|
451
|
+
const useMove = this._isPointerMoveEvent && this.enableGlobalMoveEvents;
|
|
452
|
+
const fn = useMove ? 'hitTestMoveRecursive' : 'hitTestRecursive';
|
|
453
|
+
const invertedPath = this[fn](this.rootTarget, this.rootTarget.eventMode, tempHitLocation.set(x, y), this.hitTestFn, this.hitPruneFn);
|
|
454
|
+
return invertedPath && invertedPath[0];
|
|
455
|
+
}
|
|
456
|
+
propagate(e, type) {
|
|
457
|
+
if (!e.target) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const composedPath = e.composedPath();
|
|
461
|
+
e.eventPhase = e.CAPTURING_PHASE;
|
|
462
|
+
for (let i = 0, j = composedPath.length - 1; i < j; i++) {
|
|
463
|
+
e.currentTarget = composedPath[i];
|
|
464
|
+
this.notifyTarget(e, type);
|
|
465
|
+
if (e.propagationStopped || e.propagationImmediatelyStopped) return;
|
|
466
|
+
}
|
|
467
|
+
e.eventPhase = e.AT_TARGET;
|
|
468
|
+
e.currentTarget = e.target;
|
|
469
|
+
this.notifyTarget(e, type);
|
|
470
|
+
if (e.propagationStopped || e.propagationImmediatelyStopped) return;
|
|
471
|
+
e.eventPhase = e.BUBBLING_PHASE;
|
|
472
|
+
for (let i = composedPath.length - 2; i >= 0; i--) {
|
|
473
|
+
e.currentTarget = composedPath[i];
|
|
474
|
+
this.notifyTarget(e, type);
|
|
475
|
+
if (e.propagationStopped || e.propagationImmediatelyStopped) return;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
all(e, type, targets = this._allInteractiveElements) {
|
|
479
|
+
if (targets.length === 0) return;
|
|
480
|
+
e.eventPhase = e.BUBBLING_PHASE;
|
|
481
|
+
const events = Array.isArray(type) ? type : [type];
|
|
482
|
+
for (let i = targets.length - 1; i >= 0; i--) {
|
|
483
|
+
events.forEach(event => {
|
|
484
|
+
e.currentTarget = targets[i];
|
|
485
|
+
this.notifyTarget(e, event);
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
propagationPath(target) {
|
|
490
|
+
const propagationPath = [target];
|
|
491
|
+
for (let i = 0; i < PROPAGATION_LIMIT && target !== this.rootTarget && target.parent; i++) {
|
|
492
|
+
if (!target.parent) {
|
|
493
|
+
throw new Error('Cannot find propagation path to disconnected target');
|
|
494
|
+
}
|
|
495
|
+
propagationPath.push(target.parent);
|
|
496
|
+
target = target.parent;
|
|
497
|
+
}
|
|
498
|
+
propagationPath.reverse();
|
|
499
|
+
return propagationPath;
|
|
500
|
+
}
|
|
501
|
+
hitTestMoveRecursive(currentTarget, eventMode, location, testFn, pruneFn, ignore = false) {
|
|
502
|
+
let shouldReturn = false;
|
|
503
|
+
if (this._interactivePrune(currentTarget)) return null;
|
|
504
|
+
if (currentTarget.eventMode === 'dynamic' || eventMode === 'dynamic') {
|
|
505
|
+
EventsTicker.pauseUpdate = false;
|
|
506
|
+
}
|
|
507
|
+
if (currentTarget.interactiveChildren && currentTarget.children) {
|
|
508
|
+
const children = currentTarget.children;
|
|
509
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
510
|
+
const child = children[i];
|
|
511
|
+
const nestedHit = this.hitTestMoveRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, location, testFn, pruneFn, ignore || pruneFn(currentTarget, location));
|
|
512
|
+
if (nestedHit) {
|
|
513
|
+
if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
const isInteractive = currentTarget.isInteractive();
|
|
517
|
+
if (nestedHit.length > 0 || isInteractive) {
|
|
518
|
+
if (isInteractive) this._allInteractiveElements.push(currentTarget);
|
|
519
|
+
nestedHit.push(currentTarget);
|
|
520
|
+
}
|
|
521
|
+
if (this._hitElements.length === 0) this._hitElements = nestedHit;
|
|
522
|
+
shouldReturn = true;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const isInteractiveMode = this._isInteractive(eventMode);
|
|
527
|
+
const isInteractiveTarget = currentTarget.isInteractive();
|
|
528
|
+
if (isInteractiveTarget && isInteractiveTarget) this._allInteractiveElements.push(currentTarget);
|
|
529
|
+
if (ignore || this._hitElements.length > 0) return null;
|
|
530
|
+
if (shouldReturn) return this._hitElements;
|
|
531
|
+
if (isInteractiveMode && !pruneFn(currentTarget, location) && testFn(currentTarget, location)) {
|
|
532
|
+
return isInteractiveTarget ? [currentTarget] : [];
|
|
533
|
+
}
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
hitTestRecursive(currentTarget, eventMode, location, testFn, pruneFn) {
|
|
537
|
+
if (this._interactivePrune(currentTarget) || pruneFn(currentTarget, location)) {
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
if (currentTarget.eventMode === 'dynamic' || eventMode === 'dynamic') {
|
|
541
|
+
EventsTicker.pauseUpdate = false;
|
|
542
|
+
}
|
|
543
|
+
if (currentTarget.interactiveChildren && currentTarget.children) {
|
|
544
|
+
const children = currentTarget.children;
|
|
545
|
+
const relativeLocation = location;
|
|
546
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
547
|
+
const child = children[i];
|
|
548
|
+
const nestedHit = this.hitTestRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, relativeLocation, testFn, pruneFn);
|
|
549
|
+
if (nestedHit) {
|
|
550
|
+
if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
|
|
551
|
+
continue;
|
|
552
|
+
}
|
|
553
|
+
const isInteractive = currentTarget.isInteractive();
|
|
554
|
+
if (nestedHit.length > 0 || isInteractive) nestedHit.push(currentTarget);
|
|
555
|
+
return nestedHit;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
const isInteractiveMode = this._isInteractive(eventMode);
|
|
560
|
+
const isInteractiveTarget = currentTarget.isInteractive();
|
|
561
|
+
if (isInteractiveMode && testFn(currentTarget, location)) {
|
|
562
|
+
return isInteractiveTarget ? [currentTarget] : [];
|
|
563
|
+
}
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
_isInteractive(int) {
|
|
567
|
+
return int === 'static' || int === 'dynamic';
|
|
568
|
+
}
|
|
569
|
+
_interactivePrune(container) {
|
|
570
|
+
if (!container || !container.visible || !container.renderable || !container.measurable) {
|
|
571
|
+
return true;
|
|
572
|
+
}
|
|
573
|
+
if (container.eventMode === 'none') {
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
if (container.eventMode === 'passive' && !container.interactiveChildren) {
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
579
|
+
return false;
|
|
580
|
+
}
|
|
581
|
+
hitPruneFn(container, location) {
|
|
582
|
+
if (container.hitArea) {
|
|
583
|
+
container.worldTransform.applyInverse(location, tempLocalMapping);
|
|
584
|
+
if (!container.hitArea.contains(tempLocalMapping.x, tempLocalMapping.y)) {
|
|
585
|
+
return true;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
if (container.effects && container.effects.length) {
|
|
589
|
+
for (let i = 0; i < container.effects.length; i++) {
|
|
590
|
+
const effect = container.effects[i];
|
|
591
|
+
if (effect.containsPoint) {
|
|
592
|
+
const effectContainsPoint = effect.containsPoint(location, this.hitTestFn);
|
|
593
|
+
if (!effectContainsPoint) {
|
|
594
|
+
return true;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return false;
|
|
600
|
+
}
|
|
601
|
+
hitTestFn(container, location) {
|
|
602
|
+
var _a;
|
|
603
|
+
if (container.hitArea) {
|
|
604
|
+
return true;
|
|
605
|
+
}
|
|
606
|
+
if ((_a = container) === null || _a === void 0 ? void 0 : _a.containsPoint) {
|
|
607
|
+
container.worldTransform.applyInverse(location, tempLocalMapping);
|
|
608
|
+
return container.containsPoint(tempLocalMapping);
|
|
609
|
+
}
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
notifyTarget(e, type) {
|
|
613
|
+
var _a;
|
|
614
|
+
if (!e.currentTarget.isInteractive()) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
type = type !== null && type !== void 0 ? type : e.type;
|
|
618
|
+
const handlerKey = `on${type}`;
|
|
619
|
+
(_a = e.currentTarget[handlerKey]) === null || _a === void 0 ? void 0 : _a(e);
|
|
620
|
+
const key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? `${type}capture` : type;
|
|
621
|
+
this._notifyListeners(e, key);
|
|
622
|
+
if (e.eventPhase === e.AT_TARGET) {
|
|
623
|
+
this._notifyListeners(e, type);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
mapPointerDown(from) {
|
|
627
|
+
if (!(from instanceof FederatedPointerEvent)) {
|
|
628
|
+
pixi_js.warn('EventBoundary cannot map a non-pointer event as a pointer event');
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
const e = this.createPointerEvent(from);
|
|
632
|
+
this.dispatchEvent(e, 'pointerdown');
|
|
633
|
+
if (e.pointerType === 'touch') {
|
|
634
|
+
this.dispatchEvent(e, 'touchstart');
|
|
635
|
+
} else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
|
|
636
|
+
const isRightButton = e.button === 2;
|
|
637
|
+
this.dispatchEvent(e, isRightButton ? 'rightdown' : 'mousedown');
|
|
638
|
+
}
|
|
639
|
+
const trackingData = this.trackingData(from.pointerId);
|
|
640
|
+
trackingData.pressTargetsByButton[from.button] = e.composedPath();
|
|
641
|
+
this.freeEvent(e);
|
|
642
|
+
}
|
|
643
|
+
mapPointerMove(from) {
|
|
644
|
+
var _a, _b, _c;
|
|
645
|
+
if (!(from instanceof FederatedPointerEvent)) {
|
|
646
|
+
pixi_js.warn('EventBoundary cannot map a non-pointer event as a pointer event');
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
this._allInteractiveElements.length = 0;
|
|
650
|
+
this._hitElements.length = 0;
|
|
651
|
+
this._isPointerMoveEvent = true;
|
|
652
|
+
const e = this.createPointerEvent(from);
|
|
653
|
+
this._isPointerMoveEvent = false;
|
|
654
|
+
const isMouse = e.pointerType === 'mouse' || e.pointerType === 'pen';
|
|
655
|
+
const trackingData = this.trackingData(from.pointerId);
|
|
656
|
+
const outTarget = this.findMountedTarget(trackingData.overTargets);
|
|
657
|
+
if (((_a = trackingData.overTargets) === null || _a === void 0 ? void 0 : _a.length) > 0 && outTarget !== e.target) {
|
|
658
|
+
const outType = from.type === 'mousemove' ? 'mouseout' : 'pointerout';
|
|
659
|
+
const outEvent = this.createPointerEvent(from, outType, outTarget);
|
|
660
|
+
this.dispatchEvent(outEvent, 'pointerout');
|
|
661
|
+
if (isMouse) this.dispatchEvent(outEvent, 'mouseout');
|
|
662
|
+
if (!e.composedPath().includes(outTarget)) {
|
|
663
|
+
const leaveEvent = this.createPointerEvent(from, 'pointerleave', outTarget);
|
|
664
|
+
leaveEvent.eventPhase = leaveEvent.AT_TARGET;
|
|
665
|
+
while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
|
|
666
|
+
leaveEvent.currentTarget = leaveEvent.target;
|
|
667
|
+
this.notifyTarget(leaveEvent);
|
|
668
|
+
if (isMouse) this.notifyTarget(leaveEvent, 'mouseleave');
|
|
669
|
+
leaveEvent.target = leaveEvent.target.parent;
|
|
670
|
+
}
|
|
671
|
+
this.freeEvent(leaveEvent);
|
|
672
|
+
}
|
|
673
|
+
this.freeEvent(outEvent);
|
|
674
|
+
}
|
|
675
|
+
if (outTarget !== e.target) {
|
|
676
|
+
const overType = from.type === 'mousemove' ? 'mouseover' : 'pointerover';
|
|
677
|
+
const overEvent = this.clonePointerEvent(e, overType);
|
|
678
|
+
this.dispatchEvent(overEvent, 'pointerover');
|
|
679
|
+
if (isMouse) this.dispatchEvent(overEvent, 'mouseover');
|
|
680
|
+
let overTargetAncestor = outTarget === null || outTarget === void 0 ? void 0 : outTarget.parent;
|
|
681
|
+
while (overTargetAncestor && overTargetAncestor !== this.rootTarget.parent) {
|
|
682
|
+
if (overTargetAncestor === e.target) break;
|
|
683
|
+
overTargetAncestor = overTargetAncestor.parent;
|
|
684
|
+
}
|
|
685
|
+
const didPointerEnter = !overTargetAncestor || overTargetAncestor === this.rootTarget.parent;
|
|
686
|
+
if (didPointerEnter) {
|
|
687
|
+
const enterEvent = this.clonePointerEvent(e, 'pointerenter');
|
|
688
|
+
enterEvent.eventPhase = enterEvent.AT_TARGET;
|
|
689
|
+
while (enterEvent.target && enterEvent.target !== outTarget && enterEvent.target !== this.rootTarget.parent) {
|
|
690
|
+
enterEvent.currentTarget = enterEvent.target;
|
|
691
|
+
this.notifyTarget(enterEvent);
|
|
692
|
+
if (isMouse) this.notifyTarget(enterEvent, 'mouseenter');
|
|
693
|
+
enterEvent.target = enterEvent.target.parent;
|
|
694
|
+
}
|
|
695
|
+
this.freeEvent(enterEvent);
|
|
696
|
+
}
|
|
697
|
+
this.freeEvent(overEvent);
|
|
698
|
+
}
|
|
699
|
+
const allMethods = [];
|
|
700
|
+
const allowGlobalPointerEvents = (_b = this.enableGlobalMoveEvents) !== null && _b !== void 0 ? _b : true;
|
|
701
|
+
this.moveOnAll ? allMethods.push('pointermove') : this.dispatchEvent(e, 'pointermove');
|
|
702
|
+
allowGlobalPointerEvents && allMethods.push('globalpointermove');
|
|
703
|
+
if (e.pointerType === 'touch') {
|
|
704
|
+
this.moveOnAll ? allMethods.splice(1, 0, 'touchmove') : this.dispatchEvent(e, 'touchmove');
|
|
705
|
+
allowGlobalPointerEvents && allMethods.push('globaltouchmove');
|
|
706
|
+
}
|
|
707
|
+
if (isMouse) {
|
|
708
|
+
this.moveOnAll ? allMethods.splice(1, 0, 'mousemove') : this.dispatchEvent(e, 'mousemove');
|
|
709
|
+
allowGlobalPointerEvents && allMethods.push('globalmousemove');
|
|
710
|
+
this.cursor = (_c = e.target) === null || _c === void 0 ? void 0 : _c.cursor;
|
|
711
|
+
}
|
|
712
|
+
if (allMethods.length > 0) {
|
|
713
|
+
this.all(e, allMethods);
|
|
714
|
+
}
|
|
715
|
+
this._allInteractiveElements.length = 0;
|
|
716
|
+
this._hitElements.length = 0;
|
|
717
|
+
trackingData.overTargets = e.composedPath();
|
|
718
|
+
this.freeEvent(e);
|
|
719
|
+
}
|
|
720
|
+
mapPointerOver(from) {
|
|
721
|
+
var _a;
|
|
722
|
+
if (!(from instanceof FederatedPointerEvent)) {
|
|
723
|
+
pixi_js.warn('EventBoundary cannot map a non-pointer event as a pointer event');
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
const trackingData = this.trackingData(from.pointerId);
|
|
727
|
+
const e = this.createPointerEvent(from);
|
|
728
|
+
const isMouse = e.pointerType === 'mouse' || e.pointerType === 'pen';
|
|
729
|
+
this.dispatchEvent(e, 'pointerover');
|
|
730
|
+
if (isMouse) this.dispatchEvent(e, 'mouseover');
|
|
731
|
+
if (e.pointerType === 'mouse') this.cursor = (_a = e.target) === null || _a === void 0 ? void 0 : _a.cursor;
|
|
732
|
+
const enterEvent = this.clonePointerEvent(e, 'pointerenter');
|
|
733
|
+
enterEvent.eventPhase = enterEvent.AT_TARGET;
|
|
734
|
+
while (enterEvent.target && enterEvent.target !== this.rootTarget.parent) {
|
|
735
|
+
enterEvent.currentTarget = enterEvent.target;
|
|
736
|
+
this.notifyTarget(enterEvent);
|
|
737
|
+
if (isMouse) this.notifyTarget(enterEvent, 'mouseenter');
|
|
738
|
+
enterEvent.target = enterEvent.target.parent;
|
|
739
|
+
}
|
|
740
|
+
trackingData.overTargets = e.composedPath();
|
|
741
|
+
this.freeEvent(e);
|
|
742
|
+
this.freeEvent(enterEvent);
|
|
743
|
+
}
|
|
744
|
+
mapPointerOut(from) {
|
|
745
|
+
if (!(from instanceof FederatedPointerEvent)) {
|
|
746
|
+
pixi_js.warn('EventBoundary cannot map a non-pointer event as a pointer event');
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
const trackingData = this.trackingData(from.pointerId);
|
|
750
|
+
if (trackingData.overTargets) {
|
|
751
|
+
const isMouse = from.pointerType === 'mouse' || from.pointerType === 'pen';
|
|
752
|
+
const outTarget = this.findMountedTarget(trackingData.overTargets);
|
|
753
|
+
const outEvent = this.createPointerEvent(from, 'pointerout', outTarget);
|
|
754
|
+
this.dispatchEvent(outEvent);
|
|
755
|
+
if (isMouse) this.dispatchEvent(outEvent, 'mouseout');
|
|
756
|
+
const leaveEvent = this.createPointerEvent(from, 'pointerleave', outTarget);
|
|
757
|
+
leaveEvent.eventPhase = leaveEvent.AT_TARGET;
|
|
758
|
+
while (leaveEvent.target && leaveEvent.target !== this.rootTarget.parent) {
|
|
759
|
+
leaveEvent.currentTarget = leaveEvent.target;
|
|
760
|
+
this.notifyTarget(leaveEvent);
|
|
761
|
+
if (isMouse) this.notifyTarget(leaveEvent, 'mouseleave');
|
|
762
|
+
leaveEvent.target = leaveEvent.target.parent;
|
|
763
|
+
}
|
|
764
|
+
trackingData.overTargets = null;
|
|
765
|
+
this.freeEvent(outEvent);
|
|
766
|
+
this.freeEvent(leaveEvent);
|
|
767
|
+
}
|
|
768
|
+
this.cursor = null;
|
|
769
|
+
}
|
|
770
|
+
mapPointerUp(from) {
|
|
771
|
+
if (!(from instanceof FederatedPointerEvent)) {
|
|
772
|
+
pixi_js.warn('EventBoundary cannot map a non-pointer event as a pointer event');
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
const now = performance.now();
|
|
776
|
+
const e = this.createPointerEvent(from);
|
|
777
|
+
this.dispatchEvent(e, 'pointerup');
|
|
778
|
+
if (e.pointerType === 'touch') {
|
|
779
|
+
this.dispatchEvent(e, 'touchend');
|
|
780
|
+
} else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
|
|
781
|
+
const isRightButton = e.button === 2;
|
|
782
|
+
this.dispatchEvent(e, isRightButton ? 'rightup' : 'mouseup');
|
|
783
|
+
}
|
|
784
|
+
const trackingData = this.trackingData(from.pointerId);
|
|
785
|
+
const pressTarget = this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
|
|
786
|
+
let clickTarget = pressTarget;
|
|
787
|
+
if (pressTarget && !e.composedPath().includes(pressTarget)) {
|
|
788
|
+
let currentTarget = pressTarget;
|
|
789
|
+
while (currentTarget && !e.composedPath().includes(currentTarget)) {
|
|
790
|
+
e.currentTarget = currentTarget;
|
|
791
|
+
this.notifyTarget(e, 'pointerupoutside');
|
|
792
|
+
if (e.pointerType === 'touch') {
|
|
793
|
+
this.notifyTarget(e, 'touchendoutside');
|
|
794
|
+
} else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
|
|
795
|
+
const isRightButton = e.button === 2;
|
|
796
|
+
this.notifyTarget(e, isRightButton ? 'rightupoutside' : 'mouseupoutside');
|
|
797
|
+
}
|
|
798
|
+
currentTarget = currentTarget.parent;
|
|
799
|
+
}
|
|
800
|
+
delete trackingData.pressTargetsByButton[from.button];
|
|
801
|
+
clickTarget = currentTarget;
|
|
802
|
+
}
|
|
803
|
+
if (clickTarget) {
|
|
804
|
+
const clickEvent = this.clonePointerEvent(e, 'click');
|
|
805
|
+
clickEvent.target = clickTarget;
|
|
806
|
+
clickEvent.path = null;
|
|
807
|
+
if (!trackingData.clicksByButton[from.button]) {
|
|
808
|
+
trackingData.clicksByButton[from.button] = {
|
|
809
|
+
clickCount: 0,
|
|
810
|
+
target: clickEvent.target,
|
|
811
|
+
timeStamp: now
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
const clickHistory = trackingData.clicksByButton[from.button];
|
|
815
|
+
if (clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < 200) {
|
|
816
|
+
++clickHistory.clickCount;
|
|
817
|
+
} else {
|
|
818
|
+
clickHistory.clickCount = 1;
|
|
819
|
+
}
|
|
820
|
+
clickHistory.target = clickEvent.target;
|
|
821
|
+
clickHistory.timeStamp = now;
|
|
822
|
+
clickEvent.detail = clickHistory.clickCount;
|
|
823
|
+
if (clickEvent.pointerType === 'mouse') {
|
|
824
|
+
const isRightButton = clickEvent.button === 2;
|
|
825
|
+
this.dispatchEvent(clickEvent, isRightButton ? 'rightclick' : 'click');
|
|
826
|
+
} else if (clickEvent.pointerType === 'touch') {
|
|
827
|
+
this.dispatchEvent(clickEvent, 'tap');
|
|
828
|
+
}
|
|
829
|
+
this.dispatchEvent(clickEvent, 'pointertap');
|
|
830
|
+
this.freeEvent(clickEvent);
|
|
831
|
+
}
|
|
832
|
+
this.freeEvent(e);
|
|
833
|
+
}
|
|
834
|
+
mapPointerUpOutside(from) {
|
|
835
|
+
if (!(from instanceof FederatedPointerEvent)) {
|
|
836
|
+
pixi_js.warn('EventBoundary cannot map a non-pointer event as a pointer event');
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
const trackingData = this.trackingData(from.pointerId);
|
|
840
|
+
const pressTarget = this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
|
|
841
|
+
const e = this.createPointerEvent(from);
|
|
842
|
+
if (pressTarget) {
|
|
843
|
+
let currentTarget = pressTarget;
|
|
844
|
+
while (currentTarget) {
|
|
845
|
+
e.currentTarget = currentTarget;
|
|
846
|
+
this.notifyTarget(e, 'pointerupoutside');
|
|
847
|
+
if (e.pointerType === 'touch') {
|
|
848
|
+
this.notifyTarget(e, 'touchendoutside');
|
|
849
|
+
} else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
|
|
850
|
+
this.notifyTarget(e, e.button === 2 ? 'rightupoutside' : 'mouseupoutside');
|
|
851
|
+
}
|
|
852
|
+
currentTarget = currentTarget.parent;
|
|
853
|
+
}
|
|
854
|
+
delete trackingData.pressTargetsByButton[from.button];
|
|
855
|
+
}
|
|
856
|
+
this.freeEvent(e);
|
|
857
|
+
}
|
|
858
|
+
mapWheel(from) {
|
|
859
|
+
if (!(from instanceof FederatedWheelEvent)) {
|
|
860
|
+
pixi_js.warn('EventBoundary cannot map a non-wheel event as a wheel event');
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
const wheelEvent = this.createWheelEvent(from);
|
|
864
|
+
this.dispatchEvent(wheelEvent);
|
|
865
|
+
this.freeEvent(wheelEvent);
|
|
866
|
+
}
|
|
867
|
+
findMountedTarget(propagationPath) {
|
|
868
|
+
if (!propagationPath) {
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
let currentTarget = propagationPath[0];
|
|
872
|
+
for (let i = 1; i < propagationPath.length; i++) {
|
|
873
|
+
if (propagationPath[i].parent === currentTarget) {
|
|
874
|
+
currentTarget = propagationPath[i];
|
|
875
|
+
} else {
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
return currentTarget;
|
|
880
|
+
}
|
|
881
|
+
createPointerEvent(from, type, target) {
|
|
882
|
+
var _a;
|
|
883
|
+
const event = this.allocateEvent(FederatedPointerEvent);
|
|
884
|
+
this.copyPointerData(from, event);
|
|
885
|
+
this.copyMouseData(from, event);
|
|
886
|
+
this.copyData(from, event);
|
|
887
|
+
event.nativeEvent = from.nativeEvent;
|
|
888
|
+
event.originalEvent = from;
|
|
889
|
+
event.target = (_a = target !== null && target !== void 0 ? target : this.hitTest(event.global.x, event.global.y)) !== null && _a !== void 0 ? _a : this._hitElements[0];
|
|
890
|
+
if (typeof type === 'string') {
|
|
891
|
+
event.type = type;
|
|
892
|
+
}
|
|
893
|
+
return event;
|
|
894
|
+
}
|
|
895
|
+
createWheelEvent(from) {
|
|
896
|
+
const event = this.allocateEvent(FederatedWheelEvent);
|
|
897
|
+
this.copyWheelData(from, event);
|
|
898
|
+
this.copyMouseData(from, event);
|
|
899
|
+
this.copyData(from, event);
|
|
900
|
+
event.nativeEvent = from.nativeEvent;
|
|
901
|
+
event.originalEvent = from;
|
|
902
|
+
event.target = this.hitTest(event.global.x, event.global.y);
|
|
903
|
+
return event;
|
|
904
|
+
}
|
|
905
|
+
clonePointerEvent(from, type) {
|
|
906
|
+
const event = this.allocateEvent(FederatedPointerEvent);
|
|
907
|
+
event.nativeEvent = from.nativeEvent;
|
|
908
|
+
event.originalEvent = from.originalEvent;
|
|
909
|
+
this.copyPointerData(from, event);
|
|
910
|
+
this.copyMouseData(from, event);
|
|
911
|
+
this.copyData(from, event);
|
|
912
|
+
event.target = from.target;
|
|
913
|
+
event.path = from.composedPath().slice();
|
|
914
|
+
event.type = type !== null && type !== void 0 ? type : event.type;
|
|
915
|
+
return event;
|
|
916
|
+
}
|
|
917
|
+
copyWheelData(from, to) {
|
|
918
|
+
to.deltaMode = from.deltaMode;
|
|
919
|
+
to.deltaX = from.deltaX;
|
|
920
|
+
to.deltaY = from.deltaY;
|
|
921
|
+
to.deltaZ = from.deltaZ;
|
|
922
|
+
}
|
|
923
|
+
copyPointerData(from, to) {
|
|
924
|
+
if (!(from instanceof FederatedPointerEvent && to instanceof FederatedPointerEvent)) return;
|
|
925
|
+
to.pointerId = from.pointerId;
|
|
926
|
+
to.width = from.width;
|
|
927
|
+
to.height = from.height;
|
|
928
|
+
to.isPrimary = from.isPrimary;
|
|
929
|
+
to.pointerType = from.pointerType;
|
|
930
|
+
to.pressure = from.pressure;
|
|
931
|
+
to.tangentialPressure = from.tangentialPressure;
|
|
932
|
+
to.tiltX = from.tiltX;
|
|
933
|
+
to.tiltY = from.tiltY;
|
|
934
|
+
to.twist = from.twist;
|
|
935
|
+
}
|
|
936
|
+
copyMouseData(from, to) {
|
|
937
|
+
if (!(from instanceof FederatedMouseEvent && to instanceof FederatedMouseEvent)) return;
|
|
938
|
+
to.altKey = from.altKey;
|
|
939
|
+
to.button = from.button;
|
|
940
|
+
to.buttons = from.buttons;
|
|
941
|
+
to.client.copyFrom(from.client);
|
|
942
|
+
to.ctrlKey = from.ctrlKey;
|
|
943
|
+
to.metaKey = from.metaKey;
|
|
944
|
+
to.movement.copyFrom(from.movement);
|
|
945
|
+
to.screen.copyFrom(from.screen);
|
|
946
|
+
to.shiftKey = from.shiftKey;
|
|
947
|
+
to.global.copyFrom(from.global);
|
|
948
|
+
}
|
|
949
|
+
copyData(from, to) {
|
|
950
|
+
to.isTrusted = from.isTrusted;
|
|
951
|
+
to.srcElement = from.srcElement;
|
|
952
|
+
to.timeStamp = performance.now();
|
|
953
|
+
to.type = from.type;
|
|
954
|
+
to.detail = from.detail;
|
|
955
|
+
to.view = from.view;
|
|
956
|
+
to.which = from.which;
|
|
957
|
+
to.layer.copyFrom(from.layer);
|
|
958
|
+
to.page.copyFrom(from.page);
|
|
959
|
+
}
|
|
960
|
+
trackingData(id) {
|
|
961
|
+
if (!this.mappingState.trackingData[id]) {
|
|
962
|
+
this.mappingState.trackingData[id] = {
|
|
963
|
+
pressTargetsByButton: {},
|
|
964
|
+
clicksByButton: {},
|
|
965
|
+
overTarget: null
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
return this.mappingState.trackingData[id];
|
|
969
|
+
}
|
|
970
|
+
allocateEvent(constructor) {
|
|
971
|
+
if (!this.eventPool.has(constructor)) {
|
|
972
|
+
this.eventPool.set(constructor, []);
|
|
973
|
+
}
|
|
974
|
+
const event = this.eventPool.get(constructor).pop() || new constructor(this);
|
|
975
|
+
event.eventPhase = event.NONE;
|
|
976
|
+
event.currentTarget = null;
|
|
977
|
+
event.defaultPrevented = false;
|
|
978
|
+
event.path = null;
|
|
979
|
+
event.target = null;
|
|
980
|
+
return event;
|
|
981
|
+
}
|
|
982
|
+
freeEvent(event) {
|
|
983
|
+
if (event.manager !== this) throw new Error('It is illegal to free an event not managed by this EventBoundary!');
|
|
984
|
+
const constructor = event.constructor;
|
|
985
|
+
if (!this.eventPool.has(constructor)) {
|
|
986
|
+
this.eventPool.set(constructor, []);
|
|
987
|
+
}
|
|
988
|
+
this.eventPool.get(constructor).push(event);
|
|
989
|
+
}
|
|
990
|
+
_notifyListeners(e, type) {
|
|
991
|
+
const listeners = e.currentTarget._events[type];
|
|
992
|
+
if (!listeners) return;
|
|
993
|
+
if ('fn' in listeners) {
|
|
994
|
+
if (listeners.once) e.currentTarget.removeListener(type, listeners.fn, undefined, true);
|
|
995
|
+
listeners.fn.call(listeners.context, e);
|
|
996
|
+
} else {
|
|
997
|
+
for (let i = 0, j = listeners.length; i < j && !e.propagationImmediatelyStopped; i++) {
|
|
998
|
+
if (listeners[i].once) e.currentTarget.removeListener(type, listeners[i].fn, undefined, true);
|
|
999
|
+
listeners[i].fn.call(listeners[i].context, e);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
const TOUCH_TO_POINTER = {
|
|
1005
|
+
touchstart: 'pointerdown',
|
|
1006
|
+
touchend: 'pointerup',
|
|
1007
|
+
touchendoutside: 'pointerupoutside',
|
|
1008
|
+
touchmove: 'pointermove',
|
|
1009
|
+
touchcancel: 'pointercancel'
|
|
1010
|
+
};
|
|
1011
|
+
class EventSystem {
|
|
1012
|
+
constructor(renderer) {
|
|
1013
|
+
this.supportsTouchEvents = 'ontouchstart' in globalThis;
|
|
1014
|
+
this.supportsPointerEvents = !!globalThis.PointerEvent;
|
|
1015
|
+
this.domElement = null;
|
|
1016
|
+
this.resolution = 1;
|
|
1017
|
+
this.renderer = renderer;
|
|
1018
|
+
this.rootBoundary = new EventBoundary(null);
|
|
1019
|
+
EventsTicker.init(this);
|
|
1020
|
+
this.autoPreventDefault = true;
|
|
1021
|
+
this._eventsAdded = false;
|
|
1022
|
+
this._rootPointerEvent = new FederatedPointerEvent(null);
|
|
1023
|
+
this._rootWheelEvent = new FederatedWheelEvent(null);
|
|
1024
|
+
this.cursorStyles = {
|
|
1025
|
+
default: 'inherit',
|
|
1026
|
+
pointer: 'pointer'
|
|
1027
|
+
};
|
|
1028
|
+
this.features = new Proxy(_extends({}, EventSystem.defaultEventFeatures), {
|
|
1029
|
+
set: (target, key, value) => {
|
|
1030
|
+
if (key === 'globalMove') {
|
|
1031
|
+
this.rootBoundary.enableGlobalMoveEvents = value;
|
|
1032
|
+
}
|
|
1033
|
+
target[key] = value;
|
|
1034
|
+
return true;
|
|
1035
|
+
}
|
|
1036
|
+
});
|
|
1037
|
+
this._onPointerDown = this._onPointerDown.bind(this);
|
|
1038
|
+
this._onPointerMove = this._onPointerMove.bind(this);
|
|
1039
|
+
this._onPointerUp = this._onPointerUp.bind(this);
|
|
1040
|
+
this._onPointerOverOut = this._onPointerOverOut.bind(this);
|
|
1041
|
+
this.onWheel = this.onWheel.bind(this);
|
|
1042
|
+
}
|
|
1043
|
+
static get defaultEventMode() {
|
|
1044
|
+
return this._defaultEventMode;
|
|
1045
|
+
}
|
|
1046
|
+
init(options) {
|
|
1047
|
+
var _a, _b;
|
|
1048
|
+
const {
|
|
1049
|
+
canvas,
|
|
1050
|
+
resolution
|
|
1051
|
+
} = this.renderer;
|
|
1052
|
+
this.setTargetElement(canvas);
|
|
1053
|
+
this.resolution = resolution;
|
|
1054
|
+
EventSystem._defaultEventMode = (_a = options.eventMode) !== null && _a !== void 0 ? _a : 'passive';
|
|
1055
|
+
_extends(this.features, (_b = options.eventFeatures) !== null && _b !== void 0 ? _b : {});
|
|
1056
|
+
this.rootBoundary.enableGlobalMoveEvents = this.features.globalMove;
|
|
1057
|
+
}
|
|
1058
|
+
resolutionChange(resolution) {
|
|
1059
|
+
this.resolution = resolution;
|
|
1060
|
+
}
|
|
1061
|
+
destroy() {
|
|
1062
|
+
this.setTargetElement(null);
|
|
1063
|
+
this.renderer = null;
|
|
1064
|
+
this._currentCursor = null;
|
|
1065
|
+
}
|
|
1066
|
+
setCursor(mode) {
|
|
1067
|
+
if (!mode) {
|
|
1068
|
+
mode = 'default';
|
|
1069
|
+
}
|
|
1070
|
+
let applyStyles = true;
|
|
1071
|
+
if (globalThis.OffscreenCanvas && this.domElement instanceof OffscreenCanvas) {
|
|
1072
|
+
applyStyles = false;
|
|
1073
|
+
}
|
|
1074
|
+
if (this._currentCursor === mode) {
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
this._currentCursor = mode;
|
|
1078
|
+
const style = this.cursorStyles[mode];
|
|
1079
|
+
if (style) {
|
|
1080
|
+
switch (typeof style) {
|
|
1081
|
+
case 'string':
|
|
1082
|
+
if (applyStyles) {
|
|
1083
|
+
this.domElement.style.cursor = style;
|
|
1084
|
+
}
|
|
1085
|
+
break;
|
|
1086
|
+
case 'function':
|
|
1087
|
+
style(mode);
|
|
1088
|
+
break;
|
|
1089
|
+
case 'object':
|
|
1090
|
+
if (applyStyles) {
|
|
1091
|
+
_extends(this.domElement.style, style);
|
|
1092
|
+
}
|
|
1093
|
+
break;
|
|
1094
|
+
}
|
|
1095
|
+
} else if (applyStyles && typeof mode === 'string' && !Object.prototype.hasOwnProperty.call(this.cursorStyles, mode)) {
|
|
1096
|
+
this.domElement.style.cursor = mode;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
get pointer() {
|
|
1100
|
+
return this._rootPointerEvent;
|
|
1101
|
+
}
|
|
1102
|
+
_onPointerDown(nativeEvent) {
|
|
1103
|
+
if (!this.features.click) return;
|
|
1104
|
+
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
|
1105
|
+
const events = this._normalizeToPointerData(nativeEvent);
|
|
1106
|
+
if (this.autoPreventDefault && events[0].isNormalized) {
|
|
1107
|
+
const cancelable = nativeEvent.cancelable || !('cancelable' in nativeEvent);
|
|
1108
|
+
if (cancelable) {
|
|
1109
|
+
nativeEvent.preventDefault();
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
for (let i = 0, j = events.length; i < j; i++) {
|
|
1113
|
+
const nativeEvent = events[i];
|
|
1114
|
+
const federatedEvent = this._bootstrapEvent(this._rootPointerEvent, nativeEvent);
|
|
1115
|
+
this.rootBoundary.mapEvent(federatedEvent);
|
|
1116
|
+
}
|
|
1117
|
+
this.setCursor(this.rootBoundary.cursor);
|
|
1118
|
+
}
|
|
1119
|
+
_onPointerMove(nativeEvent) {
|
|
1120
|
+
if (!this.features.move) return;
|
|
1121
|
+
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
|
1122
|
+
EventsTicker.pointerMoved();
|
|
1123
|
+
const normalizedEvents = this._normalizeToPointerData(nativeEvent);
|
|
1124
|
+
for (let i = 0, j = normalizedEvents.length; i < j; i++) {
|
|
1125
|
+
const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
|
|
1126
|
+
this.rootBoundary.mapEvent(event);
|
|
1127
|
+
}
|
|
1128
|
+
this.setCursor(this.rootBoundary.cursor);
|
|
1129
|
+
}
|
|
1130
|
+
_onPointerUp(nativeEvent) {
|
|
1131
|
+
if (!this.features.click) return;
|
|
1132
|
+
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
|
1133
|
+
const outside = '';
|
|
1134
|
+
const normalizedEvents = this._normalizeToPointerData(nativeEvent);
|
|
1135
|
+
for (let i = 0, j = normalizedEvents.length; i < j; i++) {
|
|
1136
|
+
const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
|
|
1137
|
+
event.type += outside;
|
|
1138
|
+
this.rootBoundary.mapEvent(event);
|
|
1139
|
+
}
|
|
1140
|
+
this.setCursor(this.rootBoundary.cursor);
|
|
1141
|
+
}
|
|
1142
|
+
_onPointerOverOut(nativeEvent) {
|
|
1143
|
+
if (!this.features.click) return;
|
|
1144
|
+
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
|
1145
|
+
const normalizedEvents = this._normalizeToPointerData(nativeEvent);
|
|
1146
|
+
for (let i = 0, j = normalizedEvents.length; i < j; i++) {
|
|
1147
|
+
const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
|
|
1148
|
+
this.rootBoundary.mapEvent(event);
|
|
1149
|
+
}
|
|
1150
|
+
this.setCursor(this.rootBoundary.cursor);
|
|
1151
|
+
}
|
|
1152
|
+
onWheel(nativeEvent) {
|
|
1153
|
+
if (!this.features.wheel) return;
|
|
1154
|
+
const wheelEvent = this.normalizeWheelEvent(nativeEvent);
|
|
1155
|
+
this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
|
|
1156
|
+
this.rootBoundary.mapEvent(wheelEvent);
|
|
1157
|
+
}
|
|
1158
|
+
setTargetElement(element) {
|
|
1159
|
+
this._removeEvents();
|
|
1160
|
+
this.domElement = element;
|
|
1161
|
+
EventsTicker.domElement = element;
|
|
1162
|
+
this._addEvents();
|
|
1163
|
+
}
|
|
1164
|
+
_addEvents() {
|
|
1165
|
+
if (this._eventsAdded || !this.domElement) {
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
EventsTicker.addTickerListener();
|
|
1169
|
+
const style = this.domElement.style;
|
|
1170
|
+
if (style) {
|
|
1171
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
1172
|
+
style.msContentZooming = 'none';
|
|
1173
|
+
style.msTouchAction = 'none';
|
|
1174
|
+
} else if (this.supportsPointerEvents) {
|
|
1175
|
+
style.touchAction = 'none';
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
EventSystem.eventsHandler = {
|
|
1179
|
+
pointermove: this._onPointerMove.bind(this),
|
|
1180
|
+
pointerdown: this._onPointerDown.bind(this),
|
|
1181
|
+
pointerleave: this._onPointerOverOut.bind(this),
|
|
1182
|
+
pointerover: this._onPointerOverOut.bind(this),
|
|
1183
|
+
pointerup: this._onPointerUp.bind(this),
|
|
1184
|
+
mousemove: this._onPointerMove.bind(this),
|
|
1185
|
+
mousedown: this._onPointerDown.bind(this),
|
|
1186
|
+
mouseout: this._onPointerOverOut.bind(this),
|
|
1187
|
+
mouseover: this._onPointerOverOut.bind(this),
|
|
1188
|
+
mouseup: this._onPointerUp.bind(this),
|
|
1189
|
+
touchstart: this._onPointerDown.bind(this),
|
|
1190
|
+
touchend: this._onPointerUp.bind(this),
|
|
1191
|
+
touchmove: this._onPointerMove.bind(this)
|
|
1192
|
+
};
|
|
1193
|
+
EventSystem.eventsHandler['wheel'] = this.onWheel.bind(this);
|
|
1194
|
+
this._eventsAdded = true;
|
|
1195
|
+
}
|
|
1196
|
+
_removeEvents() {
|
|
1197
|
+
if (!this._eventsAdded || !this.domElement) {
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
EventsTicker.removeTickerListener();
|
|
1201
|
+
const style = this.domElement.style;
|
|
1202
|
+
if (style) {
|
|
1203
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
1204
|
+
style.msContentZooming = '';
|
|
1205
|
+
style.msTouchAction = '';
|
|
1206
|
+
} else if (this.supportsPointerEvents) {
|
|
1207
|
+
style.touchAction = '';
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
EventSystem.eventsHandler = [];
|
|
1211
|
+
this.domElement = null;
|
|
1212
|
+
this._eventsAdded = false;
|
|
1213
|
+
}
|
|
1214
|
+
mapPositionToPoint(point, x, y) {
|
|
1215
|
+
const rect = this.domElement.isConnected ? this.domElement.getBoundingClientRect() : {
|
|
1216
|
+
x: 0,
|
|
1217
|
+
y: 0,
|
|
1218
|
+
width: this.domElement.width,
|
|
1219
|
+
height: this.domElement.height,
|
|
1220
|
+
left: 0,
|
|
1221
|
+
top: 0
|
|
1222
|
+
};
|
|
1223
|
+
const resolutionMultiplier = 1.0 / this.resolution;
|
|
1224
|
+
point.x = (x - rect.left) * (this.domElement.width / rect.width) * resolutionMultiplier;
|
|
1225
|
+
point.y = (y - rect.top) * (this.domElement.height / rect.height) * resolutionMultiplier;
|
|
1226
|
+
}
|
|
1227
|
+
_normalizeToPointerData(event) {
|
|
1228
|
+
return event.normalizedEvents;
|
|
1229
|
+
}
|
|
1230
|
+
normalizeWheelEvent(nativeEvent) {
|
|
1231
|
+
const event = this._rootWheelEvent;
|
|
1232
|
+
this._transferMouseData(event, nativeEvent);
|
|
1233
|
+
event.deltaX = nativeEvent.deltaX;
|
|
1234
|
+
event.deltaY = nativeEvent.deltaY;
|
|
1235
|
+
event.deltaZ = nativeEvent.deltaZ;
|
|
1236
|
+
event.deltaMode = nativeEvent.deltaMode;
|
|
1237
|
+
this.mapPositionToPoint(event.screen, nativeEvent.clientX, nativeEvent.clientY);
|
|
1238
|
+
event.global.copyFrom(event.screen);
|
|
1239
|
+
event.offset.copyFrom(event.screen);
|
|
1240
|
+
event.nativeEvent = nativeEvent;
|
|
1241
|
+
event.type = nativeEvent.type;
|
|
1242
|
+
return event;
|
|
1243
|
+
}
|
|
1244
|
+
_bootstrapEvent(event, nativeEvent) {
|
|
1245
|
+
event.originalEvent = null;
|
|
1246
|
+
event.nativeEvent = nativeEvent;
|
|
1247
|
+
event.pointerId = nativeEvent.pointerId;
|
|
1248
|
+
event.width = nativeEvent.width;
|
|
1249
|
+
event.height = nativeEvent.height;
|
|
1250
|
+
event.isPrimary = nativeEvent.isPrimary;
|
|
1251
|
+
event.pointerType = nativeEvent.pointerType;
|
|
1252
|
+
event.pressure = nativeEvent.pressure;
|
|
1253
|
+
event.tangentialPressure = nativeEvent.tangentialPressure;
|
|
1254
|
+
event.tiltX = nativeEvent.tiltX;
|
|
1255
|
+
event.tiltY = nativeEvent.tiltY;
|
|
1256
|
+
event.twist = nativeEvent.twist;
|
|
1257
|
+
this._transferMouseData(event, nativeEvent);
|
|
1258
|
+
this.mapPositionToPoint(event.screen, nativeEvent.clientX, nativeEvent.clientY);
|
|
1259
|
+
event.global.copyFrom(event.screen);
|
|
1260
|
+
event.offset.copyFrom(event.screen);
|
|
1261
|
+
event.isTrusted = nativeEvent.isTrusted;
|
|
1262
|
+
if (event.type === 'pointerleave') {
|
|
1263
|
+
event.type = 'pointerout';
|
|
1264
|
+
}
|
|
1265
|
+
if (event.type.startsWith('mouse')) {
|
|
1266
|
+
event.type = event.type.replace('mouse', 'pointer');
|
|
1267
|
+
}
|
|
1268
|
+
if (event.type.startsWith('touch')) {
|
|
1269
|
+
event.type = TOUCH_TO_POINTER[event.type] || event.type;
|
|
1270
|
+
}
|
|
1271
|
+
return event;
|
|
1272
|
+
}
|
|
1273
|
+
_transferMouseData(event, nativeEvent) {
|
|
1274
|
+
event.isTrusted = nativeEvent.isTrusted;
|
|
1275
|
+
event.srcElement = nativeEvent.srcElement;
|
|
1276
|
+
event.timeStamp = performance.now();
|
|
1277
|
+
event.type = nativeEvent.type;
|
|
1278
|
+
event.altKey = nativeEvent.altKey;
|
|
1279
|
+
event.button = nativeEvent.button;
|
|
1280
|
+
event.buttons = nativeEvent.buttons;
|
|
1281
|
+
event.client.x = nativeEvent.clientX;
|
|
1282
|
+
event.client.y = nativeEvent.clientY;
|
|
1283
|
+
event.ctrlKey = nativeEvent.ctrlKey;
|
|
1284
|
+
event.metaKey = nativeEvent.metaKey;
|
|
1285
|
+
event.movement.x = nativeEvent.movementX;
|
|
1286
|
+
event.movement.y = nativeEvent.movementY;
|
|
1287
|
+
event.page.x = nativeEvent.pageX;
|
|
1288
|
+
event.page.y = nativeEvent.pageY;
|
|
1289
|
+
event.relatedTarget = null;
|
|
1290
|
+
event.shiftKey = nativeEvent.shiftKey;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
EventSystem.extension = {
|
|
1294
|
+
name: 'events',
|
|
1295
|
+
type: [pixi_js.ExtensionType.WebGLSystem, pixi_js.ExtensionType.CanvasSystem, pixi_js.ExtensionType.WebGPUSystem],
|
|
1296
|
+
priority: -1
|
|
1297
|
+
};
|
|
1298
|
+
EventSystem.eventsHandler = {};
|
|
1299
|
+
EventSystem.defaultEventFeatures = {
|
|
1300
|
+
move: true,
|
|
1301
|
+
globalMove: true,
|
|
1302
|
+
click: true,
|
|
1303
|
+
wheel: true
|
|
1304
|
+
};
|
|
1305
|
+
const eventHandler = data => {
|
|
1306
|
+
const {
|
|
1307
|
+
type,
|
|
1308
|
+
eventName,
|
|
1309
|
+
event,
|
|
1310
|
+
normalizedEvents
|
|
1311
|
+
} = data;
|
|
1312
|
+
if (type === 'eva-event') {
|
|
1313
|
+
const fn = EventSystem.eventsHandler[eventName];
|
|
1314
|
+
fn && fn(_extends(_extends({}, event), {
|
|
1315
|
+
preventDefault() {},
|
|
1316
|
+
normalizedEvents
|
|
1317
|
+
}));
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
exports.eventHandler = eventHandler;
|
|
1321
|
+
Object.defineProperty(exports, '__esModule', {
|
|
1322
|
+
value: true
|
|
1323
|
+
});
|
|
1324
|
+
return exports;
|
|
1325
|
+
}({}, PIXI);
|
|
1326
|
+
window.EVA.plugin.worker = window.EVA.plugin.worker || _EVA_IIFE_worker;
|