@vpmedia/phaser 1.112.0 → 1.114.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/dist/index.js +1261 -1314
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +14 -10
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +10 -8
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +5 -4
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +4 -3
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/const.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +3 -2
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +1 -1
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +8 -6
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +40 -30
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +3 -2
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +3 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +6 -4
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +3 -2
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +4 -3
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +9 -8
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +3 -2
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/registry.d.ts +7 -0
- package/dist/phaser/core/registry.d.ts.map +1 -0
- package/dist/phaser/core/scale_manager.d.ts +1 -1
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +0 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +1 -1
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +0 -1
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +4 -3
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +6 -4
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +3 -2
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +5 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +3 -2
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +1 -1
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +1 -1
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +10 -7
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +3 -2
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +3 -2
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts +3 -2
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +3 -2
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +3 -2
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts +7 -6
- package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts +2 -2
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +10 -8
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +3 -2
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts +2 -2
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +14 -12
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +8 -5
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +4 -3
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +13 -10
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_batch.d.ts +3 -2
- package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +18 -15
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +12 -10
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +7 -6
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +16 -11
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +3 -2
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts +4 -1
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +1 -1
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts +3 -2
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts +2 -2
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/phaser/core/animation.ts +64 -60
- package/src/phaser/core/animation_manager.ts +50 -53
- package/src/phaser/core/animation_parser.ts +9 -9
- package/src/phaser/core/array_set.ts +16 -17
- package/src/phaser/core/cache.ts +92 -93
- package/src/phaser/core/const.ts +1 -1
- package/src/phaser/core/device.ts +24 -29
- package/src/phaser/core/device_util.ts +22 -26
- package/src/phaser/core/dom.ts +54 -65
- package/src/phaser/core/event_manager.ts +64 -94
- package/src/phaser/core/factory.ts +14 -14
- package/src/phaser/core/frame.ts +28 -28
- package/src/phaser/core/frame_data.test.ts +100 -0
- package/src/phaser/core/frame_data.ts +24 -24
- package/src/phaser/core/frame_util.ts +2 -2
- package/src/phaser/core/game.ts +47 -48
- package/src/phaser/core/input.ts +104 -110
- package/src/phaser/core/input_handler.test.ts +113 -0
- package/src/phaser/core/input_handler.ts +199 -218
- package/src/phaser/core/input_mouse.ts +71 -54
- package/src/phaser/core/input_mspointer.ts +52 -39
- package/src/phaser/core/input_pointer.ts +81 -80
- package/src/phaser/core/input_touch.ts +49 -36
- package/src/phaser/core/loader.ts +173 -152
- package/src/phaser/core/loader_parser.ts +39 -57
- package/src/phaser/core/raf.ts +8 -7
- package/src/phaser/core/registry.test.ts +31 -0
- package/src/phaser/core/registry.ts +9 -0
- package/src/phaser/core/scale_manager.ts +156 -152
- package/src/phaser/core/scene.ts +9 -13
- package/src/phaser/core/scene_manager.ts +47 -47
- package/src/phaser/core/signal.test.ts +4 -4
- package/src/phaser/core/signal.ts +41 -52
- package/src/phaser/core/signal_binding.ts +26 -25
- package/src/phaser/core/signal_dispatch.test.ts +180 -0
- package/src/phaser/core/sound.ts +75 -83
- package/src/phaser/core/sound_manager.ts +52 -51
- package/src/phaser/core/sound_sprite.ts +17 -16
- package/src/phaser/core/stage.ts +25 -24
- package/src/phaser/core/time.ts +52 -52
- package/src/phaser/core/timer.test.ts +187 -0
- package/src/phaser/core/timer.ts +82 -69
- package/src/phaser/core/timer_event.ts +10 -10
- package/src/phaser/core/tween.ts +90 -93
- package/src/phaser/core/tween_data.ts +45 -51
- package/src/phaser/core/tween_easing.test.ts +106 -0
- package/src/phaser/core/tween_easing.ts +151 -123
- package/src/phaser/core/tween_manager.ts +19 -18
- package/src/phaser/core/world.ts +4 -3
- package/src/phaser/display/bitmap_text.ts +56 -64
- package/src/phaser/display/button.ts +33 -32
- package/src/phaser/display/canvas/buffer.ts +8 -8
- package/src/phaser/display/canvas/graphics.ts +36 -37
- package/src/phaser/display/canvas/masker.ts +2 -2
- package/src/phaser/display/canvas/pool.test.ts +106 -0
- package/src/phaser/display/canvas/pool.ts +25 -27
- package/src/phaser/display/canvas/renderer.ts +32 -31
- package/src/phaser/display/canvas/tinter.ts +25 -25
- package/src/phaser/display/canvas/util.ts +7 -10
- package/src/phaser/display/display_object.ts +114 -118
- package/src/phaser/display/graphics.ts +121 -119
- package/src/phaser/display/graphics_data.ts +12 -12
- package/src/phaser/display/graphics_data_util.ts +2 -3
- package/src/phaser/display/group.ts +50 -57
- package/src/phaser/display/image.ts +55 -52
- package/src/phaser/display/sprite_batch.ts +3 -2
- package/src/phaser/display/sprite_util.ts +48 -54
- package/src/phaser/display/text.test.ts +110 -0
- package/src/phaser/display/text.ts +199 -204
- package/src/phaser/display/webgl/abstract_filter.ts +9 -9
- package/src/phaser/display/webgl/base_texture.ts +21 -24
- package/src/phaser/display/webgl/blend_manager.ts +6 -10
- package/src/phaser/display/webgl/earcut.ts +73 -37
- package/src/phaser/display/webgl/earcut_node.ts +10 -10
- package/src/phaser/display/webgl/fast_sprite_batch.ts +34 -34
- package/src/phaser/display/webgl/filter_manager.ts +13 -12
- package/src/phaser/display/webgl/filter_texture.ts +14 -13
- package/src/phaser/display/webgl/graphics.ts +51 -57
- package/src/phaser/display/webgl/graphics_data.ts +15 -14
- package/src/phaser/display/webgl/mask_manager.ts +2 -2
- package/src/phaser/display/webgl/render_texture.ts +26 -25
- package/src/phaser/display/webgl/renderer.ts +57 -62
- package/src/phaser/display/webgl/shader/complex.ts +28 -12
- package/src/phaser/display/webgl/shader/fast.ts +30 -12
- package/src/phaser/display/webgl/shader/normal.ts +70 -57
- package/src/phaser/display/webgl/shader/primitive.ts +26 -11
- package/src/phaser/display/webgl/shader/shader.test.ts +148 -0
- package/src/phaser/display/webgl/shader/strip.ts +27 -12
- package/src/phaser/display/webgl/shader_manager.test.ts +124 -0
- package/src/phaser/display/webgl/shader_manager.ts +26 -34
- package/src/phaser/display/webgl/sprite_batch.ts +67 -61
- package/src/phaser/display/webgl/stencil_manager.ts +23 -34
- package/src/phaser/display/webgl/texture.ts +43 -50
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +26 -25
- package/src/phaser/geom/circle.test.ts +2 -3
- package/src/phaser/geom/circle.ts +36 -36
- package/src/phaser/geom/ellipse.test.ts +73 -71
- package/src/phaser/geom/ellipse.ts +14 -14
- package/src/phaser/geom/line.test.ts +5 -5
- package/src/phaser/geom/line.ts +35 -35
- package/src/phaser/geom/matrix.test.ts +1 -1
- package/src/phaser/geom/matrix.ts +27 -27
- package/src/phaser/geom/point.test.ts +1 -2
- package/src/phaser/geom/point.ts +35 -35
- package/src/phaser/geom/polygon.test.ts +82 -0
- package/src/phaser/geom/polygon.ts +16 -16
- package/src/phaser/geom/rectangle.test.ts +14 -14
- package/src/phaser/geom/rectangle.ts +83 -75
- package/src/phaser/geom/rounded_rectangle.test.ts +1 -7
- package/src/phaser/geom/rounded_rectangle.ts +9 -9
- package/src/phaser/geom/util/circle.test.ts +25 -23
- package/src/phaser/geom/util/circle.ts +9 -18
- package/src/phaser/geom/util/ellipse.test.ts +7 -5
- package/src/phaser/geom/util/ellipse.ts +3 -2
- package/src/phaser/geom/util/line.test.ts +10 -8
- package/src/phaser/geom/util/line.ts +6 -16
- package/src/phaser/geom/util/matrix.test.ts +20 -18
- package/src/phaser/geom/util/matrix.ts +8 -15
- package/src/phaser/geom/util/point.test.ts +8 -6
- package/src/phaser/geom/util/point.ts +24 -28
- package/src/phaser/geom/util/polygon.test.ts +12 -10
- package/src/phaser/geom/util/polygon.ts +2 -2
- package/src/phaser/geom/util/rectangle.test.ts +10 -8
- package/src/phaser/geom/util/rectangle.ts +18 -37
- package/src/phaser/geom/util/rounded_rectangle.test.ts +11 -9
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
- package/src/phaser/util/math.test.ts +11 -11
- package/src/phaser/util/math.ts +29 -46
package/src/phaser/core/tween.ts
CHANGED
|
@@ -2,45 +2,44 @@ import * as MathUtils from '../util/math.js';
|
|
|
2
2
|
import { TWEEN_COMPLETE, TWEEN_LOOPED, TWEEN_PENDING, TWEEN_RUNNING } from './const.js';
|
|
3
3
|
import { Signal } from './signal.js';
|
|
4
4
|
import { TweenData } from './tween_data.js';
|
|
5
|
+
import type { Game } from './game.js';
|
|
6
|
+
import type { DisplayObject } from '../display/display_object.js';
|
|
7
|
+
import type { TweenManager } from './tween_manager.js';
|
|
5
8
|
|
|
6
9
|
export class Tween {
|
|
7
|
-
game!:
|
|
8
|
-
target!:
|
|
9
|
-
manager!:
|
|
10
|
-
timeline!: TweenData[];
|
|
11
|
-
reverse!: boolean;
|
|
12
|
-
timeScale!: number;
|
|
13
|
-
repeatCounter!: number;
|
|
14
|
-
pendingDelete!: boolean;
|
|
15
|
-
onStart!: Signal;
|
|
16
|
-
onLoop!: Signal;
|
|
17
|
-
onRepeat!: Signal;
|
|
18
|
-
onChildComplete!: Signal;
|
|
19
|
-
onComplete!: Signal;
|
|
20
|
-
isRunning!: boolean;
|
|
21
|
-
current!: number;
|
|
22
|
-
properties!: any;
|
|
23
|
-
chainedTween!: Tween | null;
|
|
24
|
-
isPaused!: boolean;
|
|
25
|
-
_onUpdateCallback!: Function | null;
|
|
26
|
-
_onUpdateCallbackContext!: object | null;
|
|
27
|
-
_pausedTime!: number;
|
|
28
|
-
_codePaused!: boolean;
|
|
29
|
-
_hasStarted!: boolean;
|
|
10
|
+
public game!: Game;
|
|
11
|
+
public target!: DisplayObject;
|
|
12
|
+
public manager!: TweenManager;
|
|
13
|
+
public timeline!: TweenData[];
|
|
14
|
+
public reverse!: boolean;
|
|
15
|
+
public timeScale!: number;
|
|
16
|
+
public repeatCounter!: number;
|
|
17
|
+
public pendingDelete!: boolean;
|
|
18
|
+
public onStart!: Signal;
|
|
19
|
+
public onLoop!: Signal;
|
|
20
|
+
public onRepeat!: Signal;
|
|
21
|
+
public onChildComplete!: Signal;
|
|
22
|
+
public onComplete!: Signal;
|
|
23
|
+
public isRunning!: boolean;
|
|
24
|
+
public current!: number;
|
|
25
|
+
public properties!: any;
|
|
26
|
+
public chainedTween!: Tween | null;
|
|
27
|
+
public isPaused!: boolean;
|
|
28
|
+
public _onUpdateCallback!: Function | null;
|
|
29
|
+
public _onUpdateCallbackContext!: object | null;
|
|
30
|
+
public _pausedTime!: number;
|
|
31
|
+
public _codePaused!: boolean;
|
|
32
|
+
public _hasStarted!: boolean;
|
|
30
33
|
/**
|
|
31
34
|
* Creates a new Tween instance.
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {
|
|
35
|
+
* @param {DisplayObject} target - The object to tween.
|
|
36
|
+
* @param {Game} game - Reference to the Phaser Game instance.
|
|
37
|
+
* @param {TweenManager} manager - Reference to the Tween Manager.
|
|
35
38
|
*/
|
|
36
|
-
constructor(
|
|
37
|
-
target: import('../display/display_object.js').DisplayObject,
|
|
38
|
-
game: import('./game.js').Game,
|
|
39
|
-
manager: import('./tween_manager.js').TweenManager
|
|
40
|
-
) {
|
|
39
|
+
public constructor(target: DisplayObject, game: Game, manager: TweenManager) {
|
|
41
40
|
this.game = game;
|
|
42
41
|
this.target = target;
|
|
43
|
-
/** @type {
|
|
42
|
+
/** @type {TweenManager} */
|
|
44
43
|
this.manager = manager;
|
|
45
44
|
/** @type {TweenData[]} */
|
|
46
45
|
this.timeline = [];
|
|
@@ -91,14 +90,14 @@ export class Tween {
|
|
|
91
90
|
* @param {boolean} yoyo - Whether to reverse the tween on repeat.
|
|
92
91
|
* @returns {Tween} This Tween object for chaining.
|
|
93
92
|
*/
|
|
94
|
-
to(
|
|
93
|
+
public to(
|
|
95
94
|
properties: any,
|
|
96
|
-
duration
|
|
95
|
+
duration = 1000,
|
|
97
96
|
ease: string | Function = 'Linear',
|
|
98
|
-
autoStart
|
|
99
|
-
delay
|
|
100
|
-
repeat
|
|
101
|
-
yoyo
|
|
97
|
+
autoStart = false,
|
|
98
|
+
delay = 0,
|
|
99
|
+
repeat = 0,
|
|
100
|
+
yoyo = false
|
|
102
101
|
) {
|
|
103
102
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
104
103
|
ease = this.manager.easeMap[ease];
|
|
@@ -124,14 +123,14 @@ export class Tween {
|
|
|
124
123
|
* @param {boolean} yoyo - Whether to reverse the tween on repeat.
|
|
125
124
|
* @returns {Tween} This Tween object for chaining.
|
|
126
125
|
*/
|
|
127
|
-
from(
|
|
126
|
+
public from(
|
|
128
127
|
properties: any,
|
|
129
|
-
duration
|
|
128
|
+
duration = 1000,
|
|
130
129
|
ease: string | Function = 'Linear',
|
|
131
|
-
autoStart
|
|
132
|
-
delay
|
|
133
|
-
repeat
|
|
134
|
-
yoyo
|
|
130
|
+
autoStart = false,
|
|
131
|
+
delay = 0,
|
|
132
|
+
repeat = 0,
|
|
133
|
+
yoyo = false
|
|
135
134
|
) {
|
|
136
135
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
137
136
|
ease = this.manager.easeMap[ease];
|
|
@@ -152,26 +151,25 @@ export class Tween {
|
|
|
152
151
|
* @param {number} index - The index to start from in the timeline.
|
|
153
152
|
* @returns {Tween} This Tween object for chaining.
|
|
154
153
|
*/
|
|
155
|
-
start(index
|
|
154
|
+
public start(index = 0) {
|
|
156
155
|
if (this.game === null || this.target === null || this.timeline.length === 0 || this.isRunning) {
|
|
157
156
|
return this;
|
|
158
157
|
}
|
|
159
158
|
// Populate the tween data
|
|
160
|
-
for (
|
|
159
|
+
for (const tweenData of this.timeline) {
|
|
161
160
|
// Build our master property list with the starting values
|
|
162
|
-
const keys = Object.keys(
|
|
163
|
-
for (
|
|
164
|
-
const property = keys[k];
|
|
161
|
+
const keys = Object.keys(tweenData.vEnd);
|
|
162
|
+
for (const property of keys) {
|
|
165
163
|
const targetProperties = this.target as unknown as Record<string, number>;
|
|
166
|
-
this.properties[property] = targetProperties[property]
|
|
164
|
+
this.properties[property] = targetProperties[property] ?? 0;
|
|
167
165
|
if (!Array.isArray(this.properties[property])) {
|
|
168
166
|
// Ensures we're using numbers, not strings
|
|
169
167
|
this.properties[property] *= 1;
|
|
170
168
|
}
|
|
171
169
|
}
|
|
172
170
|
}
|
|
173
|
-
for (
|
|
174
|
-
|
|
171
|
+
for (const tweenData of this.timeline) {
|
|
172
|
+
tweenData.loadValues();
|
|
175
173
|
}
|
|
176
174
|
this.manager.add(this);
|
|
177
175
|
this.isRunning = true;
|
|
@@ -179,7 +177,7 @@ export class Tween {
|
|
|
179
177
|
index = 0;
|
|
180
178
|
}
|
|
181
179
|
this.current = index;
|
|
182
|
-
this.timeline[this.current]
|
|
180
|
+
this.timeline[this.current]!.start();
|
|
183
181
|
return this;
|
|
184
182
|
}
|
|
185
183
|
|
|
@@ -188,7 +186,7 @@ export class Tween {
|
|
|
188
186
|
* @param {boolean} complete - Whether to dispatch the complete event.
|
|
189
187
|
* @returns {Tween} This Tween object for chaining.
|
|
190
188
|
*/
|
|
191
|
-
stop(complete
|
|
189
|
+
public stop(complete = false) {
|
|
192
190
|
this.isRunning = false;
|
|
193
191
|
this._onUpdateCallback = null;
|
|
194
192
|
this._onUpdateCallbackContext = null;
|
|
@@ -210,7 +208,7 @@ export class Tween {
|
|
|
210
208
|
* @param {number} index - The index in the timeline to update.
|
|
211
209
|
* @returns {Tween} This Tween object for chaining.
|
|
212
210
|
*/
|
|
213
|
-
updateTweenData(property: string, value: any, index
|
|
211
|
+
public updateTweenData(property: string, value: any, index = 0) {
|
|
214
212
|
if (this.timeline.length === 0) {
|
|
215
213
|
return this;
|
|
216
214
|
}
|
|
@@ -230,7 +228,7 @@ export class Tween {
|
|
|
230
228
|
* @param {number} index - The index in the timeline to apply the delay to.
|
|
231
229
|
* @returns {Tween} This Tween object for chaining.
|
|
232
230
|
*/
|
|
233
|
-
delay(duration: number, index: number) {
|
|
231
|
+
public delay(duration: number, index: number) {
|
|
234
232
|
return this.updateTweenData('delay', duration, index);
|
|
235
233
|
}
|
|
236
234
|
|
|
@@ -241,7 +239,7 @@ export class Tween {
|
|
|
241
239
|
* @param {number} index - The index in the timeline to apply the repeat to.
|
|
242
240
|
* @returns {Tween} This Tween object for chaining.
|
|
243
241
|
*/
|
|
244
|
-
repeat(total: number, repeatDelay
|
|
242
|
+
public repeat(total: number, repeatDelay = 0, index = 0) {
|
|
245
243
|
this.updateTweenData('repeatCounter', total, index);
|
|
246
244
|
return this.updateTweenData('repeatDelay', repeatDelay, index);
|
|
247
245
|
}
|
|
@@ -252,7 +250,7 @@ export class Tween {
|
|
|
252
250
|
* @param {number} index - The index in the timeline to apply the delay to.
|
|
253
251
|
* @returns {Tween} This Tween object for chaining.
|
|
254
252
|
*/
|
|
255
|
-
repeatDelay(duration: number, index: number) {
|
|
253
|
+
public repeatDelay(duration: number, index: number) {
|
|
256
254
|
return this.updateTweenData('repeatDelay', duration, index);
|
|
257
255
|
}
|
|
258
256
|
|
|
@@ -263,7 +261,7 @@ export class Tween {
|
|
|
263
261
|
* @param {number} index - The index in the timeline to apply yoyo to.
|
|
264
262
|
* @returns {Tween} This Tween object for chaining.
|
|
265
263
|
*/
|
|
266
|
-
yoyo(enable: boolean, yoyoDelay
|
|
264
|
+
public yoyo(enable: boolean, yoyoDelay = 0, index = 0) {
|
|
267
265
|
this.updateTweenData('yoyo', enable, index);
|
|
268
266
|
return this.updateTweenData('yoyoDelay', yoyoDelay, index);
|
|
269
267
|
}
|
|
@@ -274,7 +272,7 @@ export class Tween {
|
|
|
274
272
|
* @param {number} index - The index in the timeline to apply the delay to.
|
|
275
273
|
* @returns {Tween} This Tween object for chaining.
|
|
276
274
|
*/
|
|
277
|
-
yoyoDelay(duration: number, index: number) {
|
|
275
|
+
public yoyoDelay(duration: number, index: number) {
|
|
278
276
|
return this.updateTweenData('yoyoDelay', duration, index);
|
|
279
277
|
}
|
|
280
278
|
|
|
@@ -284,7 +282,7 @@ export class Tween {
|
|
|
284
282
|
* @param {number} index - The index in the timeline to apply easing to.
|
|
285
283
|
* @returns {Tween} This Tween object for chaining.
|
|
286
284
|
*/
|
|
287
|
-
easing(ease: string | Function, index: number) {
|
|
285
|
+
public easing(ease: string | Function, index: number) {
|
|
288
286
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
289
287
|
ease = this.manager.easeMap[ease];
|
|
290
288
|
}
|
|
@@ -298,7 +296,7 @@ export class Tween {
|
|
|
298
296
|
* @param {number} index - The index in the timeline to apply interpolation to.
|
|
299
297
|
* @returns {Tween} This Tween object for chaining.
|
|
300
298
|
*/
|
|
301
|
-
interpolation(interpolation: Function, context: any = MathUtils, index
|
|
299
|
+
public interpolation(interpolation: Function, context: any = MathUtils, index = 0) {
|
|
302
300
|
this.updateTweenData('interpolationFunction', interpolation, index);
|
|
303
301
|
return this.updateTweenData('interpolationContext', context, index);
|
|
304
302
|
}
|
|
@@ -308,7 +306,7 @@ export class Tween {
|
|
|
308
306
|
* @param {number} total - The number of times to repeat (-1 for infinite).
|
|
309
307
|
* @returns {Tween} This Tween object for chaining.
|
|
310
308
|
*/
|
|
311
|
-
repeatAll(total
|
|
309
|
+
public repeatAll(total = 0) {
|
|
312
310
|
this.repeatCounter = total;
|
|
313
311
|
return this;
|
|
314
312
|
}
|
|
@@ -318,7 +316,7 @@ export class Tween {
|
|
|
318
316
|
* @param {...any} args - The tweens to chain.
|
|
319
317
|
* @returns {Tween} This Tween object for chaining.
|
|
320
318
|
*/
|
|
321
|
-
chain(...args: any[]) {
|
|
319
|
+
public chain(...args: any[]) {
|
|
322
320
|
let i = args.length;
|
|
323
321
|
while (i) {
|
|
324
322
|
i -= 1;
|
|
@@ -336,7 +334,7 @@ export class Tween {
|
|
|
336
334
|
* @param {boolean} value - Whether to loop infinitely.
|
|
337
335
|
* @returns {Tween} This Tween object for chaining.
|
|
338
336
|
*/
|
|
339
|
-
loop(value
|
|
337
|
+
public loop(value = true) {
|
|
340
338
|
this.repeatCounter = value ? -1 : 0;
|
|
341
339
|
return this;
|
|
342
340
|
}
|
|
@@ -347,7 +345,7 @@ export class Tween {
|
|
|
347
345
|
* @param {object} callbackContext - The context in which to call the callback.
|
|
348
346
|
* @returns {Tween} This Tween object for chaining.
|
|
349
347
|
*/
|
|
350
|
-
onUpdateCallback(callback: Function, callbackContext: any) {
|
|
348
|
+
public onUpdateCallback(callback: Function, callbackContext: any) {
|
|
351
349
|
this._onUpdateCallback = callback;
|
|
352
350
|
this._onUpdateCallbackContext = callbackContext;
|
|
353
351
|
return this;
|
|
@@ -356,7 +354,7 @@ export class Tween {
|
|
|
356
354
|
/**
|
|
357
355
|
* Pauses the tween.
|
|
358
356
|
*/
|
|
359
|
-
pause() {
|
|
357
|
+
public pause() {
|
|
360
358
|
this.isPaused = true;
|
|
361
359
|
this._codePaused = true;
|
|
362
360
|
this._pausedTime = this.game.time.time;
|
|
@@ -365,7 +363,7 @@ export class Tween {
|
|
|
365
363
|
/**
|
|
366
364
|
* Internal method to pause the tween.
|
|
367
365
|
*/
|
|
368
|
-
_pause() {
|
|
366
|
+
public _pause() {
|
|
369
367
|
if (!this._codePaused) {
|
|
370
368
|
this.isPaused = true;
|
|
371
369
|
this._pausedTime = this.game.time.time;
|
|
@@ -375,13 +373,13 @@ export class Tween {
|
|
|
375
373
|
/**
|
|
376
374
|
* Resumes the tween.
|
|
377
375
|
*/
|
|
378
|
-
resume() {
|
|
376
|
+
public resume() {
|
|
379
377
|
if (this.isPaused) {
|
|
380
378
|
this.isPaused = false;
|
|
381
379
|
this._codePaused = false;
|
|
382
|
-
for (
|
|
383
|
-
if (!
|
|
384
|
-
|
|
380
|
+
for (const tweenData of this.timeline) {
|
|
381
|
+
if (!tweenData.isRunning) {
|
|
382
|
+
tweenData.startTime += this.game.time.time - this._pausedTime;
|
|
385
383
|
}
|
|
386
384
|
}
|
|
387
385
|
}
|
|
@@ -390,7 +388,7 @@ export class Tween {
|
|
|
390
388
|
/**
|
|
391
389
|
* Internal method to resume the tween.
|
|
392
390
|
*/
|
|
393
|
-
_resume() {
|
|
391
|
+
public _resume() {
|
|
394
392
|
if (!this._codePaused) {
|
|
395
393
|
this.resume();
|
|
396
394
|
}
|
|
@@ -401,14 +399,14 @@ export class Tween {
|
|
|
401
399
|
* @param {number} time - The current game time.
|
|
402
400
|
* @returns {boolean} True if the tween should continue running, false if it's complete.
|
|
403
401
|
*/
|
|
404
|
-
update(time: number) {
|
|
402
|
+
public update(time: number) {
|
|
405
403
|
if (this.pendingDelete || !this.target) {
|
|
406
404
|
return false;
|
|
407
405
|
}
|
|
408
406
|
if (this.isPaused) {
|
|
409
407
|
return true;
|
|
410
408
|
}
|
|
411
|
-
const status = this.timeline[this.current]
|
|
409
|
+
const status = this.timeline[this.current]!.update(time);
|
|
412
410
|
if (status === TWEEN_PENDING) {
|
|
413
411
|
return true;
|
|
414
412
|
} else if (status === TWEEN_RUNNING) {
|
|
@@ -420,14 +418,14 @@ export class Tween {
|
|
|
420
418
|
this._onUpdateCallback.call(
|
|
421
419
|
this._onUpdateCallbackContext,
|
|
422
420
|
this,
|
|
423
|
-
this.timeline[this.current]
|
|
421
|
+
this.timeline[this.current]!.value,
|
|
424
422
|
this.timeline[this.current]
|
|
425
423
|
);
|
|
426
424
|
}
|
|
427
425
|
// In case the update callback modifies this tween
|
|
428
426
|
return this.isRunning;
|
|
429
427
|
} else if (status === TWEEN_LOOPED) {
|
|
430
|
-
if (this.timeline[this.current]
|
|
428
|
+
if (this.timeline[this.current]!.repeatCounter === -1) {
|
|
431
429
|
this.onLoop.dispatch(this.target, this);
|
|
432
430
|
} else {
|
|
433
431
|
this.onRepeat.dispatch(this.target, this);
|
|
@@ -452,13 +450,13 @@ export class Tween {
|
|
|
452
450
|
if (complete) {
|
|
453
451
|
// We've reached the start or end of the child tweens (depending on Tween.reverse), should we repeat it?
|
|
454
452
|
if (this.repeatCounter === -1) {
|
|
455
|
-
this.timeline[this.current]
|
|
453
|
+
this.timeline[this.current]!.start();
|
|
456
454
|
this.onLoop.dispatch(this.target, this);
|
|
457
455
|
return true;
|
|
458
456
|
} else if (this.repeatCounter > 0) {
|
|
459
457
|
this.repeatCounter -= 1;
|
|
460
458
|
|
|
461
|
-
this.timeline[this.current]
|
|
459
|
+
this.timeline[this.current]!.start();
|
|
462
460
|
this.onRepeat.dispatch(this.target, this);
|
|
463
461
|
return true;
|
|
464
462
|
}
|
|
@@ -473,7 +471,7 @@ export class Tween {
|
|
|
473
471
|
}
|
|
474
472
|
// We've still got some children to go
|
|
475
473
|
this.onChildComplete.dispatch(this.target, this);
|
|
476
|
-
this.timeline[this.current]
|
|
474
|
+
this.timeline[this.current]!.start();
|
|
477
475
|
return true;
|
|
478
476
|
}
|
|
479
477
|
return false;
|
|
@@ -485,29 +483,28 @@ export class Tween {
|
|
|
485
483
|
* @param {object[]} data - The array to store the generated data in.
|
|
486
484
|
* @returns {object[]} The populated data array.
|
|
487
485
|
*/
|
|
488
|
-
generateData(frameRate
|
|
486
|
+
public generateData(frameRate = 60, data: any[] = []) {
|
|
489
487
|
if (this.game === null || this.target === null) {
|
|
490
488
|
return null;
|
|
491
489
|
}
|
|
492
490
|
// Populate the tween data
|
|
493
|
-
for (
|
|
491
|
+
for (const tweenData of this.timeline) {
|
|
494
492
|
// Build our master property list with the starting values
|
|
495
|
-
const keys = Object.keys(
|
|
496
|
-
for (
|
|
497
|
-
const property = keys[k];
|
|
493
|
+
const keys = Object.keys(tweenData.vEnd);
|
|
494
|
+
for (const property of keys) {
|
|
498
495
|
const targetProperties = this.target as unknown as Record<string, number>;
|
|
499
|
-
this.properties[property] = targetProperties[property]
|
|
496
|
+
this.properties[property] = targetProperties[property] ?? 0;
|
|
500
497
|
if (!Array.isArray(this.properties[property])) {
|
|
501
498
|
// Ensures we're using numbers, not strings
|
|
502
499
|
this.properties[property] *= 1;
|
|
503
500
|
}
|
|
504
501
|
}
|
|
505
502
|
}
|
|
506
|
-
for (
|
|
507
|
-
|
|
503
|
+
for (const tweenData of this.timeline) {
|
|
504
|
+
tweenData.loadValues();
|
|
508
505
|
}
|
|
509
|
-
for (
|
|
510
|
-
data = data.concat(
|
|
506
|
+
for (const tweenData of this.timeline) {
|
|
507
|
+
data = data.concat(tweenData.generateData(frameRate));
|
|
511
508
|
}
|
|
512
509
|
return data;
|
|
513
510
|
}
|
|
@@ -516,10 +513,10 @@ export class Tween {
|
|
|
516
513
|
* Gets the total duration of all timeline entries.
|
|
517
514
|
* @returns {number} The total duration in milliseconds.
|
|
518
515
|
*/
|
|
519
|
-
get totalDuration() {
|
|
516
|
+
public get totalDuration() {
|
|
520
517
|
let total = 0;
|
|
521
|
-
for (
|
|
522
|
-
total +=
|
|
518
|
+
for (const tweenData of this.timeline) {
|
|
519
|
+
total += tweenData.duration;
|
|
523
520
|
}
|
|
524
521
|
return total;
|
|
525
522
|
}
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import * as MathUtils from '../util/math.js';
|
|
2
2
|
import { TWEEN_COMPLETE, TWEEN_LOOPED, TWEEN_PENDING, TWEEN_RUNNING } from './const.js';
|
|
3
|
+
import type { Tween } from './tween.js';
|
|
3
4
|
|
|
4
5
|
export class TweenData {
|
|
5
|
-
parent!: any;
|
|
6
|
-
game!: any;
|
|
7
|
-
vStart!: any;
|
|
8
|
-
vStartCache!: any;
|
|
9
|
-
vEnd!: any;
|
|
10
|
-
vEndCache!: any;
|
|
11
|
-
duration!: any;
|
|
12
|
-
percent!: any;
|
|
13
|
-
value!: any;
|
|
14
|
-
repeatCounter!: any;
|
|
15
|
-
repeatDelay!: any;
|
|
16
|
-
repeatTotal!: any;
|
|
17
|
-
interpolate!: any;
|
|
18
|
-
yoyo!: any;
|
|
19
|
-
yoyoDelay!: any;
|
|
20
|
-
inReverse!: any;
|
|
21
|
-
delay!: any;
|
|
22
|
-
dt!: any;
|
|
23
|
-
startTime!: any;
|
|
24
|
-
easingFunction!: any;
|
|
25
|
-
interpolationFunction!: any;
|
|
26
|
-
interpolationContext!: any;
|
|
27
|
-
isRunning!: any;
|
|
28
|
-
isFrom!: any;
|
|
29
|
-
yoyoCounter!: any;
|
|
6
|
+
public parent!: any;
|
|
7
|
+
public game!: any;
|
|
8
|
+
public vStart!: any;
|
|
9
|
+
public vStartCache!: any;
|
|
10
|
+
public vEnd!: any;
|
|
11
|
+
public vEndCache!: any;
|
|
12
|
+
public duration!: any;
|
|
13
|
+
public percent!: any;
|
|
14
|
+
public value!: any;
|
|
15
|
+
public repeatCounter!: any;
|
|
16
|
+
public repeatDelay!: any;
|
|
17
|
+
public repeatTotal!: any;
|
|
18
|
+
public interpolate!: any;
|
|
19
|
+
public yoyo!: any;
|
|
20
|
+
public yoyoDelay!: any;
|
|
21
|
+
public inReverse!: any;
|
|
22
|
+
public delay!: any;
|
|
23
|
+
public dt!: any;
|
|
24
|
+
public startTime!: any;
|
|
25
|
+
public easingFunction!: any;
|
|
26
|
+
public interpolationFunction!: any;
|
|
27
|
+
public interpolationContext!: any;
|
|
28
|
+
public isRunning!: any;
|
|
29
|
+
public isFrom!: any;
|
|
30
|
+
public yoyoCounter!: any;
|
|
30
31
|
/**
|
|
31
32
|
* Creates a new TweenData instance.
|
|
32
|
-
* @param {
|
|
33
|
+
* @param {Tween} parent - The parent Tween instance.
|
|
33
34
|
*/
|
|
34
|
-
constructor(parent:
|
|
35
|
+
public constructor(parent: Tween) {
|
|
35
36
|
this.parent = parent;
|
|
36
37
|
this.game = parent.game;
|
|
37
38
|
this.vStart = {};
|
|
@@ -68,7 +69,7 @@ export class TweenData {
|
|
|
68
69
|
* @param {boolean} yoyo - Whether to reverse the tween on each repeat.
|
|
69
70
|
* @returns {TweenData} This TweenData object for chaining.
|
|
70
71
|
*/
|
|
71
|
-
to(properties: any, duration: number, ease: any, delay: number, repeat: number, yoyo: boolean) {
|
|
72
|
+
public to(properties: any, duration: number, ease: any, delay: number, repeat: number, yoyo: boolean) {
|
|
72
73
|
this.vEnd = properties;
|
|
73
74
|
this.duration = duration;
|
|
74
75
|
this.easingFunction = ease;
|
|
@@ -89,7 +90,7 @@ export class TweenData {
|
|
|
89
90
|
* @param {boolean} yoyo - Whether to reverse the tween on each repeat.
|
|
90
91
|
* @returns {TweenData} This TweenData object for chaining.
|
|
91
92
|
*/
|
|
92
|
-
from(properties: any, duration: number, ease: any, delay: number, repeat: number, yoyo: boolean) {
|
|
93
|
+
public from(properties: any, duration: number, ease: any, delay: number, repeat: number, yoyo: boolean) {
|
|
93
94
|
this.vEnd = properties;
|
|
94
95
|
this.duration = duration;
|
|
95
96
|
this.easingFunction = ease;
|
|
@@ -104,7 +105,7 @@ export class TweenData {
|
|
|
104
105
|
* Starts the tween.
|
|
105
106
|
* @returns {TweenData} This TweenData object for chaining.
|
|
106
107
|
*/
|
|
107
|
-
start() {
|
|
108
|
+
public start() {
|
|
108
109
|
this.startTime = this.game.time.time + this.delay;
|
|
109
110
|
if (this.parent.reverse) {
|
|
110
111
|
this.dt = this.duration;
|
|
@@ -119,8 +120,7 @@ export class TweenData {
|
|
|
119
120
|
if (this.isFrom) {
|
|
120
121
|
// Reverse them all and instant set them
|
|
121
122
|
const keys = Object.keys(this.vStartCache);
|
|
122
|
-
for (
|
|
123
|
-
const property = keys[k];
|
|
123
|
+
for (const property of keys) {
|
|
124
124
|
this.vStart[property] = this.vEndCache[property];
|
|
125
125
|
this.vEnd[property] = this.vStartCache[property];
|
|
126
126
|
this.parent.target[property] = this.vStart[property];
|
|
@@ -136,10 +136,9 @@ export class TweenData {
|
|
|
136
136
|
* Loads the tween values from the parent object.
|
|
137
137
|
* @returns {TweenData} This TweenData object for chaining.
|
|
138
138
|
*/
|
|
139
|
-
loadValues() {
|
|
139
|
+
public loadValues() {
|
|
140
140
|
const keys = Object.keys(this.parent.properties);
|
|
141
|
-
for (
|
|
142
|
-
const property = keys[k];
|
|
141
|
+
for (const property of keys) {
|
|
143
142
|
// Load the property from the parent object
|
|
144
143
|
this.vStart[property] = this.parent.properties[property];
|
|
145
144
|
// Check if an Array was provided as property value
|
|
@@ -153,10 +152,10 @@ export class TweenData {
|
|
|
153
152
|
this.vEnd[property] = [this.vStart[property]].concat(this.vEnd[property]);
|
|
154
153
|
}
|
|
155
154
|
}
|
|
156
|
-
if (
|
|
155
|
+
if (this.vEnd[property] !== undefined) {
|
|
157
156
|
if (typeof this.vEnd[property] === 'string') {
|
|
158
157
|
// Parses relative end values with start as base (e.g.: +10, -3)
|
|
159
|
-
this.vEnd[property] = this.vStart[property] + Number
|
|
158
|
+
this.vEnd[property] = this.vStart[property] + Number(this.vEnd[property]);
|
|
160
159
|
}
|
|
161
160
|
this.parent.properties[property] = this.vEnd[property];
|
|
162
161
|
} else {
|
|
@@ -174,7 +173,7 @@ export class TweenData {
|
|
|
174
173
|
* @param {number} time - The current time in milliseconds.
|
|
175
174
|
* @returns {number} The tween status (TWEEN_PENDING, TWEEN_RUNNING, or TWEEN_COMPLETE).
|
|
176
175
|
*/
|
|
177
|
-
update(time: number) {
|
|
176
|
+
public update(time: number) {
|
|
178
177
|
if (!this.isRunning) {
|
|
179
178
|
if (time >= this.startTime) {
|
|
180
179
|
this.isRunning = true;
|
|
@@ -196,8 +195,7 @@ export class TweenData {
|
|
|
196
195
|
this.percent = this.dt / this.duration;
|
|
197
196
|
this.value = this.easingFunction(this.percent);
|
|
198
197
|
const keys = Object.keys(this.vEnd);
|
|
199
|
-
for (
|
|
200
|
-
const property = keys[k];
|
|
198
|
+
for (const property of keys) {
|
|
201
199
|
const start = this.vStart[property];
|
|
202
200
|
const end = this.vEnd[property];
|
|
203
201
|
if (Array.isArray(end)) {
|
|
@@ -217,7 +215,7 @@ export class TweenData {
|
|
|
217
215
|
* @param {number} frameRate - The frame rate to generate data for.
|
|
218
216
|
* @returns {object[]} An array of tween data points.
|
|
219
217
|
*/
|
|
220
|
-
generateData(frameRate: number) {
|
|
218
|
+
public generateData(frameRate: number) {
|
|
221
219
|
if (this.parent.reverse) {
|
|
222
220
|
this.dt = this.duration;
|
|
223
221
|
} else {
|
|
@@ -238,8 +236,7 @@ export class TweenData {
|
|
|
238
236
|
this.value = this.easingFunction(this.percent);
|
|
239
237
|
const blob: Record<string, number> = {};
|
|
240
238
|
const keys = Object.keys(this.vEnd);
|
|
241
|
-
for (
|
|
242
|
-
const property = keys[k];
|
|
239
|
+
for (const property of keys) {
|
|
243
240
|
const start = this.vStart[property];
|
|
244
241
|
const end = this.vEnd[property];
|
|
245
242
|
if (Array.isArray(end)) {
|
|
@@ -254,7 +251,7 @@ export class TweenData {
|
|
|
254
251
|
}
|
|
255
252
|
} while (!complete);
|
|
256
253
|
if (this.yoyo) {
|
|
257
|
-
const reversed = data
|
|
254
|
+
const reversed = [...data];
|
|
258
255
|
reversed.reverse();
|
|
259
256
|
data = data.concat(reversed);
|
|
260
257
|
}
|
|
@@ -265,15 +262,14 @@ export class TweenData {
|
|
|
265
262
|
* Handles tween repetition logic.
|
|
266
263
|
* @returns {number} The tween status (TWEEN_LOOPED or TWEEN_COMPLETE).
|
|
267
264
|
*/
|
|
268
|
-
repeat() {
|
|
265
|
+
public repeat() {
|
|
269
266
|
// If not a yoyo and repeatCounter = 0 then we're done
|
|
270
267
|
if (this.yoyo) {
|
|
271
268
|
// We're already in reverse mode, which means the yoyo has finished and there's no repeats, so end
|
|
272
269
|
if (this.inReverse && this.repeatCounter === 0) {
|
|
273
270
|
// Restore the properties
|
|
274
271
|
const keys = Object.keys(this.vStartCache);
|
|
275
|
-
for (
|
|
276
|
-
const property = keys[k];
|
|
272
|
+
for (const property of keys) {
|
|
277
273
|
this.vStart[property] = this.vStartCache[property];
|
|
278
274
|
this.vEnd[property] = this.vEndCache[property];
|
|
279
275
|
}
|
|
@@ -287,16 +283,14 @@ export class TweenData {
|
|
|
287
283
|
if (this.inReverse) {
|
|
288
284
|
// If inReverse we're going from vEnd to vStartCache
|
|
289
285
|
const keys = Object.keys(this.vStartCache);
|
|
290
|
-
for (
|
|
291
|
-
const property = keys[k];
|
|
286
|
+
for (const property of keys) {
|
|
292
287
|
this.vStart[property] = this.vEndCache[property];
|
|
293
288
|
this.vEnd[property] = this.vStartCache[property];
|
|
294
289
|
}
|
|
295
290
|
} else {
|
|
296
291
|
// If not inReverse we're just repopulating the cache again
|
|
297
292
|
const keys = Object.keys(this.vStartCache);
|
|
298
|
-
for (
|
|
299
|
-
const property = keys[k];
|
|
293
|
+
for (const property of keys) {
|
|
300
294
|
this.vStart[property] = this.vStartCache[property];
|
|
301
295
|
this.vEnd[property] = this.vEndCache[property];
|
|
302
296
|
}
|