@next2d/events 3.8.2 → 3.9.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next2d/events",
3
- "version": "3.8.2",
3
+ "version": "3.9.0",
4
4
  "description": "Next2D Events Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",
@@ -22,5 +22,6 @@
22
22
  "repository": {
23
23
  "type": "git",
24
24
  "url": "git+https://github.com/Next2D/Player.git"
25
- }
25
+ },
26
+ "sideEffects": false
26
27
  }
@@ -18,6 +18,276 @@ export declare class PointerEvent extends Event {
18
18
  * @public
19
19
  */
20
20
  constructor(type: string, bubbles?: boolean);
21
+ /**
22
+ * @description ポインターの一意な識別子
23
+ * Unique identifier of the pointer
24
+ *
25
+ * @return {number | undefined}
26
+ * @readonly
27
+ * @public
28
+ */
29
+ get pointerId(): number | undefined;
30
+ /**
31
+ * @description ポインターのデバイス種別(mouse, pen, touch)
32
+ * Device type of the pointer (mouse, pen, touch)
33
+ *
34
+ * @return {string | undefined}
35
+ * @readonly
36
+ * @public
37
+ */
38
+ get pointerType(): string | undefined;
39
+ /**
40
+ * @description ポインターの接触ジオメトリの幅
41
+ * Width of the contact geometry of the pointer
42
+ *
43
+ * @return {number | undefined}
44
+ * @readonly
45
+ * @public
46
+ */
47
+ get width(): number | undefined;
48
+ /**
49
+ * @description ポインターの接触ジオメトリの高さ
50
+ * Height of the contact geometry of the pointer
51
+ *
52
+ * @return {number | undefined}
53
+ * @readonly
54
+ * @public
55
+ */
56
+ get height(): number | undefined;
57
+ /**
58
+ * @description ポインター入力の正規化された圧力(0〜1)
59
+ * Normalized pressure of the pointer input (0-1)
60
+ *
61
+ * @return {number | undefined}
62
+ * @readonly
63
+ * @public
64
+ */
65
+ get pressure(): number | undefined;
66
+ /**
67
+ * @description ポインター入力の正規化された接線圧力
68
+ * Normalized tangential pressure of the pointer input
69
+ *
70
+ * @return {number | undefined}
71
+ * @readonly
72
+ * @public
73
+ */
74
+ get tangentialPressure(): number | undefined;
75
+ /**
76
+ * @description Y-Z平面とポインター軸を含む平面の間の角度
77
+ * Angle between the Y-Z plane and the plane containing the pointer axis
78
+ *
79
+ * @return {number | undefined}
80
+ * @readonly
81
+ * @public
82
+ */
83
+ get tiltX(): number | undefined;
84
+ /**
85
+ * @description X-Z平面とポインター軸を含む平面の間の角度
86
+ * Angle between the X-Z plane and the plane containing the pointer axis
87
+ *
88
+ * @return {number | undefined}
89
+ * @readonly
90
+ * @public
91
+ */
92
+ get tiltY(): number | undefined;
93
+ /**
94
+ * @description ポインターの長軸周りの回転角
95
+ * Rotation of the pointer around its major axis
96
+ *
97
+ * @return {number | undefined}
98
+ * @readonly
99
+ * @public
100
+ */
101
+ get twist(): number | undefined;
102
+ /**
103
+ * @description プライマリポインターかどうか
104
+ * Whether the pointer is the primary pointer
105
+ *
106
+ * @return {boolean | undefined}
107
+ * @readonly
108
+ * @public
109
+ */
110
+ get isPrimary(): boolean | undefined;
111
+ /**
112
+ * @description クライアント座標X
113
+ * Client X coordinate
114
+ *
115
+ * @return {number | undefined}
116
+ * @readonly
117
+ * @public
118
+ */
119
+ get clientX(): number | undefined;
120
+ /**
121
+ * @description クライアント座標Y
122
+ * Client Y coordinate
123
+ *
124
+ * @return {number | undefined}
125
+ * @readonly
126
+ * @public
127
+ */
128
+ get clientY(): number | undefined;
129
+ /**
130
+ * @description ページ座標X
131
+ * Page X coordinate
132
+ *
133
+ * @return {number | undefined}
134
+ * @readonly
135
+ * @public
136
+ */
137
+ get pageX(): number | undefined;
138
+ /**
139
+ * @description ページ座標Y
140
+ * Page Y coordinate
141
+ *
142
+ * @return {number | undefined}
143
+ * @readonly
144
+ * @public
145
+ */
146
+ get pageY(): number | undefined;
147
+ /**
148
+ * @description スクリーン座標X
149
+ * Screen X coordinate
150
+ *
151
+ * @return {number | undefined}
152
+ * @readonly
153
+ * @public
154
+ */
155
+ get screenX(): number | undefined;
156
+ /**
157
+ * @description スクリーン座標Y
158
+ * Screen Y coordinate
159
+ *
160
+ * @return {number | undefined}
161
+ * @readonly
162
+ * @public
163
+ */
164
+ get screenY(): number | undefined;
165
+ /**
166
+ * @description 要素のパディング辺からの相対座標X
167
+ * X coordinate relative to the padding edge of the element
168
+ *
169
+ * @return {number | undefined}
170
+ * @readonly
171
+ * @public
172
+ */
173
+ get offsetX(): number | undefined;
174
+ /**
175
+ * @description 要素のパディング辺からの相対座標Y
176
+ * Y coordinate relative to the padding edge of the element
177
+ *
178
+ * @return {number | undefined}
179
+ * @readonly
180
+ * @public
181
+ */
182
+ get offsetY(): number | undefined;
183
+ /**
184
+ * @description 直前のイベントからのX方向の移動量
185
+ * Movement on the X axis since the previous event
186
+ *
187
+ * @return {number | undefined}
188
+ * @readonly
189
+ * @public
190
+ */
191
+ get movementX(): number | undefined;
192
+ /**
193
+ * @description 直前のイベントからのY方向の移動量
194
+ * Movement on the Y axis since the previous event
195
+ *
196
+ * @return {number | undefined}
197
+ * @readonly
198
+ * @public
199
+ */
200
+ get movementY(): number | undefined;
201
+ /**
202
+ * @description クライアント座標X(clientXのエイリアス)
203
+ * Client X coordinate (alias of clientX)
204
+ *
205
+ * @return {number | undefined}
206
+ * @readonly
207
+ * @public
208
+ */
209
+ get x(): number | undefined;
210
+ /**
211
+ * @description クライアント座標Y(clientYのエイリアス)
212
+ * Client Y coordinate (alias of clientY)
213
+ *
214
+ * @return {number | undefined}
215
+ * @readonly
216
+ * @public
217
+ */
218
+ get y(): number | undefined;
219
+ /**
220
+ * @description 押されたボタンの番号
221
+ * Number of the pressed button
222
+ *
223
+ * @return {number | undefined}
224
+ * @readonly
225
+ * @public
226
+ */
227
+ get button(): number | undefined;
228
+ /**
229
+ * @description 押されているボタンのビットフラグ
230
+ * Bit flags of the buttons being pressed
231
+ *
232
+ * @return {number | undefined}
233
+ * @readonly
234
+ * @public
235
+ */
236
+ get buttons(): number | undefined;
237
+ /**
238
+ * @description Altキーが押されているかどうか
239
+ * Whether the Alt key is pressed
240
+ *
241
+ * @return {boolean | undefined}
242
+ * @readonly
243
+ * @public
244
+ */
245
+ get altKey(): boolean | undefined;
246
+ /**
247
+ * @description Ctrlキーが押されているかどうか
248
+ * Whether the Ctrl key is pressed
249
+ *
250
+ * @return {boolean | undefined}
251
+ * @readonly
252
+ * @public
253
+ */
254
+ get ctrlKey(): boolean | undefined;
255
+ /**
256
+ * @description Metaキーが押されているかどうか
257
+ * Whether the Meta key is pressed
258
+ *
259
+ * @return {boolean | undefined}
260
+ * @readonly
261
+ * @public
262
+ */
263
+ get metaKey(): boolean | undefined;
264
+ /**
265
+ * @description Shiftキーが押されているかどうか
266
+ * Whether the Shift key is pressed
267
+ *
268
+ * @return {boolean | undefined}
269
+ * @readonly
270
+ * @public
271
+ */
272
+ get shiftKey(): boolean | undefined;
273
+ /**
274
+ * @description イベントの詳細情報(クリック回数など)
275
+ * Detail information of the event (e.g. click count)
276
+ *
277
+ * @return {number | undefined}
278
+ * @readonly
279
+ * @public
280
+ */
281
+ get detail(): number | undefined;
282
+ /**
283
+ * @description イベント発生時のタイムスタンプ
284
+ * Timestamp when the event occurred
285
+ *
286
+ * @return {number | undefined}
287
+ * @readonly
288
+ * @public
289
+ */
290
+ get timeStamp(): number | undefined;
21
291
  /**
22
292
  * @description ボタンが連続で押された時に発生します。
23
293
  * Occurs when a button is pressed continuously.
@@ -1,5 +1,37 @@
1
1
  import { Event } from "./Event";
2
2
  import { $getEvent } from "./EventUtil";
3
+ /**
4
+ * @description 転送対象のポインターイベント発火中であれば、アクティブなネイティブイベントを返す。
5
+ * 旧実装ではProxyのgetトラップで同じ判定を行っていたが、pointermove毎の
6
+ * Proxy生成とプロパティアクセス毎のトラップ実行がCPU負荷になるため、
7
+ * 明示的なgetterと本ヘルパーに置き換えた。判定対象のイベント種別は旧実装と同一。
8
+ * Returns the active native event while a forwardable pointer event
9
+ * is being dispatched. The former Proxy-based implementation created
10
+ * a Proxy per pointermove and executed a get trap per property
11
+ * access, so it was replaced with explicit getters and this helper.
12
+ * The forwardable event types are identical to the old implementation.
13
+ *
14
+ * @return {PointerEvent | null}
15
+ * @method
16
+ * @private
17
+ */
18
+ const $getNativePointerEvent = () => {
19
+ const event = $getEvent();
20
+ if (!event) {
21
+ return null;
22
+ }
23
+ switch (event.type) {
24
+ case PointerEvent.POINTER_DOWN:
25
+ case PointerEvent.POINTER_MOVE:
26
+ case PointerEvent.POINTER_UP:
27
+ case PointerEvent.POINTER_LEAVE:
28
+ case PointerEvent.POINTER_OVER:
29
+ case PointerEvent.POINTER_OUT:
30
+ return event;
31
+ default:
32
+ return null;
33
+ }
34
+ };
3
35
  /**
4
36
  * @description ポインターは、入力機器(マウス、ペン、またはタッチ可能な面の上の接触点など)のハードウェアにとらわれない表現です。
5
37
  * ポインターは、画面などの接触面上の特定の座標(または座標の集合)をターゲットにすることができます。
@@ -20,32 +52,336 @@ export class PointerEvent extends Event {
20
52
  */
21
53
  constructor(type, bubbles = true) {
22
54
  super(type, bubbles);
23
- return new Proxy(this, {
24
- "get": (object, name) => {
25
- if (name in object) {
26
- return object[name];
27
- }
28
- const event = $getEvent();
29
- if (!event) {
30
- return undefined;
31
- }
32
- switch (event.type) {
33
- case PointerEvent.POINTER_DOWN:
34
- case PointerEvent.POINTER_MOVE:
35
- case PointerEvent.POINTER_UP:
36
- case PointerEvent.POINTER_LEAVE:
37
- case PointerEvent.POINTER_OVER:
38
- case PointerEvent.POINTER_OUT:
39
- if (name in event) {
40
- // @ts-ignore
41
- return $event[name];
42
- }
43
- return undefined;
44
- default:
45
- return undefined;
46
- }
47
- }
48
- });
55
+ }
56
+ /**
57
+ * @description ポインターの一意な識別子
58
+ * Unique identifier of the pointer
59
+ *
60
+ * @return {number | undefined}
61
+ * @readonly
62
+ * @public
63
+ */
64
+ get pointerId() {
65
+ return $getNativePointerEvent()?.pointerId;
66
+ }
67
+ /**
68
+ * @description ポインターのデバイス種別(mouse, pen, touch)
69
+ * Device type of the pointer (mouse, pen, touch)
70
+ *
71
+ * @return {string | undefined}
72
+ * @readonly
73
+ * @public
74
+ */
75
+ get pointerType() {
76
+ return $getNativePointerEvent()?.pointerType;
77
+ }
78
+ /**
79
+ * @description ポインターの接触ジオメトリの幅
80
+ * Width of the contact geometry of the pointer
81
+ *
82
+ * @return {number | undefined}
83
+ * @readonly
84
+ * @public
85
+ */
86
+ get width() {
87
+ return $getNativePointerEvent()?.width;
88
+ }
89
+ /**
90
+ * @description ポインターの接触ジオメトリの高さ
91
+ * Height of the contact geometry of the pointer
92
+ *
93
+ * @return {number | undefined}
94
+ * @readonly
95
+ * @public
96
+ */
97
+ get height() {
98
+ return $getNativePointerEvent()?.height;
99
+ }
100
+ /**
101
+ * @description ポインター入力の正規化された圧力(0〜1)
102
+ * Normalized pressure of the pointer input (0-1)
103
+ *
104
+ * @return {number | undefined}
105
+ * @readonly
106
+ * @public
107
+ */
108
+ get pressure() {
109
+ return $getNativePointerEvent()?.pressure;
110
+ }
111
+ /**
112
+ * @description ポインター入力の正規化された接線圧力
113
+ * Normalized tangential pressure of the pointer input
114
+ *
115
+ * @return {number | undefined}
116
+ * @readonly
117
+ * @public
118
+ */
119
+ get tangentialPressure() {
120
+ return $getNativePointerEvent()?.tangentialPressure;
121
+ }
122
+ /**
123
+ * @description Y-Z平面とポインター軸を含む平面の間の角度
124
+ * Angle between the Y-Z plane and the plane containing the pointer axis
125
+ *
126
+ * @return {number | undefined}
127
+ * @readonly
128
+ * @public
129
+ */
130
+ get tiltX() {
131
+ return $getNativePointerEvent()?.tiltX;
132
+ }
133
+ /**
134
+ * @description X-Z平面とポインター軸を含む平面の間の角度
135
+ * Angle between the X-Z plane and the plane containing the pointer axis
136
+ *
137
+ * @return {number | undefined}
138
+ * @readonly
139
+ * @public
140
+ */
141
+ get tiltY() {
142
+ return $getNativePointerEvent()?.tiltY;
143
+ }
144
+ /**
145
+ * @description ポインターの長軸周りの回転角
146
+ * Rotation of the pointer around its major axis
147
+ *
148
+ * @return {number | undefined}
149
+ * @readonly
150
+ * @public
151
+ */
152
+ get twist() {
153
+ return $getNativePointerEvent()?.twist;
154
+ }
155
+ /**
156
+ * @description プライマリポインターかどうか
157
+ * Whether the pointer is the primary pointer
158
+ *
159
+ * @return {boolean | undefined}
160
+ * @readonly
161
+ * @public
162
+ */
163
+ get isPrimary() {
164
+ return $getNativePointerEvent()?.isPrimary;
165
+ }
166
+ /**
167
+ * @description クライアント座標X
168
+ * Client X coordinate
169
+ *
170
+ * @return {number | undefined}
171
+ * @readonly
172
+ * @public
173
+ */
174
+ get clientX() {
175
+ return $getNativePointerEvent()?.clientX;
176
+ }
177
+ /**
178
+ * @description クライアント座標Y
179
+ * Client Y coordinate
180
+ *
181
+ * @return {number | undefined}
182
+ * @readonly
183
+ * @public
184
+ */
185
+ get clientY() {
186
+ return $getNativePointerEvent()?.clientY;
187
+ }
188
+ /**
189
+ * @description ページ座標X
190
+ * Page X coordinate
191
+ *
192
+ * @return {number | undefined}
193
+ * @readonly
194
+ * @public
195
+ */
196
+ get pageX() {
197
+ return $getNativePointerEvent()?.pageX;
198
+ }
199
+ /**
200
+ * @description ページ座標Y
201
+ * Page Y coordinate
202
+ *
203
+ * @return {number | undefined}
204
+ * @readonly
205
+ * @public
206
+ */
207
+ get pageY() {
208
+ return $getNativePointerEvent()?.pageY;
209
+ }
210
+ /**
211
+ * @description スクリーン座標X
212
+ * Screen X coordinate
213
+ *
214
+ * @return {number | undefined}
215
+ * @readonly
216
+ * @public
217
+ */
218
+ get screenX() {
219
+ return $getNativePointerEvent()?.screenX;
220
+ }
221
+ /**
222
+ * @description スクリーン座標Y
223
+ * Screen Y coordinate
224
+ *
225
+ * @return {number | undefined}
226
+ * @readonly
227
+ * @public
228
+ */
229
+ get screenY() {
230
+ return $getNativePointerEvent()?.screenY;
231
+ }
232
+ /**
233
+ * @description 要素のパディング辺からの相対座標X
234
+ * X coordinate relative to the padding edge of the element
235
+ *
236
+ * @return {number | undefined}
237
+ * @readonly
238
+ * @public
239
+ */
240
+ get offsetX() {
241
+ return $getNativePointerEvent()?.offsetX;
242
+ }
243
+ /**
244
+ * @description 要素のパディング辺からの相対座標Y
245
+ * Y coordinate relative to the padding edge of the element
246
+ *
247
+ * @return {number | undefined}
248
+ * @readonly
249
+ * @public
250
+ */
251
+ get offsetY() {
252
+ return $getNativePointerEvent()?.offsetY;
253
+ }
254
+ /**
255
+ * @description 直前のイベントからのX方向の移動量
256
+ * Movement on the X axis since the previous event
257
+ *
258
+ * @return {number | undefined}
259
+ * @readonly
260
+ * @public
261
+ */
262
+ get movementX() {
263
+ return $getNativePointerEvent()?.movementX;
264
+ }
265
+ /**
266
+ * @description 直前のイベントからのY方向の移動量
267
+ * Movement on the Y axis since the previous event
268
+ *
269
+ * @return {number | undefined}
270
+ * @readonly
271
+ * @public
272
+ */
273
+ get movementY() {
274
+ return $getNativePointerEvent()?.movementY;
275
+ }
276
+ /**
277
+ * @description クライアント座標X(clientXのエイリアス)
278
+ * Client X coordinate (alias of clientX)
279
+ *
280
+ * @return {number | undefined}
281
+ * @readonly
282
+ * @public
283
+ */
284
+ get x() {
285
+ return $getNativePointerEvent()?.x;
286
+ }
287
+ /**
288
+ * @description クライアント座標Y(clientYのエイリアス)
289
+ * Client Y coordinate (alias of clientY)
290
+ *
291
+ * @return {number | undefined}
292
+ * @readonly
293
+ * @public
294
+ */
295
+ get y() {
296
+ return $getNativePointerEvent()?.y;
297
+ }
298
+ /**
299
+ * @description 押されたボタンの番号
300
+ * Number of the pressed button
301
+ *
302
+ * @return {number | undefined}
303
+ * @readonly
304
+ * @public
305
+ */
306
+ get button() {
307
+ return $getNativePointerEvent()?.button;
308
+ }
309
+ /**
310
+ * @description 押されているボタンのビットフラグ
311
+ * Bit flags of the buttons being pressed
312
+ *
313
+ * @return {number | undefined}
314
+ * @readonly
315
+ * @public
316
+ */
317
+ get buttons() {
318
+ return $getNativePointerEvent()?.buttons;
319
+ }
320
+ /**
321
+ * @description Altキーが押されているかどうか
322
+ * Whether the Alt key is pressed
323
+ *
324
+ * @return {boolean | undefined}
325
+ * @readonly
326
+ * @public
327
+ */
328
+ get altKey() {
329
+ return $getNativePointerEvent()?.altKey;
330
+ }
331
+ /**
332
+ * @description Ctrlキーが押されているかどうか
333
+ * Whether the Ctrl key is pressed
334
+ *
335
+ * @return {boolean | undefined}
336
+ * @readonly
337
+ * @public
338
+ */
339
+ get ctrlKey() {
340
+ return $getNativePointerEvent()?.ctrlKey;
341
+ }
342
+ /**
343
+ * @description Metaキーが押されているかどうか
344
+ * Whether the Meta key is pressed
345
+ *
346
+ * @return {boolean | undefined}
347
+ * @readonly
348
+ * @public
349
+ */
350
+ get metaKey() {
351
+ return $getNativePointerEvent()?.metaKey;
352
+ }
353
+ /**
354
+ * @description Shiftキーが押されているかどうか
355
+ * Whether the Shift key is pressed
356
+ *
357
+ * @return {boolean | undefined}
358
+ * @readonly
359
+ * @public
360
+ */
361
+ get shiftKey() {
362
+ return $getNativePointerEvent()?.shiftKey;
363
+ }
364
+ /**
365
+ * @description イベントの詳細情報(クリック回数など)
366
+ * Detail information of the event (e.g. click count)
367
+ *
368
+ * @return {number | undefined}
369
+ * @readonly
370
+ * @public
371
+ */
372
+ get detail() {
373
+ return $getNativePointerEvent()?.detail;
374
+ }
375
+ /**
376
+ * @description イベント発生時のタイムスタンプ
377
+ * Timestamp when the event occurred
378
+ *
379
+ * @return {number | undefined}
380
+ * @readonly
381
+ * @public
382
+ */
383
+ get timeStamp() {
384
+ return $getNativePointerEvent()?.timeStamp;
49
385
  }
50
386
  /**
51
387
  * @description ボタンが連続で押された時に発生します。