bard-legends-framework 0.11.0 → 0.12.1
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
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const game_entities_1 = require("../../../../game-entities");
|
|
5
|
+
const fade_in_state_animation_1 = require("./fade-in-state-animation");
|
|
6
|
+
(0, vitest_1.describe)('FadeInStateAnimation', () => {
|
|
7
|
+
let heap = [];
|
|
8
|
+
let stateAnimation;
|
|
9
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
10
|
+
if (stateAnimation) {
|
|
11
|
+
stateAnimation.destroy();
|
|
12
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
13
|
+
}
|
|
14
|
+
heap = [];
|
|
15
|
+
stateAnimation = new fade_in_state_animation_1.FadeInStateAnimation({ duration: 4 })
|
|
16
|
+
.onStateChange(state => heap.push(state))
|
|
17
|
+
.onValueChange(value => heap.push(value))
|
|
18
|
+
.attachToRoot();
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.describe)('Appearing', () => {
|
|
21
|
+
(0, vitest_1.test)('default values', () => {
|
|
22
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
23
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
24
|
+
value: 0,
|
|
25
|
+
state: undefined,
|
|
26
|
+
queuedState: undefined,
|
|
27
|
+
animationState: 'hidden'
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
(0, vitest_1.test)('initial values', () => {
|
|
31
|
+
stateAnimation.setState('A');
|
|
32
|
+
(0, vitest_1.expect)(heap).toEqual(['A']);
|
|
33
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
34
|
+
value: 0,
|
|
35
|
+
state: 'A',
|
|
36
|
+
queuedState: undefined,
|
|
37
|
+
animationState: 'appearing'
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
(0, vitest_1.test)('animation in the middle', async () => {
|
|
41
|
+
stateAnimation.setState('A');
|
|
42
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
43
|
+
(0, vitest_1.expect)(heap).toEqual(['A', 0.25]);
|
|
44
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
45
|
+
value: 0.25,
|
|
46
|
+
state: 'A',
|
|
47
|
+
queuedState: undefined,
|
|
48
|
+
animationState: 'appearing'
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
(0, vitest_1.test)('animation end', async () => {
|
|
52
|
+
stateAnimation.setState('A');
|
|
53
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
54
|
+
(0, vitest_1.expect)(heap).toEqual(['A', 1]);
|
|
55
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
56
|
+
value: 1,
|
|
57
|
+
state: 'A',
|
|
58
|
+
queuedState: undefined,
|
|
59
|
+
animationState: 'visible'
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
(0, vitest_1.test)('instant once', async () => {
|
|
63
|
+
stateAnimation.setState('A', { instant: true });
|
|
64
|
+
(0, vitest_1.expect)(heap).toEqual(['A', 1]);
|
|
65
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
66
|
+
value: 1,
|
|
67
|
+
state: 'A',
|
|
68
|
+
queuedState: undefined,
|
|
69
|
+
animationState: 'visible'
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
(0, vitest_1.test)('instant twice', async () => {
|
|
73
|
+
stateAnimation.setState('A', { instant: true });
|
|
74
|
+
heap = [];
|
|
75
|
+
stateAnimation.setState('A', { instant: true });
|
|
76
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
77
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
78
|
+
value: 1,
|
|
79
|
+
state: 'A',
|
|
80
|
+
queuedState: undefined,
|
|
81
|
+
animationState: 'visible'
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
(0, vitest_1.describe)('Disappearing', () => {
|
|
86
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
87
|
+
stateAnimation.setState('A', { instant: true });
|
|
88
|
+
heap = [];
|
|
89
|
+
});
|
|
90
|
+
(0, vitest_1.test)('initial values', async () => {
|
|
91
|
+
stateAnimation.setState(undefined);
|
|
92
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
93
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
94
|
+
value: 1,
|
|
95
|
+
state: 'A',
|
|
96
|
+
queuedState: undefined,
|
|
97
|
+
animationState: 'disappearing'
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
(0, vitest_1.test)('animation in the middle', async () => {
|
|
101
|
+
stateAnimation.setState(undefined);
|
|
102
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
103
|
+
(0, vitest_1.expect)(heap).toEqual([0.75]);
|
|
104
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
105
|
+
value: 0.75,
|
|
106
|
+
state: 'A',
|
|
107
|
+
queuedState: undefined,
|
|
108
|
+
animationState: 'disappearing'
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
(0, vitest_1.test)('animation end', async () => {
|
|
112
|
+
stateAnimation.setState(undefined);
|
|
113
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
114
|
+
(0, vitest_1.expect)(heap).toEqual([undefined, 0]);
|
|
115
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
116
|
+
value: 0,
|
|
117
|
+
state: undefined,
|
|
118
|
+
queuedState: undefined,
|
|
119
|
+
animationState: 'hidden'
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
(0, vitest_1.test)('instant', async () => {
|
|
123
|
+
stateAnimation.setState(undefined, { instant: true });
|
|
124
|
+
(0, vitest_1.expect)(heap).toEqual([undefined, 0]);
|
|
125
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
126
|
+
value: 0,
|
|
127
|
+
state: undefined,
|
|
128
|
+
queuedState: undefined,
|
|
129
|
+
animationState: 'hidden'
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
(0, vitest_1.describe)('Cancel appearing', () => {
|
|
134
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
135
|
+
stateAnimation.setState('A');
|
|
136
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
137
|
+
heap = [];
|
|
138
|
+
});
|
|
139
|
+
(0, vitest_1.test)('initial values', () => {
|
|
140
|
+
stateAnimation.setState(undefined);
|
|
141
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
142
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
143
|
+
value: 0.5,
|
|
144
|
+
state: 'A',
|
|
145
|
+
queuedState: undefined,
|
|
146
|
+
animationState: 'disappearing'
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
(0, vitest_1.test)('animation end', async () => {
|
|
150
|
+
stateAnimation.setState(undefined);
|
|
151
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
152
|
+
(0, vitest_1.expect)(heap).toEqual([undefined, 0]);
|
|
153
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
154
|
+
value: 0,
|
|
155
|
+
state: undefined,
|
|
156
|
+
queuedState: undefined,
|
|
157
|
+
animationState: 'hidden'
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
(0, vitest_1.test)('instant', async () => {
|
|
161
|
+
stateAnimation.setState(undefined, { instant: true });
|
|
162
|
+
(0, vitest_1.expect)(heap).toEqual([undefined, 0]);
|
|
163
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
164
|
+
value: 0,
|
|
165
|
+
state: undefined,
|
|
166
|
+
queuedState: undefined,
|
|
167
|
+
animationState: 'hidden'
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
(0, vitest_1.describe)('Cancel disappearing', () => {
|
|
172
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
173
|
+
stateAnimation.setState('A');
|
|
174
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
175
|
+
stateAnimation.setState(undefined);
|
|
176
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
177
|
+
heap = [];
|
|
178
|
+
});
|
|
179
|
+
(0, vitest_1.test)('initial values', () => {
|
|
180
|
+
stateAnimation.setState('A');
|
|
181
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
182
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
183
|
+
value: 0.5,
|
|
184
|
+
state: 'A',
|
|
185
|
+
queuedState: undefined,
|
|
186
|
+
animationState: 'appearing'
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
(0, vitest_1.test)('animation end', async () => {
|
|
190
|
+
stateAnimation.setState('A');
|
|
191
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
192
|
+
(0, vitest_1.expect)(heap).toEqual([1]);
|
|
193
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
194
|
+
value: 1,
|
|
195
|
+
state: 'A',
|
|
196
|
+
queuedState: undefined,
|
|
197
|
+
animationState: 'visible'
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
(0, vitest_1.test)('instant', async () => {
|
|
201
|
+
stateAnimation.setState('A', { instant: true });
|
|
202
|
+
(0, vitest_1.expect)(heap).toEqual([1]);
|
|
203
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
204
|
+
value: 1,
|
|
205
|
+
state: 'A',
|
|
206
|
+
queuedState: undefined,
|
|
207
|
+
animationState: 'visible'
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
(0, vitest_1.test)('callbacks', async () => {
|
|
211
|
+
let stateChangeCalledWith = 'unset';
|
|
212
|
+
let valueChangeCalledWith = 'unset';
|
|
213
|
+
stateAnimation
|
|
214
|
+
.onStateChange(state => {
|
|
215
|
+
stateChangeCalledWith = state;
|
|
216
|
+
})
|
|
217
|
+
.onValueChange(value => {
|
|
218
|
+
valueChangeCalledWith = value;
|
|
219
|
+
});
|
|
220
|
+
stateAnimation.setState('A');
|
|
221
|
+
(0, vitest_1.expect)(stateChangeCalledWith).toBe('unset');
|
|
222
|
+
(0, vitest_1.expect)(valueChangeCalledWith).toBe('unset');
|
|
223
|
+
stateChangeCalledWith = 'unset';
|
|
224
|
+
valueChangeCalledWith = 'unset';
|
|
225
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
226
|
+
(0, vitest_1.expect)(stateChangeCalledWith).toBe('unset');
|
|
227
|
+
(0, vitest_1.expect)(valueChangeCalledWith).toBe(0.75);
|
|
228
|
+
stateChangeCalledWith = 'unset';
|
|
229
|
+
valueChangeCalledWith = 'unset';
|
|
230
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
231
|
+
(0, vitest_1.expect)(stateChangeCalledWith).toBe('unset');
|
|
232
|
+
(0, vitest_1.expect)(valueChangeCalledWith).toBe(1);
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
(0, vitest_1.describe)('Disappear to change', () => {
|
|
236
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
237
|
+
stateAnimation.setState('A');
|
|
238
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
239
|
+
heap = [];
|
|
240
|
+
});
|
|
241
|
+
(0, vitest_1.test)('initial values', async () => {
|
|
242
|
+
stateAnimation.setState('B');
|
|
243
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
244
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
245
|
+
value: 1,
|
|
246
|
+
state: 'A',
|
|
247
|
+
queuedState: 'B',
|
|
248
|
+
animationState: 'disappearToChange'
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
(0, vitest_1.test)('dissapear animation in the middle', async () => {
|
|
252
|
+
stateAnimation.setState('B');
|
|
253
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
254
|
+
(0, vitest_1.expect)(heap).toEqual([0.75]);
|
|
255
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
256
|
+
value: 0.75,
|
|
257
|
+
state: 'A',
|
|
258
|
+
queuedState: 'B',
|
|
259
|
+
animationState: 'disappearToChange'
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
(0, vitest_1.test)('dissapear animation end', async () => {
|
|
263
|
+
stateAnimation.setState('B');
|
|
264
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
265
|
+
(0, vitest_1.expect)(heap).toEqual(['B', 0]);
|
|
266
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
267
|
+
value: 0,
|
|
268
|
+
state: 'B',
|
|
269
|
+
queuedState: undefined,
|
|
270
|
+
animationState: 'appearing'
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
(0, vitest_1.test)('appear animation in the middle', async () => {
|
|
274
|
+
stateAnimation.setState('B');
|
|
275
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
276
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
277
|
+
(0, vitest_1.expect)(heap).toEqual(['B', 0, 0.25]);
|
|
278
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
279
|
+
value: 0.25,
|
|
280
|
+
state: 'B',
|
|
281
|
+
queuedState: undefined,
|
|
282
|
+
animationState: 'appearing'
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
(0, vitest_1.test)('appear animation end', async () => {
|
|
286
|
+
stateAnimation.setState('B');
|
|
287
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
288
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
289
|
+
(0, vitest_1.expect)(heap).toEqual(['B', 0, 1]);
|
|
290
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
291
|
+
value: 1,
|
|
292
|
+
state: 'B',
|
|
293
|
+
queuedState: undefined,
|
|
294
|
+
animationState: 'visible'
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
(0, vitest_1.test)('returning back to the original state', async () => {
|
|
298
|
+
stateAnimation.setState('B');
|
|
299
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
300
|
+
stateAnimation.setState('A');
|
|
301
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
302
|
+
(0, vitest_1.expect)(heap).toEqual([0.75, 1]);
|
|
303
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
304
|
+
value: 1,
|
|
305
|
+
state: 'A',
|
|
306
|
+
queuedState: undefined,
|
|
307
|
+
animationState: 'visible'
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
(0, vitest_1.test)('edge case, changing the decition back at the moment of re-appearing', async () => {
|
|
311
|
+
stateAnimation.setState('B');
|
|
312
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
313
|
+
stateAnimation.setState('A');
|
|
314
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
315
|
+
(0, vitest_1.expect)(heap).toEqual(['B', 0, 'A', 0.25]);
|
|
316
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
317
|
+
value: 0.25,
|
|
318
|
+
state: 'A',
|
|
319
|
+
queuedState: undefined,
|
|
320
|
+
animationState: 'appearing'
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
(0, vitest_1.test)('instant', async () => {
|
|
324
|
+
stateAnimation.setState('B', { instant: true });
|
|
325
|
+
(0, vitest_1.expect)(heap).toEqual(['B', 1]);
|
|
326
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
327
|
+
value: 1,
|
|
328
|
+
state: 'B',
|
|
329
|
+
queuedState: undefined,
|
|
330
|
+
animationState: 'visible'
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
(0, vitest_1.describe)('Nullish State', () => {
|
|
335
|
+
(0, vitest_1.test)('initial values', () => {
|
|
336
|
+
stateAnimation.setState('');
|
|
337
|
+
(0, vitest_1.expect)(heap).toEqual(['']);
|
|
338
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
339
|
+
value: 0,
|
|
340
|
+
state: '',
|
|
341
|
+
queuedState: undefined,
|
|
342
|
+
animationState: 'appearing'
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
(0, vitest_1.test)('instant', () => {
|
|
346
|
+
stateAnimation.setState('', { instant: true });
|
|
347
|
+
// expect(heap).toEqual(['', 0]);
|
|
348
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
349
|
+
value: 1,
|
|
350
|
+
state: '',
|
|
351
|
+
queuedState: undefined,
|
|
352
|
+
animationState: 'visible'
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
(0, vitest_1.test)('Cancel appearing', async () => {
|
|
356
|
+
stateAnimation.setState('A');
|
|
357
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
358
|
+
heap = [];
|
|
359
|
+
stateAnimation.setState('');
|
|
360
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
361
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
362
|
+
value: 0.5,
|
|
363
|
+
state: 'A',
|
|
364
|
+
queuedState: '',
|
|
365
|
+
animationState: 'disappearToChange'
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
(0, vitest_1.test)('Cancel disappearing', async () => {
|
|
369
|
+
stateAnimation.setState('A');
|
|
370
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
371
|
+
stateAnimation.setState(undefined);
|
|
372
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
373
|
+
heap = [];
|
|
374
|
+
stateAnimation.setState('');
|
|
375
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
376
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
377
|
+
value: 0.5,
|
|
378
|
+
state: 'A',
|
|
379
|
+
queuedState: '',
|
|
380
|
+
animationState: 'disappearToChange'
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
(0, vitest_1.test)('Disappear to change', () => {
|
|
384
|
+
stateAnimation.setState('A', { instant: true });
|
|
385
|
+
heap = [];
|
|
386
|
+
stateAnimation.setState('');
|
|
387
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
388
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
389
|
+
value: 1,
|
|
390
|
+
state: 'A',
|
|
391
|
+
queuedState: '',
|
|
392
|
+
animationState: 'disappearToChange'
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
(0, vitest_1.test)('Change disappear to change', async () => {
|
|
396
|
+
stateAnimation.setState('A', { instant: true });
|
|
397
|
+
stateAnimation.setState('B');
|
|
398
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
399
|
+
heap = [];
|
|
400
|
+
stateAnimation.setState('');
|
|
401
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
402
|
+
(0, vitest_1.expect)(stateAnimation.currentState).toEqual({
|
|
403
|
+
value: 0.5,
|
|
404
|
+
state: 'A',
|
|
405
|
+
queuedState: '',
|
|
406
|
+
animationState: 'disappearToChange'
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
(0, vitest_1.describe)('Error Cases:', () => {
|
|
411
|
+
(0, vitest_1.test)('completion on hidden state', async () => {
|
|
412
|
+
let consoleErrorSpy = vitest_1.vi.spyOn(console, 'error').mockImplementation(() => { });
|
|
413
|
+
stateAnimation.setState('A');
|
|
414
|
+
stateAnimation.setState(undefined);
|
|
415
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
416
|
+
(0, vitest_1.expect)(consoleErrorSpy).not.toBeCalled();
|
|
417
|
+
consoleErrorSpy.mockRestore();
|
|
418
|
+
});
|
|
419
|
+
(0, vitest_1.test)('completion on visible state', async () => {
|
|
420
|
+
let consoleErrorSpy = vitest_1.vi.spyOn(console, 'error').mockImplementation(() => { });
|
|
421
|
+
stateAnimation.setState('A');
|
|
422
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
423
|
+
stateAnimation.setState(undefined);
|
|
424
|
+
stateAnimation.setState('A');
|
|
425
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
426
|
+
(0, vitest_1.expect)(consoleErrorSpy).not.toBeCalled();
|
|
427
|
+
consoleErrorSpy.mockRestore();
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
//# sourceMappingURL=fade-in-state-animation.test.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Vector } from 'helpers-lib';
|
|
2
|
+
import { Container } from '../../../../pixi/display-object/container';
|
|
3
|
+
import { AnimatorAnimation } from '../../animations';
|
|
4
|
+
export interface ScrollInContentOptions {
|
|
5
|
+
readonly duration: number;
|
|
6
|
+
readonly animation: AnimatorAnimation;
|
|
7
|
+
readonly size: Vector;
|
|
8
|
+
readonly margin: number;
|
|
9
|
+
readonly direction: 'horizontal' | 'vertical';
|
|
10
|
+
}
|
|
11
|
+
export declare class SlideInContentByIndex extends Container {
|
|
12
|
+
private createFunction;
|
|
13
|
+
private options;
|
|
14
|
+
private directionProperty;
|
|
15
|
+
private stateAnimation;
|
|
16
|
+
private contents;
|
|
17
|
+
constructor(createFunction: (value: {
|
|
18
|
+
index: number;
|
|
19
|
+
container: Container;
|
|
20
|
+
}) => void, partialOptions?: Partial<ScrollInContentOptions>);
|
|
21
|
+
setIndex(index: number, options?: {
|
|
22
|
+
instant?: boolean;
|
|
23
|
+
}): this;
|
|
24
|
+
private createMask;
|
|
25
|
+
}
|
|
26
|
+
export declare class SlideInContent<T> extends SlideInContentByIndex {
|
|
27
|
+
readonly itemToIndex: Map<T, number>;
|
|
28
|
+
readonly indexToItem: Map<number, T>;
|
|
29
|
+
constructor(items: T[], createFunction: (value: {
|
|
30
|
+
index: number;
|
|
31
|
+
item: T;
|
|
32
|
+
container: Container;
|
|
33
|
+
}) => void, partialOptions?: Partial<ScrollInContentOptions>);
|
|
34
|
+
setItem(item: T, options?: {
|
|
35
|
+
instant?: boolean;
|
|
36
|
+
}): this;
|
|
37
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SlideInContent = exports.SlideInContentByIndex = void 0;
|
|
4
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
5
|
+
const scroll_mask_ui_1 = require("../../../../pixi/components/scroll-mask.ui");
|
|
6
|
+
const container_1 = require("../../../../pixi/display-object/container");
|
|
7
|
+
const animations_1 = require("../../animations");
|
|
8
|
+
const slide_state_animation_1 = require("./slide-state-animation");
|
|
9
|
+
class SlideInContentByIndex extends container_1.Container {
|
|
10
|
+
constructor(createFunction, partialOptions) {
|
|
11
|
+
super();
|
|
12
|
+
this.createFunction = createFunction;
|
|
13
|
+
this.directionProperty = 'x';
|
|
14
|
+
this.contents = new Map();
|
|
15
|
+
this.options = {
|
|
16
|
+
duration: 300,
|
|
17
|
+
animation: animations_1.Animations.easeInOutCubic,
|
|
18
|
+
size: new helpers_lib_1.Vector(500, 500),
|
|
19
|
+
margin: 20,
|
|
20
|
+
direction: 'horizontal',
|
|
21
|
+
...partialOptions
|
|
22
|
+
};
|
|
23
|
+
let fullSize = this.options.direction === 'horizontal'
|
|
24
|
+
? new helpers_lib_1.Vector(this.options.size.x + this.options.margin * 2, this.options.size.y)
|
|
25
|
+
: new helpers_lib_1.Vector(this.options.size.x, this.options.size.y + this.options.margin * 2);
|
|
26
|
+
let wrapper = new container_1.Container()
|
|
27
|
+
.setPosition(this.options.direction === 'horizontal' ? new helpers_lib_1.Vector(-this.options.margin, 0) : new helpers_lib_1.Vector(0, -this.options.margin), { round: false })
|
|
28
|
+
.displayParent(this)
|
|
29
|
+
.attach(this);
|
|
30
|
+
this.createMask(fullSize, this.options.margin, this.options.direction, wrapper);
|
|
31
|
+
this.directionProperty = this.options.direction === 'horizontal' ? 'x' : 'y';
|
|
32
|
+
this.stateAnimation = new slide_state_animation_1.SlideStateAnimation({
|
|
33
|
+
duration: this.options.duration,
|
|
34
|
+
animation: this.options.animation
|
|
35
|
+
})
|
|
36
|
+
.onStateChange((state, index) => {
|
|
37
|
+
if (state === slide_state_animation_1.SlideStateAnimationState.appear) {
|
|
38
|
+
let container = new container_1.Container().displayParent(this).attach(this);
|
|
39
|
+
this.contents.set(index, container);
|
|
40
|
+
this.createFunction({ index, container });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
let container = this.contents.get(index);
|
|
44
|
+
if (container) {
|
|
45
|
+
container.destroy();
|
|
46
|
+
this.contents.delete(index);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
.onValueChange((value, index) => {
|
|
51
|
+
let container = this.contents.get(index);
|
|
52
|
+
if (container) {
|
|
53
|
+
let vec = { x: 0, y: 0 };
|
|
54
|
+
vec[this.directionProperty] = fullSize[this.directionProperty] * value + this.options.margin;
|
|
55
|
+
container.setPosition(helpers_lib_1.Vector.fromVec2(vec), { round: false });
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
.attach(this);
|
|
59
|
+
this.addChildTo = wrapper;
|
|
60
|
+
}
|
|
61
|
+
setIndex(index, options) {
|
|
62
|
+
this.stateAnimation.setIndex(index, options);
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
createMask(size, padding, direction, container) {
|
|
66
|
+
new scroll_mask_ui_1.ScrollMaskUI(container, new helpers_lib_1.Vector(size.x, size.y), padding, direction).attach(this);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.SlideInContentByIndex = SlideInContentByIndex;
|
|
70
|
+
class SlideInContent extends SlideInContentByIndex {
|
|
71
|
+
constructor(items, createFunction, partialOptions) {
|
|
72
|
+
super((value) => {
|
|
73
|
+
let item = this.indexToItem.get(value.index);
|
|
74
|
+
if (item) {
|
|
75
|
+
createFunction({ index: value.index, item, container: value.container });
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
throw new Error(`SlideInContent: The item with index '${value.index}' is not part of the items list`);
|
|
79
|
+
}
|
|
80
|
+
}, partialOptions);
|
|
81
|
+
this.itemToIndex = new Map();
|
|
82
|
+
this.indexToItem = new Map();
|
|
83
|
+
items.forEach((item, index) => {
|
|
84
|
+
this.itemToIndex.set(item, index);
|
|
85
|
+
this.indexToItem.set(index, item);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
setItem(item, options) {
|
|
89
|
+
let index = this.itemToIndex.get(item);
|
|
90
|
+
if (index !== undefined) {
|
|
91
|
+
this.setIndex(index, options);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
throw new Error(`SlideInContent: The item '${item}' is not part of the items list`);
|
|
95
|
+
}
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.SlideInContent = SlideInContent;
|
|
100
|
+
//# sourceMappingURL=slide-in-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const slide_in_content_1 = require("./slide-in-content");
|
|
5
|
+
(0, vitest_1.describe)('Slide In Content', () => {
|
|
6
|
+
(0, vitest_1.test)('should exist', () => {
|
|
7
|
+
(0, vitest_1.expect)(slide_in_content_1.SlideInContent).toBeDefined();
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=slide-in-content.test.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Attachable } from 'actions-lib';
|
|
2
|
+
import { StateAnimationOptions } from '../state-animation';
|
|
3
|
+
export declare enum SlideStateAnimationState {
|
|
4
|
+
appear = "appear",
|
|
5
|
+
disappear = "disappear"
|
|
6
|
+
}
|
|
7
|
+
export declare class SlideStateAnimation extends Attachable {
|
|
8
|
+
private stateAnimation;
|
|
9
|
+
private options;
|
|
10
|
+
private index;
|
|
11
|
+
private nextIndex;
|
|
12
|
+
private animationState;
|
|
13
|
+
constructor(partialOptions?: Partial<StateAnimationOptions>);
|
|
14
|
+
setIndex(index: number, options?: {
|
|
15
|
+
instant?: boolean;
|
|
16
|
+
}): void;
|
|
17
|
+
private handleStateChange;
|
|
18
|
+
private handleValueChange;
|
|
19
|
+
private handleNewTarget;
|
|
20
|
+
private onStateChangeAction;
|
|
21
|
+
private onValueChangeAction;
|
|
22
|
+
onStateChange(callback: (state: SlideStateAnimationState, index: number) => void): this;
|
|
23
|
+
onValueChange(callback: (value: number, index: number) => void): this;
|
|
24
|
+
}
|