bard-legends-framework 0.11.0 → 0.12.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/actions-performance.test.d.ts +1 -0
- package/dist/actions-performance.test.js +83 -0
- package/dist/game-entities/controller/controller.d.ts +2 -2
- package/dist/game-entities/controller/controller.js +8 -8
- package/dist/game-entities/controller/controller.test.js +2 -2
- package/dist/game-entities/entity/entity.d.ts +7 -7
- package/dist/game-entities/entity/entity.js +18 -12
- package/dist/game-entities/entity/entity.test.js +93 -30
- package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +3 -3
- package/dist/game-entities/entity/helpers/entity-store.helper.js +12 -12
- package/dist/game-entities/entity/helpers/entity-store.helper.test.js +11 -11
- package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +6 -6
- package/dist/game-entities/entity/helpers/entity-views.helper.js +25 -22
- package/dist/game-entities/entity/singleton-entity.test.js +9 -4
- package/dist/game-entities/hard-reset.d.ts +5 -0
- package/dist/game-entities/hard-reset.js +14 -0
- package/dist/game-entities/index.d.ts +1 -1
- package/dist/game-entities/index.js +3 -3
- package/dist/game-entities/scene/scene.d.ts +13 -13
- package/dist/game-entities/scene/scene.js +41 -46
- package/dist/game-entities/scene/scene.test.js +95 -37
- package/dist/game-entities/service/service.d.ts +1 -4
- package/dist/game-entities/service/service.js +12 -13
- package/dist/game-entities/service/service.test.js +33 -12
- package/dist/game-entities/unit-test.helper.js +1 -1
- package/dist/game-entities/update-cycle.d.ts +7 -17
- package/dist/game-entities/update-cycle.js +25 -19
- package/dist/game-entities/view/view.d.ts +6 -6
- package/dist/game-entities/view/view.js +15 -21
- package/dist/game-entities/view/view.test.js +40 -9
- package/dist/physics/entity-types/immovable-physics-entity.d.ts +1 -1
- package/dist/physics/entity-types/immovable-physics-entity.js +4 -4
- package/dist/physics/entity-types/movable-entity.d.ts +1 -1
- package/dist/physics/entity-types/movable-entity.js +2 -2
- package/dist/physics/entity-types/movable-physics-entity.d.ts +8 -8
- package/dist/physics/entity-types/movable-physics-entity.js +27 -27
- package/dist/physics/entity-types/physics-entity.d.ts +10 -14
- package/dist/physics/entity-types/physics-entity.js +27 -26
- package/dist/physics/interfaces.d.ts +6 -6
- package/dist/physics/interfaces.js +4 -4
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +16 -16
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.js +22 -22
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +19 -19
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.js +30 -30
- package/dist/physics/module//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +3 -3
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +10 -10
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.js +16 -16
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +10 -10
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.js +18 -18
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.d.ts +5 -5
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.js +17 -17
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.js +11 -11
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.js +4 -4
- package/dist/physics/module//360/237/223/220services/creation/border.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/creation/border.service.js +9 -9
- package/dist/physics/module//360/237/223/220services/creation/materials.service.d.ts +7 -7
- package/dist/physics/module//360/237/223/220services/creation/materials.service.js +17 -17
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.d.ts +11 -11
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +27 -26
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.js +13 -13
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.js +19 -19
- package/dist/physics/module//360/237/223/220services/impact/explosion.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/impact/explosion.service.js +20 -20
- package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.d.ts +1 -1
- package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.js +4 -4
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.js +3 -3
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.d.ts +5 -5
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +12 -12
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +12 -12
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.js +4 -4
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.d.ts +1 -4
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.js +7 -15
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +43 -42
- package/dist/physics/module//360/237/247/212entities/border.entity.d.ts +1 -1
- package/dist/physics/module//360/237/247/212entities/border.entity.js +3 -3
- package/dist/pixi/components/display-object-array.d.ts +5 -5
- package/dist/pixi/components/display-object-array.js +14 -14
- package/dist/pixi/components/helpers/smooth-scroller.d.ts +7 -7
- package/dist/pixi/components/helpers/smooth-scroller.js +23 -23
- package/dist/pixi/components/helpers/smooth-scroller.test.js +14 -14
- package/dist/pixi/components/menu/menu-entity.d.ts +14 -0
- package/dist/pixi/components/menu/menu-entity.js +48 -0
- package/dist/pixi/components/menu/menu.ui.d.ts +23 -0
- package/dist/pixi/components/menu/menu.ui.js +97 -0
- package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +2 -2
- package/dist/pixi/components/mouse-wheel-listener.ui.js +11 -11
- package/dist/pixi/components/scroll-area.ui.d.ts +1 -1
- package/dist/pixi/components/scroll-area.ui.js +9 -9
- package/dist/pixi/components/scroll-mask.ui.d.ts +9 -8
- package/dist/pixi/components/scroll-mask.ui.js +25 -24
- package/dist/pixi/display-object/container-attributes.d.ts +24 -25
- package/dist/pixi/display-object/container-attributes.js +26 -26
- package/dist/pixi/display-object/container.d.ts +3 -3
- package/dist/pixi/display-object/container.js +2 -2
- package/dist/pixi/display-object/filters/base-filters/blur.filter.d.ts +9 -9
- package/dist/pixi/display-object/filters/base-filters/blur.filter.js +25 -25
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.d.ts +7 -7
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.js +17 -17
- package/dist/pixi/display-object/filters/composite-filters/glow-filter.d.ts +6 -6
- package/dist/pixi/display-object/filters/composite-filters/glow-filter.js +10 -11
- package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.d.ts +2 -2
- package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.js +5 -5
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.d.ts +5 -5
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.js +8 -8
- package/dist/pixi/display-object/filters/templates/plane.template.d.ts +5 -5
- package/dist/pixi/display-object/filters/templates/plane.template.js +7 -7
- package/dist/pixi/display-object/filters.d.ts +7 -7
- package/dist/pixi/display-object/filters.js +34 -34
- package/dist/pixi/display-object/index.d.ts +1 -1
- package/dist/pixi/display-object/objects/graphics/graphics.d.ts +9 -9
- package/dist/pixi/display-object/objects/graphics/graphics.js +25 -25
- package/dist/pixi/display-object/objects/placeholder.d.ts +1 -1
- package/dist/pixi/display-object/objects/placeholder.js +7 -7
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.d.ts +9 -9
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +26 -25
- package/dist/pixi/display-object/objects/sprite/sprite.d.ts +10 -9
- package/dist/pixi/display-object/objects/sprite/sprite.js +62 -53
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter.d.ts +4 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.d.ts +6 -6
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +16 -16
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +28 -28
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.d.ts +1 -1
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.js +3 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.d.ts +17 -17
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.js +62 -62
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.test.js +2 -2
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.d.ts +3 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.js +6 -6
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.test.js +12 -12
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +2 -2
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.test.js +5 -5
- package/dist/pixi/display-object/objects/text/rich-text.d.ts +0 -1
- package/dist/pixi/display-object/objects/text/rich-text.js +0 -1
- package/dist/pixi/display-object/objects/text/text.d.ts +9 -10
- package/dist/pixi/display-object/objects/text/text.js +34 -35
- package/dist/pixi/game.d.ts +20 -15
- package/dist/pixi/game.js +40 -35
- package/dist/pixi/helpers/game-assets.d.ts +5 -5
- package/dist/pixi/helpers/game-assets.js +14 -11
- package/dist/pixi/helpers/position-conversion.helper.d.ts +4 -4
- package/dist/pixi/helpers/position-conversion.helper.js +3 -3
- package/dist/pixi/index.d.ts +3 -37
- package/dist/pixi/index.js +6 -22
- package/dist/pixi/modules/CAMERA/camera.d.ts +5 -4
- package/dist/pixi/modules/CAMERA/camera.js +9 -9
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.d.ts +3 -2
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.js +1 -1
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.d.ts +3 -2
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.js +5 -5
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.d.ts +3 -3
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.js +7 -7
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +8 -8
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.js +8 -8
- package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.d.ts +2 -2
- package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.js +12 -12
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.d.ts +17 -16
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +49 -48
- package/dist/pixi/pixi-definitions.d.ts +38 -0
- package/dist/pixi/pixi-definitions.js +37 -0
- package/dist/pixi/services/keyboard/keyboard.d.ts +2 -2
- package/dist/pixi/services/keyboard/keyboard.js +9 -9
- package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +10 -10
- package/dist/pixi/services/mouse/mouse-target-focus.service.js +28 -28
- package/dist/pixi/services/mouse/mouse.service.d.ts +1 -1
- package/dist/pixi/services/mouse/mouse.service.js +5 -5
- package/dist/utilities/animator/animating-content/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/animating-content/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/animating-content/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/animating-content/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/animations.d.ts +14 -6
- package/dist/utilities/animator/animations.js +15 -11
- package/dist/utilities/animator/animator/animator.d.ts +44 -0
- package/dist/utilities/animator/animator/animator.js +234 -0
- package/dist/utilities/animator/animator/animator.memory-leak.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.memory-leak.test.js +73 -0
- package/dist/utilities/animator/animator/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.performance.test.js +116 -0
- package/dist/utilities/animator/animator/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.test.js +1046 -0
- package/dist/utilities/animator/animator.d.ts +2 -3
- package/dist/utilities/animator/animator.js +66 -59
- package/dist/utilities/animator/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator.performance.test.js +46 -0
- package/dist/utilities/animator/animator.test.js +89 -28
- package/dist/utilities/animator/animator2/animator.d.ts +42 -0
- package/dist/utilities/animator/animator2/animator.js +222 -0
- package/dist/utilities/animator/animator2/animator.memory-leak.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.memory-leak.test.js +73 -0
- package/dist/utilities/animator/animator2/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.performance.test.js +65 -0
- package/dist/utilities/animator/animator2/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.test.js +1007 -0
- package/dist/utilities/animator/animator_old/animator.d.ts +60 -0
- package/dist/utilities/animator/animator_old/animator.js +337 -0
- package/dist/utilities/animator/animator_old/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator_old/animator.performance.test.js +121 -0
- package/dist/utilities/animator/animator_old/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator_old/animator.test.js +996 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.js +37 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.d.ts +38 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.js +208 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.js +439 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.d.ts +41 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.js +107 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.js +138 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.js +307 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.d.ts +37 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.js +170 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.test.js +340 -0
- package/dist/utilities/animator/index.d.ts +6 -6
- package/dist/utilities/animator/index.js +6 -6
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.js +37 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.d.ts +32 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.js +168 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.js +431 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.d.ts +37 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.js +100 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.js +130 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.js +301 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.js +30 -30
- package/dist/utilities/animator/state-animation/state-animation.js +7 -7
- package/dist/utilities/animator/state-animation/state-animation.test.js +24 -24
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +30 -30
- package/dist/utilities/data-structures/vector-set/vector-set.d.ts +1 -1
- package/dist/utilities/data-structures/vector-set/vector-set.js +5 -5
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +1 -1
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +5 -5
- package/dist/utilities/grid-algorithms/path-finder/path-finder.js +21 -21
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +9 -9
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +14 -14
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +43 -43
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +21 -21
- package/package.json +7 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Attachable } from 'actions-lib';
|
|
1
|
+
import { Attachable, SingleEvent } from 'actions-lib';
|
|
2
2
|
import { AnimatorAnimation } from './animations';
|
|
3
3
|
export interface AnimationState {
|
|
4
4
|
duration: number;
|
|
@@ -39,7 +39,6 @@ export declare class Animator<T> extends Attachable {
|
|
|
39
39
|
private running;
|
|
40
40
|
private propertyStates;
|
|
41
41
|
private updateCycleSubscription;
|
|
42
|
-
private allResolvers;
|
|
43
42
|
get isAnimating(): boolean;
|
|
44
43
|
constructor(target: T, effectOn: string | string[], options?: AnimationOptions);
|
|
45
44
|
onChange(callback: (target: T) => void): Animator<T>;
|
|
@@ -50,7 +49,7 @@ export declare class Animator<T> extends Attachable {
|
|
|
50
49
|
resumeAnimations(): void;
|
|
51
50
|
completeAnimations(completeAnimationsHandling?: CompleteAnimationsHandlingType): void;
|
|
52
51
|
set(values: Record<string, any>): void;
|
|
53
|
-
animate(values: Record<string, any>, options?: AnimationOptions):
|
|
52
|
+
animate(values: Record<string, any>, options?: AnimationOptions): SingleEvent;
|
|
54
53
|
private completeAnimationOfProperty;
|
|
55
54
|
private checkOngoingAnimations;
|
|
56
55
|
private update;
|
|
@@ -33,7 +33,6 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
33
33
|
this.effectOn = new Set();
|
|
34
34
|
this.running = true;
|
|
35
35
|
this.propertyStates = new Map();
|
|
36
|
-
this.allResolvers = new Set();
|
|
37
36
|
if (!helpers_lib_1.Comparator.isObject(target)) {
|
|
38
37
|
this.attachToRoot();
|
|
39
38
|
throw new Error(`Animator: target is not an object! Target: "${target}"`);
|
|
@@ -44,19 +43,19 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
44
43
|
animatedObjectProperties = new Set();
|
|
45
44
|
Animator.animatedObjects.set(target, animatedObjectProperties);
|
|
46
45
|
}
|
|
47
|
-
this.effectOn
|
|
46
|
+
for (let key of this.effectOn) {
|
|
48
47
|
if (animatedObjectProperties.has(key)) {
|
|
49
48
|
this.attachToRoot();
|
|
50
49
|
throw new Error(`Animator: target property is already animated! Target: "${JSON.stringify(target, undefined, 2)}", Property: "${key}"`);
|
|
51
50
|
}
|
|
52
51
|
animatedObjectProperties.add(key);
|
|
53
|
-
}
|
|
52
|
+
}
|
|
54
53
|
this.defaultDuration = options.duration ?? DEFAULT_DURATION;
|
|
55
54
|
this.defaultAnimation = options.animation ?? DEFAULT_ANIMATION;
|
|
56
55
|
this.defaultLoop = options.loop ?? DEFAULT_LOOP;
|
|
57
56
|
this.defaultReAnimateHandling = options.reAnimateHandling ?? DEFAULT_RE_ANIMATE_HANDLING;
|
|
58
57
|
this.defaultCompleteAnimationsHandling = options.completeAnimationsHandling ?? DEFAULT_COMPLETE_ANIMATIONS_HANDLING;
|
|
59
|
-
this.effectOn
|
|
58
|
+
for (let key of this.effectOn) {
|
|
60
59
|
if (!helpers_lib_1.Comparator.hasProperty(target, key)) {
|
|
61
60
|
this.attachToRoot();
|
|
62
61
|
throw new Error(`Animator: target does not have property. Target property: "${key}"`);
|
|
@@ -65,7 +64,7 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
65
64
|
this.attachToRoot();
|
|
66
65
|
throw new Error(`Animator: target property is not a number. Target property: "${key}"`);
|
|
67
66
|
}
|
|
68
|
-
}
|
|
67
|
+
}
|
|
69
68
|
}
|
|
70
69
|
onChange(callback) {
|
|
71
70
|
if (this.onChangeCallback) {
|
|
@@ -90,13 +89,13 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
90
89
|
this.defaultAnimation = DEFAULT_ANIMATION;
|
|
91
90
|
this.propertyStates.clear();
|
|
92
91
|
let animatedObjectProperties = Animator.animatedObjects.get(this.target);
|
|
93
|
-
|
|
92
|
+
for (let key of this.effectOn) {
|
|
93
|
+
animatedObjectProperties.delete(key);
|
|
94
|
+
}
|
|
94
95
|
if (animatedObjectProperties.size <= 0) {
|
|
95
96
|
Animator.animatedObjects.delete(this.target);
|
|
96
97
|
}
|
|
97
98
|
this.target = undefined;
|
|
98
|
-
this.allResolvers.forEach(resolver => resolver());
|
|
99
|
-
this.allResolvers.clear();
|
|
100
99
|
super.destroy();
|
|
101
100
|
}
|
|
102
101
|
}
|
|
@@ -121,7 +120,7 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
121
120
|
}
|
|
122
121
|
completeAnimations(completeAnimationsHandling) {
|
|
123
122
|
let triggerOnChange = false;
|
|
124
|
-
this.propertyStates
|
|
123
|
+
for (let [key, value] of this.propertyStates) {
|
|
125
124
|
let completeAnimationsHandlingFinal = completeAnimationsHandling ?? value.completeAnimationsHandling;
|
|
126
125
|
if (completeAnimationsHandlingFinal === CompleteAnimationsHandlingType.returnToOriginal) {
|
|
127
126
|
if (this.target[key] !== value.startingValue) {
|
|
@@ -136,33 +135,46 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
this.completeAnimationOfProperty(value);
|
|
139
|
-
}
|
|
138
|
+
}
|
|
140
139
|
triggerOnChange && this.triggerOnChange();
|
|
141
140
|
}
|
|
142
141
|
set(values) {
|
|
143
|
-
Object.keys(values)
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
let keys = Object.keys(values);
|
|
143
|
+
for (let i = 0; i < keys.length; i++) {
|
|
144
|
+
this.checkPropertyValidity(keys[i]);
|
|
145
|
+
}
|
|
146
146
|
this.checkOngoingAnimations(values);
|
|
147
147
|
let triggerOnChange = false;
|
|
148
|
-
|
|
148
|
+
for (let i = 0; i < keys.length; i++) {
|
|
149
|
+
let key = keys[i];
|
|
149
150
|
triggerOnChange = triggerOnChange || this.target[key] !== values[key];
|
|
150
151
|
this.target[key] = values[key];
|
|
151
|
-
}
|
|
152
|
+
}
|
|
152
153
|
triggerOnChange && this.triggerOnChange();
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
+
animate(values, options = {}) {
|
|
155
156
|
if (this.destroyed) {
|
|
156
|
-
return;
|
|
157
|
+
return actions_lib_1.SingleEvent.create(resolve => resolve());
|
|
157
158
|
}
|
|
158
159
|
let valueKeys = Object.keys(values);
|
|
159
|
-
valueKeys.
|
|
160
|
-
this.checkPropertyValidity(
|
|
161
|
-
}
|
|
160
|
+
for (let i = 0; i < valueKeys.length; i++) {
|
|
161
|
+
this.checkPropertyValidity(valueKeys[i]);
|
|
162
|
+
}
|
|
162
163
|
this.checkOngoingAnimations(values, options.reAnimateHandling);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
// Recalculate valueKeys after checkOngoingAnimations, as it may have deleted some keys
|
|
165
|
+
valueKeys = Object.keys(values);
|
|
166
|
+
this.subscribeUpdateCycle();
|
|
167
|
+
return actions_lib_1.SingleEvent.create(resolve => {
|
|
168
|
+
let ongoingKeys = new Set(valueKeys);
|
|
169
|
+
let animationDone = (key) => {
|
|
170
|
+
ongoingKeys.delete(key);
|
|
171
|
+
if (ongoingKeys.size <= 0) {
|
|
172
|
+
resolve();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
// console.log(Object.keys(values), ongoingKeys);
|
|
176
|
+
for (let i = 0; i < valueKeys.length; i++) {
|
|
177
|
+
let key = valueKeys[i];
|
|
166
178
|
let duration = options.duration ?? this.defaultDuration;
|
|
167
179
|
let animation = options.animation ?? this.defaultAnimation;
|
|
168
180
|
let loop = options.loop ?? this.defaultLoop;
|
|
@@ -170,34 +182,28 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
170
182
|
let startingValue = this.target[key];
|
|
171
183
|
let targetValue = values[key];
|
|
172
184
|
if (startingValue === targetValue && !loop) {
|
|
173
|
-
|
|
174
|
-
return;
|
|
185
|
+
animationDone(key);
|
|
175
186
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
this.allResolvers.delete(resolveAll);
|
|
187
|
+
else {
|
|
188
|
+
animation.start();
|
|
189
|
+
try {
|
|
190
|
+
this.propertyStates.set(key, {
|
|
191
|
+
propertyName: key,
|
|
192
|
+
duration,
|
|
193
|
+
animation,
|
|
194
|
+
elapsedTime: 0,
|
|
195
|
+
startingValue,
|
|
196
|
+
targetValue,
|
|
197
|
+
loop,
|
|
198
|
+
completeAnimationsHandling,
|
|
199
|
+
completionCallback: () => animationDone(key)
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
animationDone(key);
|
|
204
|
+
}
|
|
195
205
|
}
|
|
196
|
-
}
|
|
197
|
-
resolveAll();
|
|
198
|
-
this.allResolvers.delete(resolveAll);
|
|
199
|
-
});
|
|
200
|
-
this.subscribeUpdateCycle();
|
|
206
|
+
}
|
|
201
207
|
});
|
|
202
208
|
}
|
|
203
209
|
completeAnimationOfProperty(propertyState) {
|
|
@@ -213,11 +219,12 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
213
219
|
}
|
|
214
220
|
checkOngoingAnimations(values, reAnimateHandling) {
|
|
215
221
|
reAnimateHandling = reAnimateHandling ?? this.defaultReAnimateHandling;
|
|
216
|
-
Object.keys(values)
|
|
222
|
+
let keys = Object.keys(values);
|
|
223
|
+
for (let i = 0; i < keys.length; i++) {
|
|
224
|
+
let key = keys[i];
|
|
217
225
|
let previousState = this.propertyStates.get(key);
|
|
218
226
|
if (previousState) {
|
|
219
227
|
if (reAnimateHandling === ReAnimateHandlingType.throwError) {
|
|
220
|
-
this.attachToRoot();
|
|
221
228
|
throw new Error(`Animator: property is already being animated. Property: "${key}"`);
|
|
222
229
|
}
|
|
223
230
|
else if (reAnimateHandling === ReAnimateHandlingType.ignoreNewAnimation) {
|
|
@@ -227,13 +234,13 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
227
234
|
this.completeAnimationOfProperty(previousState);
|
|
228
235
|
}
|
|
229
236
|
}
|
|
230
|
-
}
|
|
237
|
+
}
|
|
231
238
|
}
|
|
232
239
|
update(delta) {
|
|
233
240
|
if (this.running && !this.destroyed) {
|
|
234
241
|
let triggerOnChange = this.propertyStates.size;
|
|
235
242
|
let propertyStatesToComplete = [];
|
|
236
|
-
this.propertyStates
|
|
243
|
+
for (let [key, value] of this.propertyStates) {
|
|
237
244
|
value.elapsedTime += delta;
|
|
238
245
|
let animationIsCompete = value.elapsedTime >= value.duration;
|
|
239
246
|
if (animationIsCompete) {
|
|
@@ -249,7 +256,7 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
249
256
|
else {
|
|
250
257
|
this.target[key] = value.targetValue;
|
|
251
258
|
}
|
|
252
|
-
// Do not complete inside the
|
|
259
|
+
// Do not complete inside the for loop, completion can start a new animation which will put the loop into infinite loop
|
|
253
260
|
propertyStatesToComplete.push(value);
|
|
254
261
|
}
|
|
255
262
|
}
|
|
@@ -258,10 +265,10 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
258
265
|
let relativeTarget = value.targetValue - value.startingValue;
|
|
259
266
|
this.target[key] = relativeTarget * multiplier + value.startingValue;
|
|
260
267
|
}
|
|
261
|
-
}
|
|
262
|
-
|
|
268
|
+
}
|
|
269
|
+
for (let value of propertyStatesToComplete) {
|
|
263
270
|
this.completeAnimationOfProperty(value);
|
|
264
|
-
}
|
|
271
|
+
}
|
|
265
272
|
triggerOnChange && this.triggerOnChange();
|
|
266
273
|
if (this.propertyStates.size <= 0) {
|
|
267
274
|
this.unsubscribeUpdateCycle();
|
|
@@ -277,14 +284,14 @@ class Animator extends actions_lib_1.Attachable {
|
|
|
277
284
|
}
|
|
278
285
|
catch (e) {
|
|
279
286
|
console.error('Animator:', e);
|
|
280
|
-
this.propertyStates.
|
|
287
|
+
for (let value of this.propertyStates.values()) {
|
|
281
288
|
try {
|
|
282
289
|
value.completionCallback();
|
|
283
290
|
}
|
|
284
291
|
catch (err) {
|
|
285
292
|
console.error('Animator:', err);
|
|
286
293
|
}
|
|
287
|
-
}
|
|
294
|
+
}
|
|
288
295
|
this.propertyStates = new Map();
|
|
289
296
|
this.unsubscribeUpdateCycle();
|
|
290
297
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const animator_1 = require("./animator");
|
|
6
|
+
vitest_1.describe.skipIf(!process.env.MANUAL)('Performance Tests', () => {
|
|
7
|
+
(0, vitest_1.test)('single', async () => {
|
|
8
|
+
await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
|
|
9
|
+
return new Promise(resolve => {
|
|
10
|
+
let obj = { x: 0, y: 0 };
|
|
11
|
+
let animator = new animator_1.Animator(obj, 'x', {
|
|
12
|
+
duration: 1
|
|
13
|
+
}).attachToRoot();
|
|
14
|
+
animator.animate({ x: 1 }).tap(resolve).attachToRoot();
|
|
15
|
+
animator['update'](1);
|
|
16
|
+
});
|
|
17
|
+
// 3.178299903869629
|
|
18
|
+
// converting to single event: 6.434300422668457
|
|
19
|
+
// with wait until all destroyed: 11.552299976348877
|
|
20
|
+
// 7.839200019836426
|
|
21
|
+
// last comparible: 5.697200298309326
|
|
22
|
+
// no forEach: 5.479100227355957
|
|
23
|
+
// after bundle: 2.5292000770568848
|
|
24
|
+
}, { sampleCount: 200 });
|
|
25
|
+
}, 60000);
|
|
26
|
+
(0, vitest_1.test)('multiple', async () => {
|
|
27
|
+
await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
|
|
28
|
+
return new Promise(resolve => {
|
|
29
|
+
let obj = { x: 0, y: 0 };
|
|
30
|
+
let animator = new animator_1.Animator(obj, ['x', 'y'], {
|
|
31
|
+
duration: 1
|
|
32
|
+
}).attachToRoot();
|
|
33
|
+
animator.animate({ x: 1, y: 1 }).tap(resolve).attachToRoot();
|
|
34
|
+
animator['update'](1);
|
|
35
|
+
});
|
|
36
|
+
// 3.6912999153137207
|
|
37
|
+
// converting to single event: 6.845600128173828
|
|
38
|
+
// with wait until all destroyed: 13.253100395202637
|
|
39
|
+
// 9.115399837493896
|
|
40
|
+
// last comparible: 6.0391998291015625
|
|
41
|
+
// no forEach: 5.958700180053711
|
|
42
|
+
// after bundle: 2.9321999549865723
|
|
43
|
+
}, { sampleCount: 200 });
|
|
44
|
+
}, 60000);
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=animator.performance.test.js.map
|
|
@@ -204,9 +204,12 @@ const animator_1 = require("./animator");
|
|
|
204
204
|
let obj = { x: 0 };
|
|
205
205
|
let completed = false;
|
|
206
206
|
let animator = new animator_1.Animator(obj, 'x').attachToRoot();
|
|
207
|
-
animator
|
|
207
|
+
animator
|
|
208
|
+
.animate({ x: 1 }, { duration: 2 })
|
|
209
|
+
.tap(() => {
|
|
208
210
|
completed = true;
|
|
209
|
-
})
|
|
211
|
+
})
|
|
212
|
+
.attachToRoot();
|
|
210
213
|
(0, vitest_1.expect)(completed).toBeFalsy();
|
|
211
214
|
animator['update'](1);
|
|
212
215
|
(0, vitest_1.expect)(completed).toBeFalsy();
|
|
@@ -311,9 +314,11 @@ const animator_1 = require("./animator");
|
|
|
311
314
|
reAnimateHandling: animator_1.ReAnimateHandlingType.throwError
|
|
312
315
|
}).attachToRoot();
|
|
313
316
|
animator.animate({ x: 1 });
|
|
314
|
-
|
|
317
|
+
(0, vitest_1.expect)(() => animator.animate({ x: 0 })).toThrow('Animator: property is already being animated. Property: "x"');
|
|
315
318
|
animator['update'](1);
|
|
316
|
-
|
|
319
|
+
(0, vitest_1.expect)(() => animator.animate({ x: 0 })).toThrow('Animator: property is already being animated. Property: "x"');
|
|
320
|
+
animator['update'](3);
|
|
321
|
+
(0, vitest_1.expect)(() => animator.animate({ x: 0 })).not.toThrow('Animator: property is already being animated. Property: "x"');
|
|
317
322
|
});
|
|
318
323
|
(0, vitest_1.test)('re-animation handling option ignore should ignore new animation', () => {
|
|
319
324
|
let obj = { x: 0 };
|
|
@@ -484,9 +489,12 @@ const animator_1 = require("./animator");
|
|
|
484
489
|
let obj = { x: 0 };
|
|
485
490
|
let completed = false;
|
|
486
491
|
let animator = new animator_1.Animator(obj, 'x').attachToRoot();
|
|
487
|
-
animator
|
|
492
|
+
animator
|
|
493
|
+
.animate({ x: 1 }, { duration: 4 })
|
|
494
|
+
.tap(() => {
|
|
488
495
|
completed = true;
|
|
489
|
-
})
|
|
496
|
+
})
|
|
497
|
+
.attachToRoot();
|
|
490
498
|
animator['update'](1);
|
|
491
499
|
await (0, helpers_lib_1.Wait)();
|
|
492
500
|
(0, vitest_1.expect)(completed).toBeFalsy();
|
|
@@ -499,13 +507,19 @@ const animator_1 = require("./animator");
|
|
|
499
507
|
let completed2 = false;
|
|
500
508
|
let obj = { x: 0, y: 0 };
|
|
501
509
|
let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationEaseInOut() }).attachToRoot();
|
|
502
|
-
animator
|
|
510
|
+
animator
|
|
511
|
+
.animate({ y: 10 }, { loop: true })
|
|
512
|
+
.tap(() => {
|
|
503
513
|
completed1 = true;
|
|
504
|
-
})
|
|
514
|
+
})
|
|
515
|
+
.attachToRoot();
|
|
505
516
|
animator['update'](1);
|
|
506
|
-
animator
|
|
517
|
+
animator
|
|
518
|
+
.animate({ x: 10 })
|
|
519
|
+
.tap(() => {
|
|
507
520
|
completed2 = true;
|
|
508
|
-
})
|
|
521
|
+
})
|
|
522
|
+
.attachToRoot();
|
|
509
523
|
animator['update'](1);
|
|
510
524
|
await (0, helpers_lib_1.Wait)();
|
|
511
525
|
(0, vitest_1.expect)(completed1).toBeFalsy();
|
|
@@ -784,13 +798,19 @@ const animator_1 = require("./animator");
|
|
|
784
798
|
let completed2 = false;
|
|
785
799
|
let obj = { x: 0, y: 0 };
|
|
786
800
|
let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4 }).attachToRoot();
|
|
787
|
-
animator
|
|
801
|
+
animator
|
|
802
|
+
.animate({ y: 10 })
|
|
803
|
+
.tap(() => {
|
|
788
804
|
completed1 = true;
|
|
789
|
-
})
|
|
805
|
+
})
|
|
806
|
+
.attachToRoot();
|
|
790
807
|
animator['update'](1);
|
|
791
|
-
animator
|
|
808
|
+
animator
|
|
809
|
+
.animate({ x: 10 })
|
|
810
|
+
.tap(() => {
|
|
792
811
|
completed2 = true;
|
|
793
|
-
})
|
|
812
|
+
})
|
|
813
|
+
.attachToRoot();
|
|
794
814
|
animator['update'](2);
|
|
795
815
|
await (0, helpers_lib_1.Wait)();
|
|
796
816
|
(0, vitest_1.expect)(completed1).toBeFalsy();
|
|
@@ -833,13 +853,13 @@ const animator_1 = require("./animator");
|
|
|
833
853
|
let obj = { x: 0 };
|
|
834
854
|
let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).attachToRoot();
|
|
835
855
|
animator.animate({ x: 4 });
|
|
836
|
-
|
|
856
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
837
857
|
(0, vitest_1.expect)(obj.x).toEqual(1);
|
|
838
|
-
|
|
858
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
839
859
|
(0, vitest_1.expect)(obj.x).toEqual(2);
|
|
840
|
-
|
|
860
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
841
861
|
(0, vitest_1.expect)(obj.x).toEqual(3);
|
|
842
|
-
|
|
862
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
843
863
|
(0, vitest_1.expect)(obj.x).toEqual(4);
|
|
844
864
|
});
|
|
845
865
|
});
|
|
@@ -848,19 +868,60 @@ const animator_1 = require("./animator");
|
|
|
848
868
|
let obj = { x: 0 };
|
|
849
869
|
let animator = new animator_1.Animator(obj, 'x', { duration: 1, animation: new animations_1.AnimationLineer() }).attachToRoot();
|
|
850
870
|
animator.destroy();
|
|
851
|
-
|
|
871
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
852
872
|
animator.animate({ x: 1 });
|
|
853
|
-
|
|
873
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
854
874
|
(0, vitest_1.expect)(obj.x).toEqual(0);
|
|
855
875
|
});
|
|
856
|
-
(0, vitest_1.test)('
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
876
|
+
(0, vitest_1.test)('after destroy animation should not trigger complete', async () => {
|
|
877
|
+
let obj = { x: 0 };
|
|
878
|
+
let animator = new animator_1.Animator(obj, 'x', { duration: 1, animation: new animations_1.AnimationLineer() }).attachToRoot();
|
|
879
|
+
let animation = animator.animate({ x: 1 });
|
|
880
|
+
animator.destroy();
|
|
881
|
+
let triggered = false;
|
|
882
|
+
animation
|
|
883
|
+
.tap(() => {
|
|
884
|
+
triggered = true;
|
|
885
|
+
})
|
|
886
|
+
.attachToRoot();
|
|
887
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
888
|
+
(0, vitest_1.expect)(triggered).toBeFalsy();
|
|
889
|
+
});
|
|
890
|
+
(0, vitest_1.test)('destroying animator should destroy the animation that attached to that animator', () => {
|
|
891
|
+
let obj = { x: 0 };
|
|
892
|
+
let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).attachToRoot();
|
|
893
|
+
animator.animate({ x: 4 }).attach(animator);
|
|
894
|
+
animator['update'](1);
|
|
895
|
+
(0, vitest_1.expect)(obj.x).toEqual(1);
|
|
896
|
+
animator['update'](1);
|
|
897
|
+
(0, vitest_1.expect)(obj.x).toEqual(2);
|
|
898
|
+
animator['update'](1);
|
|
899
|
+
(0, vitest_1.expect)(obj.x).toEqual(3);
|
|
900
|
+
animator.destroy();
|
|
901
|
+
animator['update'](1);
|
|
902
|
+
animator['update'](1);
|
|
903
|
+
animator['update'](1);
|
|
904
|
+
(0, vitest_1.expect)(obj.x).toEqual(3);
|
|
905
|
+
});
|
|
906
|
+
(0, vitest_1.test)('animation sequence destroys the animator that it is being attached to', () => {
|
|
907
|
+
let obj = { x: 0 };
|
|
908
|
+
let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).attachToRoot();
|
|
909
|
+
animator
|
|
910
|
+
.animate({ x: 4 })
|
|
911
|
+
.tap(() => animator.destroy())
|
|
912
|
+
.attach(animator);
|
|
913
|
+
animator['update'](1);
|
|
914
|
+
(0, vitest_1.expect)(obj.x).toEqual(1);
|
|
915
|
+
(0, vitest_1.expect)(animator.destroyed).toBeFalsy();
|
|
916
|
+
animator['update'](1);
|
|
917
|
+
(0, vitest_1.expect)(obj.x).toEqual(2);
|
|
918
|
+
(0, vitest_1.expect)(animator.destroyed).toBeFalsy();
|
|
919
|
+
animator['update'](1);
|
|
920
|
+
(0, vitest_1.expect)(obj.x).toEqual(3);
|
|
921
|
+
(0, vitest_1.expect)(animator.destroyed).toBeFalsy();
|
|
922
|
+
animator['update'](1);
|
|
923
|
+
(0, vitest_1.expect)(obj.x).toEqual(4);
|
|
924
|
+
(0, vitest_1.expect)(animator.destroyed).toBeTruthy();
|
|
864
925
|
});
|
|
865
926
|
});
|
|
866
927
|
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IAttachment, NotifierCallbackFunction, SingleEvent } from 'actions-lib';
|
|
2
|
+
import { AnimatorAnimation } from '../animations';
|
|
3
|
+
export declare enum ReAnimateHandlingType {
|
|
4
|
+
throwError = 1,
|
|
5
|
+
ignoreNewAnimation = 2,
|
|
6
|
+
completePrevious = 3
|
|
7
|
+
}
|
|
8
|
+
export declare enum AnimationsCompletionHandlingType {
|
|
9
|
+
returnToOriginal = 1,
|
|
10
|
+
stayInCurrentState = 2,
|
|
11
|
+
jumpToEnd = 3,
|
|
12
|
+
loop = 4
|
|
13
|
+
}
|
|
14
|
+
export interface AnimationOptions {
|
|
15
|
+
readonly duration: number;
|
|
16
|
+
readonly animation: AnimatorAnimation;
|
|
17
|
+
readonly reAnimateHandling: ReAnimateHandlingType;
|
|
18
|
+
readonly completionHandling: AnimationsCompletionHandlingType;
|
|
19
|
+
}
|
|
20
|
+
type NumericKeys<T> = {
|
|
21
|
+
[P in keyof T]: T[P] extends number ? P : never;
|
|
22
|
+
}[keyof T] & string;
|
|
23
|
+
export declare class Animator<T extends object = any, K extends NumericKeys<T> = NumericKeys<T>> {
|
|
24
|
+
private static _animatedObjects;
|
|
25
|
+
private static _getAnimatedObjectProperties;
|
|
26
|
+
private _target;
|
|
27
|
+
private _options;
|
|
28
|
+
private _animatedProperties;
|
|
29
|
+
private _subscribeCallback?;
|
|
30
|
+
private _ongoingAnimation;
|
|
31
|
+
get animating(): boolean;
|
|
32
|
+
constructor(target: T & Record<K, number>, animatedProperties: K | K[], partialOptions?: Partial<AnimationOptions>);
|
|
33
|
+
subscribe(callback: NotifierCallbackFunction<T>): IAttachment;
|
|
34
|
+
animate(values: Record<K, number>, partialOptions?: Partial<AnimationOptions>): SingleEvent<void>;
|
|
35
|
+
set(values: Record<K, number>): void;
|
|
36
|
+
completeAnimation(completionHandling?: AnimationsCompletionHandlingType): void;
|
|
37
|
+
private _isAnimatingToSameValues;
|
|
38
|
+
private _setCompletionValues;
|
|
39
|
+
private _setValues;
|
|
40
|
+
private _lockAnimatedProperties;
|
|
41
|
+
}
|
|
42
|
+
export {};
|