@vpmedia/phaser 1.94.0 → 1.96.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/CHANGELOG.md +41 -0
- package/package.json +11 -11
- package/src/phaser/core/animation.js +79 -56
- package/src/phaser/core/animation_manager.js +55 -55
- package/src/phaser/core/animation_parser.js +2 -2
- package/src/phaser/core/cache.js +154 -154
- package/src/phaser/core/device.js +2 -1
- package/src/phaser/core/device_util.js +27 -27
- package/src/phaser/core/dom.js +43 -43
- package/src/phaser/core/event_manager.js +63 -63
- package/src/phaser/core/factory.js +47 -47
- package/src/phaser/core/frame.js +30 -30
- package/src/phaser/core/frame_data.js +30 -28
- package/src/phaser/core/frame_util.js +8 -8
- package/src/phaser/core/game.js +35 -19
- package/src/phaser/core/input_pointer.js +18 -0
- package/src/phaser/core/loader.js +171 -171
- package/src/phaser/core/loader_parser.js +22 -22
- package/src/phaser/core/raf.js +1 -1
- package/src/phaser/core/scale_manager.js +3 -2
- package/src/phaser/core/scene.js +16 -10
- package/src/phaser/core/scene_manager.js +51 -43
- package/src/phaser/core/signal.js +56 -52
- package/src/phaser/core/sound.js +54 -54
- package/src/phaser/core/sound_manager.js +49 -49
- package/src/phaser/core/stage.js +16 -16
- package/src/phaser/core/time.js +54 -30
- package/src/phaser/core/timer.js +82 -64
- package/src/phaser/core/timer_event.js +9 -9
- package/src/phaser/core/tween.js +106 -90
- package/src/phaser/core/tween_data.js +30 -30
- package/src/phaser/core/tween_manager.js +32 -24
- package/src/phaser/core/world.js +4 -3
- package/src/phaser/display/bitmap_text.js +72 -54
- package/src/phaser/display/button.js +48 -47
- package/src/phaser/display/canvas/buffer.js +8 -8
- package/src/phaser/display/canvas/graphics.js +8 -8
- package/src/phaser/display/canvas/masker.js +5 -5
- package/src/phaser/display/canvas/pool.js +18 -18
- package/src/phaser/display/canvas/renderer.js +17 -16
- package/src/phaser/display/canvas/tinter.js +22 -22
- package/src/phaser/display/canvas/util.js +42 -42
- package/src/phaser/display/display_object.js +119 -108
- package/src/phaser/display/graphics.js +129 -112
- package/src/phaser/display/graphics_data.js +10 -10
- package/src/phaser/display/graphics_data_util.js +3 -3
- package/src/phaser/display/group.js +63 -50
- package/src/phaser/display/image.js +68 -50
- package/src/phaser/display/sprite_batch.js +2 -2
- package/src/phaser/display/sprite_util.js +19 -19
- package/src/phaser/display/text.js +217 -187
- package/src/phaser/display/webgl/abstract_filter.js +4 -4
- package/src/phaser/display/webgl/base_texture.js +9 -9
- package/src/phaser/display/webgl/blend_manager.js +7 -7
- package/src/phaser/display/webgl/earcut.js +95 -95
- package/src/phaser/display/webgl/earcut_node.js +4 -4
- package/src/phaser/display/webgl/fast_sprite_batch.js +15 -15
- package/src/phaser/display/webgl/filter_manager.js +9 -9
- package/src/phaser/display/webgl/filter_texture.js +10 -10
- package/src/phaser/display/webgl/graphics.js +37 -37
- package/src/phaser/display/webgl/graphics_data.js +4 -4
- package/src/phaser/display/webgl/mask_manager.js +6 -6
- package/src/phaser/display/webgl/render_texture.js +16 -16
- package/src/phaser/display/webgl/renderer.js +21 -20
- package/src/phaser/display/webgl/shader/complex.js +4 -4
- package/src/phaser/display/webgl/shader/fast.js +4 -4
- package/src/phaser/display/webgl/shader/normal.js +8 -8
- package/src/phaser/display/webgl/shader/primitive.js +4 -4
- package/src/phaser/display/webgl/shader/strip.js +4 -4
- package/src/phaser/display/webgl/shader_manager.js +9 -9
- package/src/phaser/display/webgl/sprite_batch.js +18 -18
- package/src/phaser/display/webgl/stencil_manager.js +16 -16
- package/src/phaser/display/webgl/texture.js +13 -13
- package/src/phaser/display/webgl/texture_util.js +8 -8
- package/src/phaser/display/webgl/util.js +25 -25
- package/src/phaser/geom/circle.js +74 -69
- package/src/phaser/geom/ellipse.js +33 -28
- package/src/phaser/geom/line.js +96 -93
- package/src/phaser/geom/matrix.js +61 -54
- package/src/phaser/geom/point.js +99 -96
- package/src/phaser/geom/polygon.js +27 -22
- package/src/phaser/geom/rectangle.js +137 -132
- package/src/phaser/geom/rounded_rectangle.js +12 -12
- package/src/phaser/geom/util/circle.js +33 -33
- package/src/phaser/geom/util/ellipse.js +5 -5
- package/src/phaser/geom/util/line.js +26 -26
- package/src/phaser/geom/util/matrix.js +8 -8
- package/src/phaser/geom/util/point.js +97 -97
- package/src/phaser/geom/util/polygon.js +4 -4
- package/src/phaser/geom/util/rectangle.js +74 -74
- package/src/phaser/geom/util/rounded_rectangle.js +4 -4
- package/src/phaser/util/math.js +81 -81
- package/types/phaser/core/animation.d.ts +79 -56
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +55 -55
- package/types/phaser/core/animation_parser.d.ts +3 -2
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +51 -44
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +63 -63
- package/types/phaser/core/factory.d.ts +47 -47
- package/types/phaser/core/frame.d.ts +30 -30
- package/types/phaser/core/frame_data.d.ts +28 -27
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +54 -21
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +18 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +175 -172
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +1 -1
- package/types/phaser/core/scale_manager.d.ts +6 -5
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +15 -9
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +51 -43
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +54 -51
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +54 -54
- package/types/phaser/core/sound_manager.d.ts +49 -49
- package/types/phaser/core/stage.d.ts +10 -10
- package/types/phaser/core/time.d.ts +54 -30
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +82 -64
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +106 -90
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +35 -67
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +4 -3
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +76 -53
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +47 -46
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +8 -8
- package/types/phaser/display/canvas/graphics.d.ts +3 -3
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +6 -3
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +18 -17
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts +6 -6
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +119 -108
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +118 -102
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +59 -47
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +58 -45
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +237 -188
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +4 -4
- package/types/phaser/display/webgl/base_texture.d.ts +10 -10
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +6 -6
- package/types/phaser/display/webgl/earcut.d.ts +95 -95
- package/types/phaser/display/webgl/earcut_node.d.ts +4 -4
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +15 -15
- package/types/phaser/display/webgl/filter_manager.d.ts +8 -8
- package/types/phaser/display/webgl/filter_texture.d.ts +10 -10
- package/types/phaser/display/webgl/graphics.d.ts +2 -2
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +21 -20
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +4 -4
- package/types/phaser/display/webgl/shader/fast.d.ts +4 -4
- package/types/phaser/display/webgl/shader/normal.d.ts +8 -8
- package/types/phaser/display/webgl/shader/primitive.d.ts +4 -4
- package/types/phaser/display/webgl/shader/strip.d.ts +4 -4
- package/types/phaser/display/webgl/shader_manager.d.ts +8 -8
- package/types/phaser/display/webgl/sprite_batch.d.ts +17 -17
- package/types/phaser/display/webgl/stencil_manager.d.ts +15 -15
- package/types/phaser/display/webgl/texture.d.ts +12 -12
- package/types/phaser/display/webgl/texture_util.d.ts +4 -2
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +74 -69
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +33 -28
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +96 -93
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +61 -54
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +99 -96
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +29 -23
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +137 -132
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/types/phaser/geom/util/point.d.ts +1 -1
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/pnpm-workspace.yaml +0 -4
|
@@ -4,18 +4,18 @@ import { Device } from './device.js';
|
|
|
4
4
|
const logger = new Logger('device');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {Device} device -
|
|
9
|
-
* @param {string} type -
|
|
10
|
-
* @returns {boolean}
|
|
7
|
+
* Check if the device can play a specific audio format.
|
|
8
|
+
* @param {Device} device - The device instance to check.
|
|
9
|
+
* @param {string} type - The audio format type to check.
|
|
10
|
+
* @returns {boolean} True if the device can play this audio format, false otherwise.
|
|
11
11
|
*/
|
|
12
12
|
export const canPlayAudio = (device, type) => {
|
|
13
13
|
return device.supportedAudioFormats[type] === true;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {Device} device -
|
|
17
|
+
* Detect the operating system of the device.
|
|
18
|
+
* @param {Device} device - The device instance to update.
|
|
19
19
|
*/
|
|
20
20
|
export const checkOS = (device) => {
|
|
21
21
|
const ua = navigator.userAgent;
|
|
@@ -51,8 +51,8 @@ export const checkOS = (device) => {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
* @param {Device} device -
|
|
54
|
+
* Detect input capabilities of the device.
|
|
55
|
+
* @param {Device} device - The device instance to update.
|
|
56
56
|
*/
|
|
57
57
|
export const checkInput = (device) => {
|
|
58
58
|
if (
|
|
@@ -71,8 +71,8 @@ export const checkInput = (device) => {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @param {Device} device -
|
|
74
|
+
* Check for fullscreen support capabilities.
|
|
75
|
+
* @param {Device} device - The device instance to update.
|
|
76
76
|
*/
|
|
77
77
|
export const checkFullScreenSupport = (device) => {
|
|
78
78
|
const fs = [
|
|
@@ -118,8 +118,8 @@ export const checkFullScreenSupport = (device) => {
|
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
*
|
|
122
|
-
* @param {Device} device -
|
|
121
|
+
* Detect the browser type.
|
|
122
|
+
* @param {Device} device - The device instance to update.
|
|
123
123
|
*/
|
|
124
124
|
export const checkBrowser = (device) => {
|
|
125
125
|
const ua = navigator.userAgent;
|
|
@@ -135,10 +135,10 @@ export const checkBrowser = (device) => {
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
|
-
* Check
|
|
139
|
-
* @param {HTMLAudioElement} audioElement -
|
|
140
|
-
* @param {string} type -
|
|
141
|
-
* @returns {boolean}
|
|
138
|
+
* Check if an audio element can play a specific codec.
|
|
139
|
+
* @param {HTMLAudioElement} audioElement - The audio element to test.
|
|
140
|
+
* @param {string} type - The codec type to check.
|
|
141
|
+
* @returns {boolean} True if the codec is supported, false otherwise.
|
|
142
142
|
*/
|
|
143
143
|
export const canPlayType = (audioElement, type) => {
|
|
144
144
|
try {
|
|
@@ -152,9 +152,9 @@ export const canPlayType = (audioElement, type) => {
|
|
|
152
152
|
};
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
|
-
* Check
|
|
156
|
-
* @param {string} type -
|
|
157
|
-
* @returns {boolean}
|
|
155
|
+
* Check if a media source type is supported by the browser.
|
|
156
|
+
* @param {string} type - The media source type to check.
|
|
157
|
+
* @returns {boolean} True if the media source type is supported, false otherwise.
|
|
158
158
|
*/
|
|
159
159
|
export const isMediaSourceTypeSupported = (type) => {
|
|
160
160
|
if ('MediaSource' in window) {
|
|
@@ -170,8 +170,8 @@ export const isMediaSourceTypeSupported = (type) => {
|
|
|
170
170
|
};
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
|
-
*
|
|
174
|
-
* @param {Device} device -
|
|
173
|
+
* Check for supported audio formats on the device.
|
|
174
|
+
* @param {Device} device - The device instance to update with audio format support.
|
|
175
175
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
|
|
176
176
|
* @see https://developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements
|
|
177
177
|
* @see https://bit.ly/iphoneoscodecs
|
|
@@ -205,8 +205,8 @@ export const checkAudio = (device) => {
|
|
|
205
205
|
};
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
|
-
*
|
|
209
|
-
* @param {Device} device -
|
|
208
|
+
* Check for supported image formats on the device.
|
|
209
|
+
* @param {Device} device - The device instance to update with image format support.
|
|
210
210
|
*/
|
|
211
211
|
export const checkImage = (device) => {
|
|
212
212
|
try {
|
|
@@ -233,8 +233,8 @@ export const checkImage = (device) => {
|
|
|
233
233
|
};
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
|
-
*
|
|
237
|
-
* @param {Device} device -
|
|
236
|
+
* Initialize device capabilities detection.
|
|
237
|
+
* @param {Device} device - The device instance to initialize.
|
|
238
238
|
*/
|
|
239
239
|
export const initialize = (device) => {
|
|
240
240
|
logger.info('initialize');
|
|
@@ -247,8 +247,8 @@ export const initialize = (device) => {
|
|
|
247
247
|
};
|
|
248
248
|
|
|
249
249
|
/**
|
|
250
|
-
*
|
|
251
|
-
* @returns {Device}
|
|
250
|
+
* Create a new Device instance.
|
|
251
|
+
* @returns {Device} A new Device instance.
|
|
252
252
|
*/
|
|
253
253
|
export const createDevice = () => {
|
|
254
254
|
return new Device();
|
package/src/phaser/core/dom.js
CHANGED
|
@@ -2,32 +2,32 @@ import { Point } from '../geom/point.js';
|
|
|
2
2
|
|
|
3
3
|
class VisualBoundsDesktopRectangle {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @returns {number}
|
|
5
|
+
* Gets the horizontal scroll position of the window.
|
|
6
|
+
* @returns {number} The horizontal scroll position in pixels.
|
|
7
7
|
*/
|
|
8
8
|
get x() {
|
|
9
9
|
return window && 'pageXOffset' in window ? window.pageXOffset : document.documentElement.scrollLeft;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @returns {number}
|
|
13
|
+
* Gets the vertical scroll position of the window.
|
|
14
|
+
* @returns {number} The vertical scroll position in pixels.
|
|
15
15
|
*/
|
|
16
16
|
get y() {
|
|
17
17
|
return window && 'pageYOffset' in window ? window.pageYOffset : document.documentElement.scrollTop;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @returns {number}
|
|
21
|
+
* Gets the width of the window.
|
|
22
|
+
* @returns {number} The width of the window in pixels.
|
|
23
23
|
*/
|
|
24
24
|
get width() {
|
|
25
25
|
return Math.max(window.innerWidth, document.documentElement.clientWidth);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @returns {number}
|
|
29
|
+
* Gets the height of the window.
|
|
30
|
+
* @returns {number} The height of the window in pixels.
|
|
31
31
|
*/
|
|
32
32
|
get height() {
|
|
33
33
|
return Math.max(window.innerHeight, document.documentElement.clientHeight);
|
|
@@ -36,32 +36,32 @@ class VisualBoundsDesktopRectangle {
|
|
|
36
36
|
|
|
37
37
|
class LayoutBoundsDesktopRectangle {
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @returns {number}
|
|
39
|
+
* Gets the horizontal scroll position of the window.
|
|
40
|
+
* @returns {number} The horizontal scroll position in pixels.
|
|
41
41
|
*/
|
|
42
42
|
get x() {
|
|
43
43
|
return 0;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @returns {number}
|
|
47
|
+
* Gets the vertical scroll position of the window.
|
|
48
|
+
* @returns {number} The vertical scroll position in pixels.
|
|
49
49
|
*/
|
|
50
50
|
get y() {
|
|
51
51
|
return 0;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
56
|
-
* @returns {number}
|
|
55
|
+
* Gets the width of the window.
|
|
56
|
+
* @returns {number} The width of the window in pixels.
|
|
57
57
|
*/
|
|
58
58
|
get width() {
|
|
59
59
|
return Math.max(window.innerWidth, document.documentElement.clientWidth);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
64
|
-
* @returns {number}
|
|
63
|
+
* Gets the height of the window.
|
|
64
|
+
* @returns {number} The height of the window in pixels.
|
|
65
65
|
*/
|
|
66
66
|
get height() {
|
|
67
67
|
return Math.max(window.innerHeight, document.documentElement.clientHeight);
|
|
@@ -70,16 +70,16 @@ class LayoutBoundsDesktopRectangle {
|
|
|
70
70
|
|
|
71
71
|
class VisualBoundsRectangle {
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
74
|
-
* @returns {number}
|
|
73
|
+
* Gets the horizontal scroll position of the document.
|
|
74
|
+
* @returns {number} The horizontal scroll position in pixels.
|
|
75
75
|
*/
|
|
76
76
|
get x() {
|
|
77
77
|
return window && 'pageXOffset' in window ? window.pageXOffset : document.documentElement.scrollLeft;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
82
|
-
* @returns {number}
|
|
81
|
+
* Gets the vertical scroll position of the document.
|
|
82
|
+
* @returns {number} The vertical scroll position in pixels.
|
|
83
83
|
*/
|
|
84
84
|
get y() {
|
|
85
85
|
return window && 'pageYOffset' in window ? window.pageYOffset : document.documentElement.scrollTop;
|
|
@@ -199,10 +199,10 @@ export class DOM {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
|
-
*
|
|
203
|
-
* @param {HTMLCanvasElement} element -
|
|
204
|
-
* @param {Point} point -
|
|
205
|
-
* @returns {Point}
|
|
202
|
+
* Gets the offset position of an element relative to the document.
|
|
203
|
+
* @param {HTMLCanvasElement} element - The element to get the offset for.
|
|
204
|
+
* @param {Point} point - Optional Point object to store the result.
|
|
205
|
+
* @returns {Point} The offset position of the element.
|
|
206
206
|
*/
|
|
207
207
|
getOffset(element, point = null) {
|
|
208
208
|
point = point || new Point();
|
|
@@ -217,10 +217,10 @@ export class DOM {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
/**
|
|
220
|
-
*
|
|
221
|
-
* @param {HTMLCanvasElement} element -
|
|
222
|
-
* @param {number} cushion -
|
|
223
|
-
* @returns {boolean}
|
|
220
|
+
* Gets the bounding rectangle of an element with optional cushion.
|
|
221
|
+
* @param {HTMLCanvasElement} element - The element to get bounds for.
|
|
222
|
+
* @param {number} cushion - Optional padding to add around the element.
|
|
223
|
+
* @returns {boolean} True if bounds were successfully retrieved, false otherwise.
|
|
224
224
|
*/
|
|
225
225
|
getBounds(element, cushion = 0) {
|
|
226
226
|
element = element && !element.nodeType ? element[0] : element;
|
|
@@ -231,10 +231,10 @@ export class DOM {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
/**
|
|
234
|
-
*
|
|
235
|
-
* @param {DOMRect} coords -
|
|
236
|
-
* @param {number} cushion -
|
|
237
|
-
* @returns {
|
|
234
|
+
* Calibrates DOM rectangle coordinates with optional cushion.
|
|
235
|
+
* @param {DOMRect} coords - The DOM rectangle coordinates to calibrate.
|
|
236
|
+
* @param {number} cushion - Optional padding to add around the rectangle.
|
|
237
|
+
* @returns {{width: number, height: number, left: number, right: number, top: number, bottom: number}} The calibrated rectangle.
|
|
238
238
|
*/
|
|
239
239
|
calibrate(coords, cushion = 0) {
|
|
240
240
|
const output = {
|
|
@@ -251,9 +251,9 @@ export class DOM {
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
|
-
*
|
|
255
|
-
* @param {string} primaryFallback -
|
|
256
|
-
* @returns {string}
|
|
254
|
+
* Gets the screen orientation.
|
|
255
|
+
* @param {string} primaryFallback - The fallback method to use if screen orientation API is not available.
|
|
256
|
+
* @returns {string} The screen orientation ('portrait-primary', 'landscape-primary', etc.).
|
|
257
257
|
*/
|
|
258
258
|
getScreenOrientation(primaryFallback) {
|
|
259
259
|
const screen = window.screen;
|
|
@@ -286,32 +286,32 @@ export class DOM {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
/**
|
|
289
|
-
*
|
|
290
|
-
* @returns {number}
|
|
289
|
+
* Gets the horizontal scroll position of the window.
|
|
290
|
+
* @returns {number} The horizontal scroll position in pixels.
|
|
291
291
|
*/
|
|
292
292
|
get scrollX() {
|
|
293
293
|
return this.scrollXProvider();
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
/**
|
|
297
|
-
*
|
|
298
|
-
* @returns {number}
|
|
297
|
+
* Gets the vertical scroll position of the window.
|
|
298
|
+
* @returns {number} The vertical scroll position in pixels.
|
|
299
299
|
*/
|
|
300
300
|
get scrollY() {
|
|
301
301
|
return this.scrollYProvider();
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
/**
|
|
305
|
-
*
|
|
306
|
-
* @returns {number}
|
|
305
|
+
* Gets the width of the window's client area.
|
|
306
|
+
* @returns {number} The width of the client area in pixels.
|
|
307
307
|
*/
|
|
308
308
|
get clientWidth() {
|
|
309
309
|
return Math.max(window.innerWidth, document.documentElement.clientWidth);
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
/**
|
|
313
|
-
*
|
|
314
|
-
* @returns {number}
|
|
313
|
+
* Gets the height of the window's client area.
|
|
314
|
+
* @returns {number} The height of the client area in pixels.
|
|
315
315
|
*/
|
|
316
316
|
get clientHeight() {
|
|
317
317
|
return Math.max(window.innerHeight, document.documentElement.clientHeight);
|
|
@@ -2,8 +2,8 @@ import { Signal } from './signal.js';
|
|
|
2
2
|
|
|
3
3
|
export class EventManager {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {import('../display/display_object.js').DisplayObject} sprite -
|
|
5
|
+
* Creates a new EventManager instance.
|
|
6
|
+
* @param {import('../display/display_object.js').DisplayObject} sprite - Reference to the parent DisplayObject.
|
|
7
7
|
*/
|
|
8
8
|
constructor(sprite) {
|
|
9
9
|
this.parent = sprite;
|
|
@@ -25,7 +25,7 @@ export class EventManager {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Destroys the EventManager and cleans up resources.
|
|
29
29
|
*/
|
|
30
30
|
destroy() {
|
|
31
31
|
this._parent = null;
|
|
@@ -77,8 +77,8 @@ export class EventManager {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
* @returns {Signal}
|
|
80
|
+
* Gets the onAddedToGroup signal.
|
|
81
|
+
* @returns {Signal} The Signal object for the onAddedToGroup event.
|
|
82
82
|
*/
|
|
83
83
|
get onAddedToGroup() {
|
|
84
84
|
if (!this._onAddedToGroup) {
|
|
@@ -88,8 +88,8 @@ export class EventManager {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
* @param {...any} args -
|
|
91
|
+
* Dispatches the onAddedToGroup event.
|
|
92
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
93
93
|
*/
|
|
94
94
|
onAddedToGroup$dispatch(...args) {
|
|
95
95
|
if (this._onAddedToGroup) {
|
|
@@ -98,8 +98,8 @@ export class EventManager {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
102
|
-
* @returns {Signal}
|
|
101
|
+
* Gets the onRemovedFromGroup signal.
|
|
102
|
+
* @returns {Signal} The Signal object for the onRemovedFromGroup event.
|
|
103
103
|
*/
|
|
104
104
|
get onRemovedFromGroup() {
|
|
105
105
|
if (!this._onRemovedFromGroup) {
|
|
@@ -109,8 +109,8 @@ export class EventManager {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
*
|
|
113
|
-
* @param {...any} args -
|
|
112
|
+
* Dispatches the onRemovedFromGroup event.
|
|
113
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
114
114
|
*/
|
|
115
115
|
onRemovedFromGroup$dispatch(...args) {
|
|
116
116
|
if (this._onRemovedFromGroup) {
|
|
@@ -119,8 +119,8 @@ export class EventManager {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
*
|
|
123
|
-
* @returns {Signal}
|
|
122
|
+
* Gets the onDestroy signal.
|
|
123
|
+
* @returns {Signal} The Signal object for the onDestroy event.
|
|
124
124
|
*/
|
|
125
125
|
get onDestroy() {
|
|
126
126
|
if (!this._onDestroy) {
|
|
@@ -130,8 +130,8 @@ export class EventManager {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
134
|
-
* @param {...any} args -
|
|
133
|
+
* Dispatches the onDestroy event.
|
|
134
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
135
135
|
*/
|
|
136
136
|
onDestroy$dispatch(...args) {
|
|
137
137
|
if (this._onDestroy) {
|
|
@@ -140,8 +140,8 @@ export class EventManager {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
144
|
-
* @returns {Signal}
|
|
143
|
+
* Gets the onOutOfBounds signal.
|
|
144
|
+
* @returns {Signal} The Signal object for the onOutOfBounds event.
|
|
145
145
|
*/
|
|
146
146
|
get onOutOfBounds() {
|
|
147
147
|
if (!this._onOutOfBounds) {
|
|
@@ -151,8 +151,8 @@ export class EventManager {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
-
*
|
|
155
|
-
* @param {...any} args -
|
|
154
|
+
* Dispatches the onOutOfBounds event.
|
|
155
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
156
156
|
*/
|
|
157
157
|
onOutOfBounds$dispatch(...args) {
|
|
158
158
|
if (this._onOutOfBounds) {
|
|
@@ -161,8 +161,8 @@ export class EventManager {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
-
*
|
|
165
|
-
* @returns {Signal}
|
|
164
|
+
* Gets the onEnterBounds signal.
|
|
165
|
+
* @returns {Signal} The Signal object for the onEnterBounds event.
|
|
166
166
|
*/
|
|
167
167
|
get onEnterBounds() {
|
|
168
168
|
if (!this._onEnterBounds) {
|
|
@@ -172,8 +172,8 @@ export class EventManager {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
|
-
*
|
|
176
|
-
* @param {...any} args -
|
|
175
|
+
* Dispatches the onEnterBounds event.
|
|
176
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
177
177
|
*/
|
|
178
178
|
onEnterBounds$dispatch(...args) {
|
|
179
179
|
if (this._onEnterBounds) {
|
|
@@ -182,8 +182,8 @@ export class EventManager {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
|
-
*
|
|
186
|
-
* @returns {Signal}
|
|
185
|
+
* Gets the onInputOver signal.
|
|
186
|
+
* @returns {Signal} The Signal object for the onInputOver event.
|
|
187
187
|
*/
|
|
188
188
|
get onInputOver() {
|
|
189
189
|
if (!this._onInputOver) {
|
|
@@ -193,8 +193,8 @@ export class EventManager {
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
|
-
*
|
|
197
|
-
* @param {...any} args -
|
|
196
|
+
* Dispatches the onInputOver event.
|
|
197
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
198
198
|
*/
|
|
199
199
|
onInputOver$dispatch(...args) {
|
|
200
200
|
if (this._onInputOver) {
|
|
@@ -203,8 +203,8 @@ export class EventManager {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
|
-
*
|
|
207
|
-
* @returns {Signal}
|
|
206
|
+
* Gets the onInputOut signal.
|
|
207
|
+
* @returns {Signal} The Signal object for the onInputOut event.
|
|
208
208
|
*/
|
|
209
209
|
get onInputOut() {
|
|
210
210
|
if (!this._onInputOut) {
|
|
@@ -214,8 +214,8 @@ export class EventManager {
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
|
-
*
|
|
218
|
-
* @param {...any} args -
|
|
217
|
+
* Dispatches the onInputOut event.
|
|
218
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
219
219
|
*/
|
|
220
220
|
onInputOut$dispatch(...args) {
|
|
221
221
|
if (this._onInputOut) {
|
|
@@ -224,8 +224,8 @@ export class EventManager {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
/**
|
|
227
|
-
*
|
|
228
|
-
* @returns {Signal}
|
|
227
|
+
* Gets the onInputDown signal.
|
|
228
|
+
* @returns {Signal} The Signal object for the onInputDown event.
|
|
229
229
|
*/
|
|
230
230
|
get onInputDown() {
|
|
231
231
|
if (!this._onInputDown) {
|
|
@@ -235,8 +235,8 @@ export class EventManager {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
/**
|
|
238
|
-
*
|
|
239
|
-
* @param {...any} args -
|
|
238
|
+
* Dispatches the onInputDown event.
|
|
239
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
240
240
|
*/
|
|
241
241
|
onInputDown$dispatch(...args) {
|
|
242
242
|
if (this._onInputDown) {
|
|
@@ -245,8 +245,8 @@ export class EventManager {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
/**
|
|
248
|
-
*
|
|
249
|
-
* @returns {Signal}
|
|
248
|
+
* Gets the onInputUp signal.
|
|
249
|
+
* @returns {Signal} The Signal object for the onInputUp event.
|
|
250
250
|
*/
|
|
251
251
|
get onInputUp() {
|
|
252
252
|
if (!this._onInputUp) {
|
|
@@ -256,8 +256,8 @@ export class EventManager {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
/**
|
|
259
|
-
*
|
|
260
|
-
* @param {...any} args -
|
|
259
|
+
* Dispatches the onInputUp event.
|
|
260
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
261
261
|
*/
|
|
262
262
|
onInputUp$dispatch(...args) {
|
|
263
263
|
if (this._onInputUp) {
|
|
@@ -266,8 +266,8 @@ export class EventManager {
|
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
|
-
*
|
|
270
|
-
* @returns {Signal}
|
|
269
|
+
* Gets the onDragStart signal.
|
|
270
|
+
* @returns {Signal} The Signal object for the onDragStart event.
|
|
271
271
|
*/
|
|
272
272
|
get onDragStart() {
|
|
273
273
|
if (!this._onDragStart) {
|
|
@@ -277,8 +277,8 @@ export class EventManager {
|
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
/**
|
|
280
|
-
*
|
|
281
|
-
* @param {...any} args -
|
|
280
|
+
* Dispatches the onDragStart event.
|
|
281
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
282
282
|
*/
|
|
283
283
|
onDragStart$dispatch(...args) {
|
|
284
284
|
if (this._onDragStart) {
|
|
@@ -287,8 +287,8 @@ export class EventManager {
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
|
-
*
|
|
291
|
-
* @returns {Signal}
|
|
290
|
+
* Gets the onDragUpdate signal.
|
|
291
|
+
* @returns {Signal} The Signal object for the onDragUpdate event.
|
|
292
292
|
*/
|
|
293
293
|
get onDragUpdate() {
|
|
294
294
|
if (!this._onDragUpdate) {
|
|
@@ -298,8 +298,8 @@ export class EventManager {
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
/**
|
|
301
|
-
*
|
|
302
|
-
* @param {...any} args -
|
|
301
|
+
* Dispatches the onDragUpdate event.
|
|
302
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
303
303
|
*/
|
|
304
304
|
onDragUpdate$dispatch(...args) {
|
|
305
305
|
if (this._onDragUpdate) {
|
|
@@ -308,8 +308,8 @@ export class EventManager {
|
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
/**
|
|
311
|
-
*
|
|
312
|
-
* @returns {Signal}
|
|
311
|
+
* Gets the onDragStop signal.
|
|
312
|
+
* @returns {Signal} The Signal object for the onDragStop event.
|
|
313
313
|
*/
|
|
314
314
|
get onDragStop() {
|
|
315
315
|
if (!this._onDragStop) {
|
|
@@ -319,8 +319,8 @@ export class EventManager {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
/**
|
|
322
|
-
*
|
|
323
|
-
* @param {...any} args -
|
|
322
|
+
* Dispatches the onDragStop event.
|
|
323
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
324
324
|
*/
|
|
325
325
|
onDragStop$dispatch(...args) {
|
|
326
326
|
if (this._onDragStop) {
|
|
@@ -329,8 +329,8 @@ export class EventManager {
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
/**
|
|
332
|
-
*
|
|
333
|
-
* @returns {Signal}
|
|
332
|
+
* Gets the onAnimationStart signal.
|
|
333
|
+
* @returns {Signal} The Signal object for the onAnimationStart event.
|
|
334
334
|
*/
|
|
335
335
|
get onAnimationStart() {
|
|
336
336
|
if (!this._onAnimationStart) {
|
|
@@ -340,8 +340,8 @@ export class EventManager {
|
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
/**
|
|
343
|
-
*
|
|
344
|
-
* @param {...any} args -
|
|
343
|
+
* Dispatches the onAnimationStart event.
|
|
344
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
345
345
|
*/
|
|
346
346
|
onAnimationStart$dispatch(...args) {
|
|
347
347
|
if (this._onAnimationStart) {
|
|
@@ -350,8 +350,8 @@ export class EventManager {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
/**
|
|
353
|
-
*
|
|
354
|
-
* @returns {Signal}
|
|
353
|
+
* Gets the onAnimationComplete signal.
|
|
354
|
+
* @returns {Signal} The Signal object for the onAnimationComplete event.
|
|
355
355
|
*/
|
|
356
356
|
get onAnimationComplete() {
|
|
357
357
|
if (!this._onAnimationComplete) {
|
|
@@ -361,8 +361,8 @@ export class EventManager {
|
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
/**
|
|
364
|
-
*
|
|
365
|
-
* @param {...any} args -
|
|
364
|
+
* Dispatches the onAnimationComplete event.
|
|
365
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
366
366
|
*/
|
|
367
367
|
onAnimationComplete$dispatch(...args) {
|
|
368
368
|
if (this._onAnimationComplete) {
|
|
@@ -371,8 +371,8 @@ export class EventManager {
|
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
/**
|
|
374
|
-
*
|
|
375
|
-
* @returns {Signal}
|
|
374
|
+
* Gets the onAnimationLoop signal.
|
|
375
|
+
* @returns {Signal} The Signal object for the onAnimationLoop event.
|
|
376
376
|
*/
|
|
377
377
|
get onAnimationLoop() {
|
|
378
378
|
if (!this._onAnimationLoop) {
|
|
@@ -382,8 +382,8 @@ export class EventManager {
|
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
/**
|
|
385
|
-
*
|
|
386
|
-
* @param {...any} args -
|
|
385
|
+
* Dispatches the onAnimationLoop event.
|
|
386
|
+
* @param {...any} args - Arguments to pass to the signal.
|
|
387
387
|
*/
|
|
388
388
|
onAnimationLoop$dispatch(...args) {
|
|
389
389
|
if (this._onAnimationLoop) {
|