bard-legends-framework 0.10.9 → 0.11.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/game-entities/controller/controller.d.ts +0 -1
- package/dist/game-entities/controller/controller.js +1 -0
- package/dist/game-entities/controller/controller.test.js +2 -2
- package/dist/game-entities/entity/entity.d.ts +8 -6
- package/dist/game-entities/entity/entity.js +5 -7
- package/dist/game-entities/entity/entity.test.js +40 -134
- package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +6 -9
- package/dist/game-entities/entity/helpers/entity-store.helper.js +22 -57
- package/dist/game-entities/entity/helpers/entity-store.helper.test.d.ts +1 -0
- package/dist/game-entities/entity/helpers/entity-store.helper.test.js +136 -0
- package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +1 -1
- package/dist/game-entities/entity/helpers/entity-views.helper.js +5 -3
- package/dist/game-entities/entity/singleton-entity.d.ts +3 -3
- package/dist/game-entities/entity/singleton-entity.js +1 -1
- package/dist/game-entities/entity/singleton-entity.test.js +2 -29
- package/dist/game-entities/index.d.ts +1 -3
- package/dist/game-entities/index.js +3 -7
- package/dist/game-entities/scene/scene.d.ts +3 -3
- package/dist/game-entities/scene/scene.js +31 -25
- package/dist/game-entities/scene/scene.test.js +4 -32
- package/dist/game-entities/service/service.js +5 -3
- package/dist/game-entities/service/service.test.js +2 -28
- package/dist/game-entities/unit-test.helper.d.ts +5 -0
- package/dist/game-entities/unit-test.helper.js +14 -0
- package/dist/game-entities/update-cycle.d.ts +15 -4
- package/dist/game-entities/update-cycle.js +14 -9
- package/dist/game-entities/view/view.d.ts +5 -6
- package/dist/game-entities/view/view.js +5 -17
- package/dist/game-entities/view/view.test.js +36 -244
- package/dist/physics/entity-types/immovable-physics-entity.d.ts +1 -3
- package/dist/physics/entity-types/immovable-physics-entity.js +1 -3
- package/dist/physics/entity-types/movable-entity.js +4 -4
- package/dist/physics/entity-types/movable-physics-entity.d.ts +2 -3
- package/dist/physics/entity-types/movable-physics-entity.js +5 -6
- package/dist/physics/entity-types/physics-entity.d.ts +2 -1
- package/dist/physics/entity-types/physics-entity.js +3 -2
- package/dist/physics/interfaces.d.ts +1 -1
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +3 -3
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +1 -1
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +3 -3
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +1 -1
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +2 -2
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +17 -7
- package/dist/physics/module//360/237/247/212entities/physics-world.entity.js +2 -2
- package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +2 -1
- package/dist/pixi/components/mouse-wheel-listener.ui.js +4 -3
- package/dist/pixi/display-object/container-attributes.d.ts +2 -3
- package/dist/pixi/display-object/container-attributes.js +2 -3
- package/dist/pixi/display-object/container.d.ts +0 -3
- package/dist/pixi/display-object/container.js +0 -10
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +5 -3
- package/dist/pixi/game.d.ts +6 -2
- package/dist/pixi/game.js +14 -5
- package/dist/pixi/modules/CAMERA//360/237/247/212entities/camera.entity.js +4 -4
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +1 -1
- package/dist/pixi/services/keyboard/keyboard.d.ts +4 -2
- package/dist/pixi/services/keyboard/keyboard.js +6 -4
- package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +2 -1
- package/dist/pixi/services/mouse/mouse-target-focus.service.js +6 -5
- package/dist/pixi/services/mouse/mouse.service.d.ts +15 -5
- package/dist/pixi/services/mouse/mouse.service.js +38 -18
- package/dist/utilities/animator/animating-content/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/animating-content/fade-in-content.js +37 -0
- package/dist/utilities/animator/animating-content/slide-in-content.d.ts +37 -0
- package/dist/utilities/animator/animating-content/slide-in-content.js +99 -0
- package/dist/utilities/animator/animations.d.ts +37 -0
- package/dist/utilities/animator/animations.js +88 -0
- package/dist/utilities/animator/animator.d.ts +61 -0
- package/dist/utilities/animator/animator.js +315 -0
- package/dist/utilities/animator/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator.test.js +867 -0
- package/dist/utilities/animator/index.d.ts +7 -0
- package/dist/utilities/animator/index.js +24 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.js +130 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.js +301 -0
- package/dist/utilities/animator/state-animation/state-animation.d.ts +33 -0
- package/dist/utilities/animator/state-animation/state-animation.js +146 -0
- package/dist/utilities/animator/state-animation/state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/state-animation.test.js +335 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.d.ts +32 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.js +168 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +431 -0
- package/dist/utilities/data-structures/vector-set/vector-set.d.ts +7 -0
- package/dist/utilities/data-structures/vector-set/vector-set.js +26 -0
- package/dist/utilities/delta-time/delta-time.d.ts +3 -0
- package/dist/utilities/delta-time/delta-time.js +10 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +6 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +55 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.js +100 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.d.ts +8 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.js +98 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +155 -0
- package/dist/utilities/grid-algorithms/position-to-grid-position-converter.d.ts +6 -0
- package/dist/utilities/grid-algorithms/position-to-grid-position-converter.js +17 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +18 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +129 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +254 -0
- package/dist/utilities/index.d.ts +6 -6
- package/dist/utilities/index.js +6 -6
- package/package.json +3 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './animating-content/fade-in-content';
|
|
2
|
+
export * from './animating-content/slide-in-content';
|
|
3
|
+
export * from './animations';
|
|
4
|
+
export * from './animator';
|
|
5
|
+
export * from './state-animation/slide-state-animation';
|
|
6
|
+
export * from './state-animation/state-animation';
|
|
7
|
+
export * from './state-animation/visit-disappear-state-animation';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./animating-content/fade-in-content"), exports);
|
|
18
|
+
__exportStar(require("./animating-content/slide-in-content"), exports);
|
|
19
|
+
__exportStar(require("./animations"), exports);
|
|
20
|
+
__exportStar(require("./animator"), exports);
|
|
21
|
+
__exportStar(require("./state-animation/slide-state-animation"), exports);
|
|
22
|
+
__exportStar(require("./state-animation/state-animation"), exports);
|
|
23
|
+
__exportStar(require("./state-animation/visit-disappear-state-animation"), exports);
|
|
24
|
+
//# sourceMappingURL=index.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
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SlideStateAnimation = exports.SlideStateAnimationState = void 0;
|
|
4
|
+
const actions_lib_1 = require("actions-lib");
|
|
5
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
6
|
+
const animations_1 = require("../animations");
|
|
7
|
+
const state_animation_1 = require("./state-animation");
|
|
8
|
+
var SlideStateAnimationState;
|
|
9
|
+
(function (SlideStateAnimationState) {
|
|
10
|
+
SlideStateAnimationState["appear"] = "appear";
|
|
11
|
+
SlideStateAnimationState["disappear"] = "disappear";
|
|
12
|
+
})(SlideStateAnimationState || (exports.SlideStateAnimationState = SlideStateAnimationState = {}));
|
|
13
|
+
class SlideStateAnimation extends actions_lib_1.Attachable {
|
|
14
|
+
constructor(partialOptions) {
|
|
15
|
+
super();
|
|
16
|
+
this.animationState = 'idle';
|
|
17
|
+
this.onStateChangeAction = new actions_lib_1.Action();
|
|
18
|
+
this.onValueChangeAction = new actions_lib_1.Action();
|
|
19
|
+
this.options = { duration: 500, animation: new animations_1.AnimationEaseInOutCubic(), ...partialOptions };
|
|
20
|
+
this.stateAnimation = new state_animation_1.StateAnimation({
|
|
21
|
+
duration: this.options.duration,
|
|
22
|
+
animation: this.options.animation
|
|
23
|
+
})
|
|
24
|
+
.onStateChange((state, nextState) => this.handleStateChange(state, nextState))
|
|
25
|
+
.onValueChange(value => this.handleValueChange(value))
|
|
26
|
+
.attach(this);
|
|
27
|
+
}
|
|
28
|
+
setIndex(index, options) {
|
|
29
|
+
if (!helpers_lib_1.Comparator.isInteger(index)) {
|
|
30
|
+
throw new Error('SlideStateAnimation: index must be an integer!');
|
|
31
|
+
}
|
|
32
|
+
if (this.index === undefined) {
|
|
33
|
+
this.index = index;
|
|
34
|
+
this.onStateChangeAction.trigger({ state: SlideStateAnimationState.appear, index });
|
|
35
|
+
this.stateAnimation.setState(index, options);
|
|
36
|
+
}
|
|
37
|
+
else if (this.index !== index) {
|
|
38
|
+
if (this.nextIndex !== index) {
|
|
39
|
+
if (this.animationState === 'idle') {
|
|
40
|
+
this.animationState = index > this.index ? 'transitionForward' : 'transitionBackward';
|
|
41
|
+
this.nextIndex = index;
|
|
42
|
+
this.onStateChangeAction.trigger({ state: SlideStateAnimationState.appear, index: this.nextIndex });
|
|
43
|
+
this.stateAnimation.setState(index, options);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.stateAnimation.setState(index, options);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if (this.animationState === 'reverting' && this.nextIndex === index) {
|
|
50
|
+
this.animationState = index > this.index ? 'transitionForward' : 'transitionBackward';
|
|
51
|
+
this.stateAnimation.setState(index, options);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (this.animationState === 'transitionForward' || this.animationState === 'transitionBackward') {
|
|
55
|
+
this.animationState = 'reverting';
|
|
56
|
+
this.stateAnimation.setState(index, options);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
handleStateChange(state, nextState) {
|
|
60
|
+
if (this.index !== undefined && this.index !== state && this.index !== nextState) {
|
|
61
|
+
this.onStateChangeAction.trigger({ state: SlideStateAnimationState.disappear, index: this.index });
|
|
62
|
+
}
|
|
63
|
+
if (this.nextIndex !== undefined && this.nextIndex !== state && this.nextIndex !== nextState) {
|
|
64
|
+
this.onStateChangeAction.trigger({ state: SlideStateAnimationState.disappear, index: this.nextIndex });
|
|
65
|
+
}
|
|
66
|
+
if (nextState !== undefined && nextState !== this.index && nextState !== this.nextIndex) {
|
|
67
|
+
this.onStateChangeAction.trigger({ state: SlideStateAnimationState.appear, index: nextState });
|
|
68
|
+
}
|
|
69
|
+
switch (this.animationState) {
|
|
70
|
+
case 'transitionForward':
|
|
71
|
+
case 'transitionBackward':
|
|
72
|
+
if (nextState === undefined) {
|
|
73
|
+
this.animationState = 'idle';
|
|
74
|
+
this.index = this.nextIndex;
|
|
75
|
+
this.nextIndex = undefined;
|
|
76
|
+
}
|
|
77
|
+
else if (this.index !== state) {
|
|
78
|
+
this.handleNewTarget(state, nextState);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case 'reverting':
|
|
82
|
+
if (nextState === undefined) {
|
|
83
|
+
this.animationState = 'idle';
|
|
84
|
+
this.nextIndex = undefined;
|
|
85
|
+
}
|
|
86
|
+
else if (this.index !== nextState) {
|
|
87
|
+
this.handleNewTarget(state, nextState);
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
handleValueChange(value) {
|
|
93
|
+
let directionMultiplier = 1;
|
|
94
|
+
if (this.animationState === 'transitionBackward' ||
|
|
95
|
+
(this.animationState === 'reverting' &&
|
|
96
|
+
this.index !== undefined &&
|
|
97
|
+
this.nextIndex !== undefined &&
|
|
98
|
+
this.index > this.nextIndex)) {
|
|
99
|
+
directionMultiplier = -1;
|
|
100
|
+
}
|
|
101
|
+
if (this.animationState === 'idle' || value !== 0) {
|
|
102
|
+
this.onValueChangeAction.trigger({
|
|
103
|
+
value: helpers_lib_1.NumberHelper.ensurePositiveZero(-directionMultiplier * value),
|
|
104
|
+
index: this.index
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (this.nextIndex !== undefined) {
|
|
108
|
+
this.onValueChangeAction.trigger({
|
|
109
|
+
value: helpers_lib_1.NumberHelper.ensurePositiveZero(directionMultiplier * (1 - value)),
|
|
110
|
+
index: this.nextIndex
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
handleNewTarget(state, nextState) {
|
|
115
|
+
this.index = state;
|
|
116
|
+
this.nextIndex = nextState;
|
|
117
|
+
this.onValueChangeAction.trigger({ value: 0, index: this.index });
|
|
118
|
+
this.animationState = this.index < this.nextIndex ? 'transitionForward' : 'transitionBackward';
|
|
119
|
+
}
|
|
120
|
+
onStateChange(callback) {
|
|
121
|
+
this.onStateChangeAction.subscribe(value => callback(value.state, value.index)).attach(this);
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
onValueChange(callback) {
|
|
125
|
+
this.onValueChangeAction.subscribe(value => callback(value.value, value.index)).attach(this);
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.SlideStateAnimation = SlideStateAnimation;
|
|
130
|
+
//# sourceMappingURL=slide-state-animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,301 @@
|
|
|
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 animations_1 = require("../animations");
|
|
6
|
+
const slide_state_animation_1 = require("./slide-state-animation");
|
|
7
|
+
(0, vitest_1.describe)('SlideStateAnimation', () => {
|
|
8
|
+
let stateAnimation;
|
|
9
|
+
let heap = [];
|
|
10
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
11
|
+
if (stateAnimation) {
|
|
12
|
+
stateAnimation.destroy();
|
|
13
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
14
|
+
}
|
|
15
|
+
heap = [];
|
|
16
|
+
stateAnimation = new slide_state_animation_1.SlideStateAnimation({ duration: 4, animation: new animations_1.AnimationLineer() })
|
|
17
|
+
.onStateChange((state, index) => heap.push({ state, index }))
|
|
18
|
+
.onValueChange((value, index) => heap.push({ value, index }))
|
|
19
|
+
.attachToRoot();
|
|
20
|
+
});
|
|
21
|
+
(0, vitest_1.describe)('Creation', () => {
|
|
22
|
+
(0, vitest_1.test)('initial values', () => {
|
|
23
|
+
(0, vitest_1.expect)(stateAnimation).toBeDefined();
|
|
24
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
25
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('idle');
|
|
26
|
+
});
|
|
27
|
+
(0, vitest_1.test)('initial state default', () => {
|
|
28
|
+
stateAnimation.setIndex(0);
|
|
29
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
30
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.appear, index: 0 },
|
|
31
|
+
{ value: 0, index: 0 }
|
|
32
|
+
]);
|
|
33
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('idle');
|
|
34
|
+
});
|
|
35
|
+
(0, vitest_1.test)('initial state instant', () => {
|
|
36
|
+
stateAnimation.setIndex(0, { instant: true });
|
|
37
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
38
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.appear, index: 0 },
|
|
39
|
+
{ value: 0, index: 0 }
|
|
40
|
+
]);
|
|
41
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('idle');
|
|
42
|
+
});
|
|
43
|
+
(0, vitest_1.test)('setting same index', () => {
|
|
44
|
+
stateAnimation.setIndex(0);
|
|
45
|
+
heap = [];
|
|
46
|
+
stateAnimation.setIndex(0);
|
|
47
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
48
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('idle');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
(0, vitest_1.describe)('Slide Next', () => {
|
|
52
|
+
(0, vitest_1.beforeEach)(() => {
|
|
53
|
+
stateAnimation.setIndex(0);
|
|
54
|
+
heap = [];
|
|
55
|
+
stateAnimation.setIndex(1);
|
|
56
|
+
});
|
|
57
|
+
(0, vitest_1.test)('initial state', () => {
|
|
58
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
59
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.appear, index: 1 },
|
|
60
|
+
{ value: 1, index: 1 }
|
|
61
|
+
]);
|
|
62
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
63
|
+
});
|
|
64
|
+
(0, vitest_1.test)('during the animation', async () => {
|
|
65
|
+
heap = [];
|
|
66
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
67
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
68
|
+
{ value: -0.25, index: 0 },
|
|
69
|
+
{ value: 0.75, index: 1 }
|
|
70
|
+
]);
|
|
71
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
72
|
+
});
|
|
73
|
+
(0, vitest_1.test)('end of the animation', async () => {
|
|
74
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
75
|
+
heap = [];
|
|
76
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(3);
|
|
77
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
78
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.disappear, index: 0 },
|
|
79
|
+
{ value: 0, index: 1 }
|
|
80
|
+
]);
|
|
81
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('idle');
|
|
82
|
+
});
|
|
83
|
+
(0, vitest_1.test)('animating again', async () => {
|
|
84
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
85
|
+
heap = [];
|
|
86
|
+
stateAnimation.setIndex(2);
|
|
87
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
88
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.appear, index: 2 },
|
|
89
|
+
{ value: 1, index: 2 }
|
|
90
|
+
]);
|
|
91
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
92
|
+
});
|
|
93
|
+
(0, vitest_1.test)('setting same index', async () => {
|
|
94
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
95
|
+
heap = [];
|
|
96
|
+
stateAnimation.setIndex(1);
|
|
97
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
98
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
(0, vitest_1.describe)('Slide Previous', () => {
|
|
102
|
+
(0, vitest_1.beforeEach)(() => {
|
|
103
|
+
stateAnimation.setIndex(1);
|
|
104
|
+
heap = [];
|
|
105
|
+
stateAnimation.setIndex(0);
|
|
106
|
+
});
|
|
107
|
+
(0, vitest_1.test)('initial state', () => {
|
|
108
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
109
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.appear, index: 0 },
|
|
110
|
+
{ value: -1, index: 0 }
|
|
111
|
+
]);
|
|
112
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
113
|
+
});
|
|
114
|
+
(0, vitest_1.test)('during the animation', async () => {
|
|
115
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
116
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
117
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.appear, index: 0 },
|
|
118
|
+
{ value: -1, index: 0 },
|
|
119
|
+
{ value: 0.25, index: 1 },
|
|
120
|
+
{ value: -0.75, index: 0 }
|
|
121
|
+
]);
|
|
122
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
123
|
+
});
|
|
124
|
+
(0, vitest_1.test)('end of the animation', async () => {
|
|
125
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
126
|
+
heap = [];
|
|
127
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(3);
|
|
128
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
129
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.disappear, index: 1 },
|
|
130
|
+
{ value: 0, index: 0 }
|
|
131
|
+
]);
|
|
132
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('idle');
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
(0, vitest_1.describe)('Reverting', () => {
|
|
136
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
137
|
+
stateAnimation.setIndex(0);
|
|
138
|
+
});
|
|
139
|
+
(0, vitest_1.test)('forward reverting', async () => {
|
|
140
|
+
stateAnimation.setIndex(1);
|
|
141
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
142
|
+
heap = [];
|
|
143
|
+
stateAnimation.setIndex(0);
|
|
144
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('reverting');
|
|
145
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
146
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
147
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('reverting');
|
|
148
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
149
|
+
{ value: -0.25, index: 0 },
|
|
150
|
+
{ value: 0.75, index: 1 }
|
|
151
|
+
]);
|
|
152
|
+
heap = [];
|
|
153
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
154
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('idle');
|
|
155
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
156
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.disappear, index: 1 },
|
|
157
|
+
{ value: 0, index: 0 }
|
|
158
|
+
]);
|
|
159
|
+
});
|
|
160
|
+
(0, vitest_1.test)('backward reverting', async () => {
|
|
161
|
+
stateAnimation.setIndex(-1);
|
|
162
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
163
|
+
heap = [];
|
|
164
|
+
stateAnimation.setIndex(0);
|
|
165
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('reverting');
|
|
166
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
167
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
168
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('reverting');
|
|
169
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
170
|
+
{ value: 0.25, index: 0 },
|
|
171
|
+
{ value: -0.75, index: -1 }
|
|
172
|
+
]);
|
|
173
|
+
heap = [];
|
|
174
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
175
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('idle');
|
|
176
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
177
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.disappear, index: -1 },
|
|
178
|
+
{ value: 0, index: 0 }
|
|
179
|
+
]);
|
|
180
|
+
});
|
|
181
|
+
(0, vitest_1.test)('re-reverting', async () => {
|
|
182
|
+
stateAnimation.setIndex(1);
|
|
183
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
184
|
+
heap = [];
|
|
185
|
+
stateAnimation.setIndex(0);
|
|
186
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
187
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('reverting');
|
|
188
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
189
|
+
{ value: -0.25, index: 0 },
|
|
190
|
+
{ value: 0.75, index: 1 }
|
|
191
|
+
]);
|
|
192
|
+
heap = [];
|
|
193
|
+
stateAnimation.setIndex(1);
|
|
194
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
195
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
196
|
+
heap = [];
|
|
197
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
198
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
199
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
200
|
+
{ value: -0.75, index: 0 },
|
|
201
|
+
{ value: 0.25, index: 1 }
|
|
202
|
+
]);
|
|
203
|
+
heap = [];
|
|
204
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
205
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('idle');
|
|
206
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
207
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.disappear, index: 0 },
|
|
208
|
+
{ value: 0, index: 1 }
|
|
209
|
+
]);
|
|
210
|
+
});
|
|
211
|
+
(0, vitest_1.test)('setting same index', async () => {
|
|
212
|
+
stateAnimation.setIndex(1);
|
|
213
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
214
|
+
heap = [];
|
|
215
|
+
stateAnimation.setIndex(0);
|
|
216
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
217
|
+
heap = [];
|
|
218
|
+
stateAnimation.setIndex(0);
|
|
219
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
220
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('reverting');
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
(0, vitest_1.describe)('Re-targeting', () => {
|
|
224
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
225
|
+
stateAnimation.setIndex(0);
|
|
226
|
+
stateAnimation.setIndex(2);
|
|
227
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
228
|
+
heap = [];
|
|
229
|
+
});
|
|
230
|
+
(0, vitest_1.test)('changing target in transitioning', async () => {
|
|
231
|
+
stateAnimation.setIndex(1);
|
|
232
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
233
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
234
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
235
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
236
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
237
|
+
{ value: -0.75, index: 0 },
|
|
238
|
+
{ value: 0.25, index: 2 }
|
|
239
|
+
]);
|
|
240
|
+
heap = [];
|
|
241
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
242
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
243
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
244
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.disappear, index: 0 },
|
|
245
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.appear, index: 1 },
|
|
246
|
+
{ value: 0, index: 2 },
|
|
247
|
+
{ value: -1, index: 1 }
|
|
248
|
+
]);
|
|
249
|
+
heap = [];
|
|
250
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
251
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
252
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
253
|
+
{ value: 0.25, index: 2 },
|
|
254
|
+
{ value: -0.75, index: 1 }
|
|
255
|
+
]);
|
|
256
|
+
heap = [];
|
|
257
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(3);
|
|
258
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('idle');
|
|
259
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
260
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.disappear, index: 2 },
|
|
261
|
+
{ value: 0, index: 1 }
|
|
262
|
+
]);
|
|
263
|
+
});
|
|
264
|
+
(0, vitest_1.test)('changing target in reverting', async () => {
|
|
265
|
+
stateAnimation.setIndex(0);
|
|
266
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
267
|
+
heap = [];
|
|
268
|
+
stateAnimation.setIndex(1);
|
|
269
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('reverting');
|
|
270
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
271
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
272
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
273
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
274
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.disappear, index: 2 },
|
|
275
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.appear, index: 1 },
|
|
276
|
+
{ value: 0, index: 0 },
|
|
277
|
+
{ value: 1, index: 1 }
|
|
278
|
+
]);
|
|
279
|
+
heap = [];
|
|
280
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
281
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('transitioning');
|
|
282
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
283
|
+
{ value: -0.25, index: 0 },
|
|
284
|
+
{ value: 0.75, index: 1 }
|
|
285
|
+
]);
|
|
286
|
+
heap = [];
|
|
287
|
+
await game_entities_1.UpdateCycle.triggerUpdateTick(3);
|
|
288
|
+
(0, vitest_1.expect)(stateAnimation['stateAnimation']['animationState']).toBe('idle');
|
|
289
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
290
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.disappear, index: 0 },
|
|
291
|
+
{ value: 0, index: 1 }
|
|
292
|
+
]);
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
(0, vitest_1.describe)('Error Cases:', () => {
|
|
296
|
+
(0, vitest_1.test)('index must be an integer', async () => {
|
|
297
|
+
(0, vitest_1.expect)(() => stateAnimation.setIndex(0.25)).toThrowError('SlideStateAnimation: index must be an integer!');
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
//# sourceMappingURL=slide-state-animation.test.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Attachable } from 'actions-lib';
|
|
2
|
+
import { AnimatorAnimation } from '../animations';
|
|
3
|
+
export interface StateAnimationOptions {
|
|
4
|
+
readonly duration: number;
|
|
5
|
+
readonly animation: AnimatorAnimation;
|
|
6
|
+
}
|
|
7
|
+
type AnimationState = 'idle' | 'transitioning' | 'reverting';
|
|
8
|
+
export declare class StateAnimation<T> extends Attachable {
|
|
9
|
+
private animator;
|
|
10
|
+
private options;
|
|
11
|
+
private value;
|
|
12
|
+
private state;
|
|
13
|
+
private nextState;
|
|
14
|
+
private queuedState;
|
|
15
|
+
private animationState;
|
|
16
|
+
get currentState(): {
|
|
17
|
+
value: number;
|
|
18
|
+
state: T | undefined;
|
|
19
|
+
nextState: T | undefined;
|
|
20
|
+
queuedState: T | undefined;
|
|
21
|
+
animationState: AnimationState;
|
|
22
|
+
};
|
|
23
|
+
constructor(partialOptions?: Partial<StateAnimationOptions>);
|
|
24
|
+
setState(state: T, options?: {
|
|
25
|
+
instant?: boolean;
|
|
26
|
+
}): void;
|
|
27
|
+
private onComplete;
|
|
28
|
+
private onStateChangeAction;
|
|
29
|
+
private onValueChangeAction;
|
|
30
|
+
onStateChange(callback: (state: T, nextState?: T) => void): this;
|
|
31
|
+
onValueChange(callback: (value: number) => void): this;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StateAnimation = void 0;
|
|
4
|
+
const actions_lib_1 = require("actions-lib");
|
|
5
|
+
const animations_1 = require("../animations");
|
|
6
|
+
const animator_1 = require("../animator");
|
|
7
|
+
class StateAnimation extends actions_lib_1.Attachable {
|
|
8
|
+
get currentState() {
|
|
9
|
+
return {
|
|
10
|
+
value: this.value,
|
|
11
|
+
state: this.state,
|
|
12
|
+
nextState: this.nextState,
|
|
13
|
+
queuedState: this.queuedState,
|
|
14
|
+
animationState: this.animationState
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
constructor(partialOptions) {
|
|
18
|
+
super();
|
|
19
|
+
this.animationState = 'idle';
|
|
20
|
+
this.onStateChangeAction = new actions_lib_1.Action();
|
|
21
|
+
this.onValueChangeAction = new actions_lib_1.Action();
|
|
22
|
+
this.options = { duration: 500, animation: new animations_1.AnimationLineer(), ...partialOptions };
|
|
23
|
+
this.value = 0;
|
|
24
|
+
this.animator = new animator_1.Animator(this, 'value', {
|
|
25
|
+
duration: this.options.duration,
|
|
26
|
+
animation: this.options.animation,
|
|
27
|
+
reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious,
|
|
28
|
+
completeAnimationsHandling: animator_1.CompleteAnimationsHandlingType.stayInCurrentState
|
|
29
|
+
})
|
|
30
|
+
.onComplete((key, value) => this.onComplete(value))
|
|
31
|
+
.onChange(() => {
|
|
32
|
+
this.value = this.value === 1 ? 0 : this.value;
|
|
33
|
+
this.onValueChangeAction.trigger(this.value);
|
|
34
|
+
})
|
|
35
|
+
.attach(this);
|
|
36
|
+
}
|
|
37
|
+
setState(state, options) {
|
|
38
|
+
if (this.state === undefined) {
|
|
39
|
+
this.state = state;
|
|
40
|
+
this.onStateChangeAction.trigger({ state: this.state, nextState: this.nextState });
|
|
41
|
+
this.onValueChangeAction.trigger(this.value);
|
|
42
|
+
}
|
|
43
|
+
else if (options?.instant) {
|
|
44
|
+
this.animator.completeAnimations();
|
|
45
|
+
this.animationState = 'idle';
|
|
46
|
+
this.state = state;
|
|
47
|
+
this.nextState = undefined;
|
|
48
|
+
this.value = 0;
|
|
49
|
+
this.onStateChangeAction.trigger({ state: this.state, nextState: this.nextState });
|
|
50
|
+
this.onValueChangeAction.trigger(this.value);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
switch (this.animationState) {
|
|
54
|
+
case 'idle':
|
|
55
|
+
if (state !== this.state) {
|
|
56
|
+
this.animationState = 'transitioning';
|
|
57
|
+
this.nextState = state;
|
|
58
|
+
this.value = 0;
|
|
59
|
+
this.onStateChangeAction.trigger({ state: this.state, nextState: this.nextState });
|
|
60
|
+
this.onValueChangeAction.trigger(this.value);
|
|
61
|
+
this.animator.animate({ value: 1 });
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case 'transitioning':
|
|
65
|
+
if (state !== this.nextState) {
|
|
66
|
+
if (state === this.state) {
|
|
67
|
+
this.animationState = 'reverting';
|
|
68
|
+
this.animator.animate({ value: 0 }, { duration: this.value * this.options.duration });
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.queuedState = state;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
case 'reverting':
|
|
76
|
+
if (state !== this.state) {
|
|
77
|
+
if (state === this.nextState) {
|
|
78
|
+
this.animationState = 'transitioning';
|
|
79
|
+
this.animator.animate({ value: 1 }, { duration: (1 - this.value) * this.options.duration });
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.queuedState = state;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
onComplete(value) {
|
|
90
|
+
switch (this.animationState) {
|
|
91
|
+
case 'transitioning':
|
|
92
|
+
if (value === 1) {
|
|
93
|
+
if (this.queuedState !== undefined) {
|
|
94
|
+
this.animationState = 'transitioning';
|
|
95
|
+
this.state = this.nextState;
|
|
96
|
+
this.nextState = this.queuedState;
|
|
97
|
+
this.queuedState = undefined;
|
|
98
|
+
this.value = 0;
|
|
99
|
+
this.onStateChangeAction.trigger({ state: this.state, nextState: this.nextState });
|
|
100
|
+
this.animator.animate({ value: 1 });
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.animationState = 'idle';
|
|
104
|
+
this.state = this.nextState;
|
|
105
|
+
this.nextState = undefined;
|
|
106
|
+
this.onStateChangeAction.trigger({ state: this.state, nextState: this.nextState });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
case 'reverting':
|
|
111
|
+
if (this.state === undefined) {
|
|
112
|
+
throw new Error('StateAnimation: state must be defined when reverting!');
|
|
113
|
+
}
|
|
114
|
+
if (value === 0) {
|
|
115
|
+
if (this.queuedState !== undefined) {
|
|
116
|
+
this.animationState = 'transitioning';
|
|
117
|
+
this.nextState = this.queuedState;
|
|
118
|
+
this.queuedState = undefined;
|
|
119
|
+
this.value = 0;
|
|
120
|
+
this.onStateChangeAction.trigger({ state: this.state, nextState: this.nextState });
|
|
121
|
+
this.animator.animate({ value: 1 });
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.animationState = 'idle';
|
|
125
|
+
this.nextState = undefined;
|
|
126
|
+
this.value = 0;
|
|
127
|
+
this.onStateChangeAction.trigger({ state: this.state, nextState: this.nextState });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
case 'idle':
|
|
132
|
+
// Do nothing
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
onStateChange(callback) {
|
|
137
|
+
this.onStateChangeAction.subscribe(value => callback(value.state, value.nextState)).attach(this);
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
onValueChange(callback) {
|
|
141
|
+
this.onValueChangeAction.subscribe(value => callback(value)).attach(this);
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.StateAnimation = StateAnimation;
|
|
146
|
+
//# sourceMappingURL=state-animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|