@ue-too/animate 0.14.1 → 0.16.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/index.js CHANGED
@@ -1,5 +1,912 @@
1
- import{PointCal as J}from"@ue-too/math";var H={lerp:(q,p,x)=>{let K=(q-p.percentage)/(x.percentage-p.percentage),E=K;if(p.easingFn)E=p.easingFn(K);return J.addVector(p.value,J.multiplyVectorByScalar(J.subVector(x.value,p.value),E))}};class W{constructor(){}lerp(q,p,x){let K=(q-p.percentage)/(x.percentage-p.percentage),E=K;if(p.easingFn)E=p.easingFn(K);return J.addVector(p.value,J.multiplyVectorByScalar(J.subVector(x.value,p.value),E))}}var S={lerp:(q,p,x)=>{let K=(q-p.percentage)/(x.percentage-p.percentage),E=K;if(p.easingFn)E=p.easingFn(K);return p.value+E*(x.value-p.value)}};class X{constructor(){}lerp(q,p,x){let K=(q-p.percentage)/(x.percentage-p.percentage),E=K;if(p.easingFn)E=p.easingFn(K);return p.value+E*(x.value-p.value)}}var I={lerp:(q,p,x)=>{let K=(q-p.percentage)/(x.percentage-p.percentage);return K<0||K<0.5?p.value:x.value}};class Y{constructor(){}lerp(q,p,x){let K=(q-p.percentage)/(x.percentage-p.percentage);return K<0||K<0.5?p.value:x.value}}var N={lerp:(q,p,x)=>{let K=(q-p.percentage)/(x.percentage-p.percentage);return K<0||K<0.5?p.value:x.value}};class Z{constructor(){}lerp(q,p,x){let K=(q-p.percentage)/(x.percentage-p.percentage);return K<0||K<0.5?p.value:x.value}}var R={lerp:(q,p,x)=>{return{r:p.value.r+(q-p.percentage)/(x.percentage-p.percentage)*(x.value.r-p.value.r),g:p.value.g+(q-p.percentage)/(x.percentage-p.percentage)*(x.value.g-p.value.g),b:p.value.b+(q-p.percentage)/(x.percentage-p.percentage)*(x.value.b-p.value.b)}}};class _{constructor(){}lerp(q,p,x){return{r:p.value.r+(q-p.percentage)/(x.percentage-p.percentage)*(x.value.r-p.value.r),g:p.value.g+(q-p.percentage)/(x.percentage-p.percentage)*(x.value.g-p.value.g),b:p.value.b+(q-p.percentage)/(x.percentage-p.percentage)*(x.value.b-p.value.b)}}}var $=(q)=>{return q};class V{animations;localTime;_duration;onGoing;loop;playedTime;setUpFn;tearDownFn;_dragTime;_delayTime;parent;_maxLoopCount;endCallbacks=[];startCallbacks=[];reverse;constructor(q=new Map,p=!1,x=void 0,K=()=>{},E=()=>{}){this.animations=q,this._duration=0,this.calculateDuration(),this.localTime=-1,this.onGoing=!1,this.loop=p,this.setUpFn=K,this.tearDownFn=E,this._delayTime=0,this._dragTime=0,this.parent=x,this.animations.forEach((z)=>{z.animator.setParent(this)}),this.reverse=!1,this.playedTime=0}toggleReverse(q){if(this.reverse==q)return;this.reverse=q,this.animations.forEach((p)=>{p.animator.toggleReverse(q)})}setParent(q){this.parent=q}detachParent(){this.parent=void 0}animate(q){if(!this.onGoing||this.localTime>this._duration+this._delayTime+this._dragTime||this.localTime<0||this.animations.size==0)return;if(this.localTime+=q,this.localTime-q<=0&&q>0)this.startCallbacks.forEach((p)=>{queueMicrotask(()=>{p()})});this.animateChildren(q),this.checkTerminalAndLoop()}checkTerminalAndLoop(){if(this.localTime>=this._duration+this._delayTime+this._dragTime)if(this.playedTime+=1,this.endCallbacks.forEach((q)=>{queueMicrotask(()=>{q()})}),!this.loops||this.maxLoopCount!=null&&this.playedTime>=this.maxLoopCount)this.stop();else this.start()}animateChildren(q){let p=this.localTime-q;if(this.localTime<this._delayTime)return;this.animations.forEach((x,K)=>{if(x.startTime==null)x.startTime=0;if(!this.childShouldAnimate(x,p)){this.wrapUpAnimator({animator:x.animator,startTime:x.startTime,name:K},p);return}if(p-this._delayTime<x.startTime)x.animator.animate(this.localTime-this._delayTime-x.startTime);else x.animator.animate(q)})}childShouldAnimate(q,p){if(q.startTime==null)q.startTime=0;if(this.localTime-this._delayTime>=q.startTime&&this.localTime-this._delayTime<=q.startTime+q.animator.duration)return!0;return!1}wrapUpAnimator(q,p){if(q.startTime==null)q.startTime=0;if(this.localTime-this._delayTime>q.startTime+q.animator.duration&&p-this._delayTime<q.startTime+q.animator.duration)q.animator.animate(q.startTime+q.animator.duration-(p-this._delayTime))}pause(){this.onGoing=!1,this.animations.forEach((q)=>{q.animator.pause()})}resume(){this.onGoing=!0,this.animations.forEach((q)=>{q.animator.resume()})}start(){this.onGoing=!0,this.setUp(),this.localTime=0,this.animations.forEach((q)=>{q.animator.start()})}stop(){this.onGoing=!1,this.playedTime=0,this.localTime=this._duration+0.1,this.animations.forEach((q)=>{q.animator.stop()}),this.tearDown()}get duration(){return this._duration+this._delayTime+this._dragTime}set duration(q){if(q<0)return;let p=this._duration+this._delayTime+this._dragTime,x=q/p,K=this._delayTime*x,E=this._dragTime*x;if(this._delayTime=K,this._dragTime=E,this.animations.forEach((z)=>{if(z.startTime==null)z.startTime=0;z.startTime*=x;let j=z.animator.duration*x;z.animator.nonCascadingDuration(j)}),this.calculateDuration(),this.parent!=null)this.parent.updateDuration()}nonCascadingDuration(q){if(q<0)return;let p=this._duration+this._delayTime+this._dragTime,x=q/p,K=this._delayTime*x,E=this._dragTime*x;this._delayTime=K,this._dragTime=E,this.animations.forEach((z)=>{if(z.startTime==null)z.startTime=0;z.startTime*=x;let j=z.animator.duration*x;z.animator.nonCascadingDuration(j)}),this.calculateDuration()}resetAnimationState(){this.onGoing=!1,this.animations.forEach((q)=>{q.animator.resetAnimationState()})}getTrueDuration(){return this._duration}setUp(){this.setUpFn(),this.animations.forEach((q)=>{q.animator.setUp()})}tearDown(){this.tearDownFn(),this.animations.forEach((q)=>{q.animator.tearDown()})}addAnimation(q,p,x=0,K=()=>{}){if(this.animations.has(q))return;if(this.parent!==void 0&&this.parent.containsAnimation(p))return;if(this.animations.set(q,{animator:p,startTime:x}),p.setParent(this),this.localTime>x)p.animate(this.localTime-x);let E=x+p.duration;if(this._duration=Math.max(this._duration,E),this.parent!=null)this.parent.updateDuration()}addAnimationAfter(q,p,x,K=0){let E=this.animations.get(x);if(E==null)return;if(E.startTime==null)E.startTime=0;let z=E.startTime+E.animator.duration;if(z+=K,this.addAnimation(q,p,z),this.calculateDuration(),this.parent!=null)this.parent.updateDuration()}addAnimationAdmist(q,p,x,K){let E=this.animations.get(x);if(E==null)return;if(E.startTime==null)E.startTime=0;let z=E.startTime+K;if(this.addAnimation(q,p,z),this.calculateDuration(),this.parent!=null)this.parent.updateDuration()}addAnimationBefore(q,p,x,K=0){let E=this.animations.get(x);if(E==null)return;if(E.startTime==null)E.startTime=0;let z=E.startTime;if(z-=K,this.addAnimation(q,p,z),z<0){let j=0-z;this.animations.forEach((M)=>{if(M.startTime==null)M.startTime=0;M.startTime+=j})}if(this.calculateDuration(),this.parent!=null)this.parent.updateDuration()}removeAnimation(q){let p=this.animations.get(q);if(this.animations.delete(q)){if(p!=null)p.animator.detachParent();if(this.calculateDuration(),this.parent!=null)this.parent.updateDuration()}}set delay(q){if(this._delayTime=q,this.parent!=null)this.parent.updateDuration()}get delay(){return this._delayTime}set drag(q){if(this._dragTime=q,this.parent!=null)this.parent.updateDuration()}get drag(){return this._dragTime}removeDelay(){if(this._delayTime=0,this.parent!=null)this.parent.updateDuration()}removeDrag(){if(this._dragTime=0,this.parent!=null)this.parent.updateDuration()}updateDuration(){if(this.checkCyclicChildren())return;if(this.calculateDuration(),this.parent!=null)this.parent.updateDuration()}calculateDuration(){this._duration=0,this.animations.forEach((q)=>{if(q.startTime==null)q.startTime=0;let p=q.startTime+q.animator.duration;this._duration=Math.max(this._duration,p)})}get loops(){return this.loop}set loops(q){this.loop=q}checkCyclicChildren(){let q=[];q.push(this);let p=new Set;while(q.length>0){let x=q.pop();if(x==null)continue;if(p.has(x))return!0;if(p.add(x),x instanceof V)x.animations.forEach((K)=>{q.push(K.animator)})}return!1}forceToggleLoop(q){this.loop=!0,this.animations.forEach((p)=>{p.animator.loops=!0})}containsAnimation(q){if(this.parent!==void 0)return this.parent.containsAnimation(q);let p=[];p.push(this);let x=new Set;while(p.length>0){let K=p.pop();if(K==null)continue;if(K==q)return!0;if(x.has(K))continue;if(x.add(K),K instanceof V)K.animations.forEach((E)=>{p.push(E.animator)})}return!1}onEnd(q){return this.endCallbacks.push(q),()=>{this.endCallbacks=this.endCallbacks.filter((p)=>p!=q)}}onStart(q){return this.startCallbacks.push(q),()=>{this.startCallbacks=this.startCallbacks.filter((p)=>p!=q)}}clearOnEnd(){this.endCallbacks=[]}clearOnStart(){this.startCallbacks=[]}get playing(){return this.onGoing}get maxLoopCount(){return this._maxLoopCount}set maxLoopCount(q){this._maxLoopCount=q}}class B{localTime;_duration;keyframes;animatableAttributeHelper;applyAnimationValue;easeFn;onGoing;currentKeyframeIndex;loop;playedTime;setUpFn;tearDownFn;parent;delayTime=0;dragTime=0;reverse=!1;endCallbacks=[];startCallbacks=[];startAfterDelayCallbacks=[];zeroPercentageValue;_maxLoopCount;_fillMode="none";constructor(q,p,x,K=1000,E=!1,z=void 0,j=()=>{},M=()=>{},Q=$){this._duration=K,this.keyframes=q,this.animatableAttributeHelper=x,this.applyAnimationValue=p,this.easeFn=Q,this.onGoing=!1,this.localTime=K+0.1,this.currentKeyframeIndex=0,this.loop=E,this.setUpFn=j,this.tearDownFn=M,this.parent=z,this.playedTime=0,this.zeroPercentageValue=this.findValue(0,q,x)}toggleReverse(q){this.reverse=q}start(){this.localTime=0,this.currentKeyframeIndex=0,this.onGoing=!0,this.setUp()}stop(){this.onGoing=!1,this.localTime=this._duration+this.dragTime+this.delayTime+0.1,this.playedTime=0,this.tearDown()}pause(){this.onGoing=!1}resume(){this.onGoing=!0}get playing(){return this.onGoing}animate(q){if(this.onGoing!=!0||this.localTime<0)return;if(q==0)return;if(this.localTime+=q,this.localTime-q<=0&&q>0)this.startCallbacks.forEach((p)=>{queueMicrotask(()=>{p()})});if(this.localTime>=this.delayTime&&(this.localTime<=this.delayTime+this._duration+this.dragTime||this.localTime-q<=this.delayTime+this._duration+this.dragTime)){if(this.localTime-q<=this.delayTime&&this.delayTime!==0&&q>0)this.startAfterDelayCallbacks.forEach((E)=>{queueMicrotask(()=>{E()})}),this.applyAnimationValue(this.zeroPercentageValue);let p=(this.localTime-this.delayTime)/this._duration,x=this.easeFn(p);if(p>1)x=this.easeFn(1);let K;if(this.currentKeyframeIndex<this.keyframes.length&&this.currentKeyframeIndex>=0&&(this.reverse?1-this.keyframes[this.currentKeyframeIndex].percentage==x:this.keyframes[this.currentKeyframeIndex].percentage==x))K=this.keyframes[this.currentKeyframeIndex].value;else K=this.findValue(x,this.keyframes,this.animatableAttributeHelper);if(this.reverse)while(this.currentKeyframeIndex>=0&&1-this.keyframes[this.currentKeyframeIndex].percentage<=x)this.currentKeyframeIndex-=1;else while(this.currentKeyframeIndex<this.keyframes.length&&this.keyframes[this.currentKeyframeIndex].percentage<=x)this.currentKeyframeIndex+=1;if(this.applyAnimationValue(K),this.localTime>=this._duration+this.dragTime+this.delayTime)if(this.playedTime+=1,this.endCallbacks.forEach((E)=>{queueMicrotask(()=>{E()})}),!this.loops||this._maxLoopCount!=null&&this.playedTime>=(this.maxLoopCount??0))this.stop();else this.onGoing=!0,this.localTime=0,this.currentKeyframeIndex=0,this.start()}}findValue(q,p,x){if(q>1){if(this.reverse)return x.lerp(q,p[1],p[0]);return x.lerp(q,p[p.length-2],p[p.length-1])}if(q<0){if(this.reverse)return x.lerp(q,p[p.length-2],p[p.length-1]);return x.lerp(q,p[1],p[0])}let K=0,E=p.length-1;while(K<=E){let M=K+Math.floor((E-K)/2),Q=this.reverse?1-p[M].percentage:p[M].percentage;if(Q==q)return p[M].value;else if(Q<q)if(this.reverse)E=M-1;else K=M+1;else if(this.reverse)K=M+1;else E=M-1}if(K>p.length-1)K=p.length-1;let z=this.reverse?{percentage:1-p[K].percentage,value:p[K].value}:p[K-1],j=this.reverse?{percentage:1-p[K-1].percentage,value:p[K-1].value}:p[K];return x.lerp(q,z,j)}setUp(){this.setUpFn()}tearDown(){this.tearDownFn()}get loops(){return this.loop}set loops(q){this.loop=q}get duration(){return this._duration+this.delayTime+this.dragTime}set duration(q){if(q<0)return;let p=this._duration+this.delayTime+this.dragTime,x=q/p,K=this.delayTime*x,E=this.dragTime*x;if(this.delayTime=K,this.dragTime=E,this._duration=this._duration*x,this.parent!=null)this.parent.updateDuration()}nonCascadingDuration(q){if(q<0)return;let p=this._duration+this.delayTime+this.dragTime,x=q/p,K=this.delayTime*x,E=this.dragTime*x;this.delayTime=K,this.dragTime=E,this._duration=q}resetAnimationState(){this.onGoing=!1,this.applyAnimationValue(this.keyframes[0].value),this.currentKeyframeIndex=0,this.setUp()}wrapUp(){this.onGoing=!1,this.localTime=this._duration+this.dragTime+this.delayTime+0.1,this.currentKeyframeIndex=0}get delay(){return this.delayTime}set delay(q){if(this.delayTime=q,this.parent!=null)this.parent.updateDuration()}get drag(){return this.dragTime}set drag(q){if(this.dragTime=q,this.parent!=null)this.parent.updateDuration()}get trueDuration(){return this._duration}set trueDuration(q){if(this._duration=q,this.parent!=null)this.parent.updateDuration()}setParent(q){this.parent=q}detachParent(){this.parent=void 0}set keyFrames(q){this.keyframes=q,this.zeroPercentageValue=this.findValue(0,q,this.animatableAttributeHelper)}get keyFrames(){return this.keyframes}get easeFunction(){return this.easeFn}set easeFunction(q){this.easeFn=q}onEnd(q){return this.endCallbacks.push(q),()=>{this.endCallbacks=this.endCallbacks.filter((p)=>p!=q)}}onStart(q){return this.startCallbacks.push(q),()=>{this.startCallbacks=this.startCallbacks.filter((p)=>p!=q)}}onStartAfterDelay(q){return this.startAfterDelayCallbacks.push(q),()=>{this.startAfterDelayCallbacks=this.startAfterDelayCallbacks.filter((p)=>p!=q)}}clearOnEnd(){this.endCallbacks=[]}clearOnStart(){this.startCallbacks=[]}get maxLoopCount(){return this._maxLoopCount}set maxLoopCount(q){this._maxLoopCount=q}}class O{_keyframes;constructor(){this._keyframes=[]}get keyframes(){return this._keyframes}from(q){if(this._keyframes.length==0)this._keyframes.push({percentage:0,value:q});else if(this._keyframes[0].percentage==0)this._keyframes[0].value=q;else this._keyframes.unshift({percentage:0,value:q});return this}to(q){if(this._keyframes.length==0)this._keyframes.push({percentage:1,value:q});else if(this._keyframes[this._keyframes.length-1].percentage==1)this._keyframes[this._keyframes.length-1].value=q;else this._keyframes.push({percentage:1,value:q});return this}insertAt(q,p){this._keyframes.push({percentage:q,value:p})}clearFrames(){this._keyframes=[]}}export{I as stringHelperFunctions,R as rgbHelperFunctions,H as pointHelperFunctions,S as numberHelperFunctions,$ as linear,N as integerHelperFunctions,Y as StringAnimationHelper,_ as RGBAnimationHelper,W as PointAnimationHelper,X as NumberAnimationHelper,O as KeyFramesContiner,Z as IntegerAnimationHelper,V as CompositeAnimation,B as Animation};
1
+ // src/animatable-attribute.ts
2
+ import { PointCal } from "@ue-too/math";
3
+ var pointHelperFunctions = {
4
+ lerp: (ratio, start, end) => {
5
+ const inbetweenRatio = (ratio - start.percentage) / (end.percentage - start.percentage);
6
+ let transformed = inbetweenRatio;
7
+ if (start.easingFn) {
8
+ transformed = start.easingFn(inbetweenRatio);
9
+ }
10
+ const res = PointCal.addVector(start.value, PointCal.multiplyVectorByScalar(PointCal.subVector(end.value, start.value), transformed));
11
+ return res;
12
+ }
13
+ };
2
14
 
3
- //# debugId=A64492CFE695240C64756E2164756E21
15
+ class PointAnimationHelper {
16
+ constructor() {}
17
+ lerp(ratio, start, end) {
18
+ const inbetweenRatio = (ratio - start.percentage) / (end.percentage - start.percentage);
19
+ let transformed = inbetweenRatio;
20
+ if (start.easingFn) {
21
+ transformed = start.easingFn(inbetweenRatio);
22
+ }
23
+ const res = PointCal.addVector(start.value, PointCal.multiplyVectorByScalar(PointCal.subVector(end.value, start.value), transformed));
24
+ return res;
25
+ }
26
+ }
27
+ var numberHelperFunctions = {
28
+ lerp: (ratio, start, end) => {
29
+ const inbetweenRatio = (ratio - start.percentage) / (end.percentage - start.percentage);
30
+ let transformed = inbetweenRatio;
31
+ if (start.easingFn) {
32
+ transformed = start.easingFn(inbetweenRatio);
33
+ }
34
+ const res = start.value + transformed * (end.value - start.value);
35
+ return res;
36
+ }
37
+ };
38
+
39
+ class NumberAnimationHelper {
40
+ constructor() {}
41
+ lerp(ratio, start, end) {
42
+ const inbetweenRatio = (ratio - start.percentage) / (end.percentage - start.percentage);
43
+ let transformed = inbetweenRatio;
44
+ if (start.easingFn) {
45
+ transformed = start.easingFn(inbetweenRatio);
46
+ }
47
+ const res = start.value + transformed * (end.value - start.value);
48
+ return res;
49
+ }
50
+ }
51
+ var stringHelperFunctions = {
52
+ lerp: (ratio, start, end) => {
53
+ const percentageScale = (ratio - start.percentage) / (end.percentage - start.percentage);
54
+ return percentageScale < 0 || percentageScale < 0.5 ? start.value : end.value;
55
+ }
56
+ };
57
+
58
+ class StringAnimationHelper {
59
+ constructor() {}
60
+ lerp(ratio, start, end) {
61
+ const percentageScale = (ratio - start.percentage) / (end.percentage - start.percentage);
62
+ return percentageScale < 0 || percentageScale < 0.5 ? start.value : end.value;
63
+ }
64
+ }
65
+ var integerHelperFunctions = {
66
+ lerp: (ratio, start, end) => {
67
+ const percentageScale = (ratio - start.percentage) / (end.percentage - start.percentage);
68
+ return percentageScale < 0 || percentageScale < 0.5 ? start.value : end.value;
69
+ }
70
+ };
71
+
72
+ class IntegerAnimationHelper {
73
+ constructor() {}
74
+ lerp(ratio, start, end) {
75
+ const percentageScale = (ratio - start.percentage) / (end.percentage - start.percentage);
76
+ return percentageScale < 0 || percentageScale < 0.5 ? start.value : end.value;
77
+ }
78
+ }
79
+ var rgbHelperFunctions = {
80
+ lerp: (ratio, start, end) => {
81
+ const res = {
82
+ r: start.value.r + (ratio - start.percentage) / (end.percentage - start.percentage) * (end.value.r - start.value.r),
83
+ g: start.value.g + (ratio - start.percentage) / (end.percentage - start.percentage) * (end.value.g - start.value.g),
84
+ b: start.value.b + (ratio - start.percentage) / (end.percentage - start.percentage) * (end.value.b - start.value.b)
85
+ };
86
+ return res;
87
+ }
88
+ };
89
+
90
+ class RGBAnimationHelper {
91
+ constructor() {}
92
+ lerp(ratio, start, end) {
93
+ const res = {
94
+ r: start.value.r + (ratio - start.percentage) / (end.percentage - start.percentage) * (end.value.r - start.value.r),
95
+ g: start.value.g + (ratio - start.percentage) / (end.percentage - start.percentage) * (end.value.g - start.value.g),
96
+ b: start.value.b + (ratio - start.percentage) / (end.percentage - start.percentage) * (end.value.b - start.value.b)
97
+ };
98
+ return res;
99
+ }
100
+ }
101
+ // src/composite-animation.ts
102
+ var linear = (percentage) => {
103
+ return percentage;
104
+ };
105
+
106
+ class CompositeAnimation {
107
+ animations;
108
+ localTime;
109
+ _duration;
110
+ onGoing;
111
+ loop;
112
+ playedTime;
113
+ setUpFn;
114
+ tearDownFn;
115
+ _dragTime;
116
+ _delayTime;
117
+ parent;
118
+ _maxLoopCount;
119
+ endCallbacks = [];
120
+ startCallbacks = [];
121
+ reverse;
122
+ constructor(animations = new Map, loop = false, parent = undefined, setupFn = () => {}, tearDownFn = () => {}) {
123
+ this.animations = animations;
124
+ this._duration = 0;
125
+ this.calculateDuration();
126
+ this.localTime = -1;
127
+ this.onGoing = false;
128
+ this.loop = loop;
129
+ this.setUpFn = setupFn;
130
+ this.tearDownFn = tearDownFn;
131
+ this._delayTime = 0;
132
+ this._dragTime = 0;
133
+ this.parent = parent;
134
+ this.animations.forEach((animation) => {
135
+ animation.animator.setParent(this);
136
+ });
137
+ this.reverse = false;
138
+ this.playedTime = 0;
139
+ }
140
+ toggleReverse(reverse) {
141
+ if (this.reverse == reverse) {
142
+ return;
143
+ }
144
+ this.reverse = reverse;
145
+ this.animations.forEach((animation) => {
146
+ animation.animator.toggleReverse(reverse);
147
+ });
148
+ }
149
+ setParent(parent) {
150
+ this.parent = parent;
151
+ }
152
+ detachParent() {
153
+ this.parent = undefined;
154
+ }
155
+ animate(deltaTime) {
156
+ if (!this.onGoing || this.localTime > this._duration + this._delayTime + this._dragTime || this.localTime < 0 || this.animations.size == 0) {
157
+ return;
158
+ }
159
+ this.localTime += deltaTime;
160
+ if (this.localTime - deltaTime <= 0 && deltaTime > 0) {
161
+ this.startCallbacks.forEach((callback) => {
162
+ queueMicrotask(() => {
163
+ callback();
164
+ });
165
+ });
166
+ }
167
+ this.animateChildren(deltaTime);
168
+ this.checkTerminalAndLoop();
169
+ }
170
+ checkTerminalAndLoop() {
171
+ if (this.localTime >= this._duration + this._delayTime + this._dragTime) {
172
+ this.playedTime += 1;
173
+ this.endCallbacks.forEach((callback) => {
174
+ queueMicrotask(() => {
175
+ callback();
176
+ });
177
+ });
178
+ if (!this.loops || this.maxLoopCount != null && this.playedTime >= this.maxLoopCount) {
179
+ this.stop();
180
+ } else {
181
+ this.start();
182
+ }
183
+ }
184
+ }
185
+ animateChildren(deltaTime) {
186
+ const prevLocalTime = this.localTime - deltaTime;
187
+ if (this.localTime < this._delayTime) {
188
+ return;
189
+ }
190
+ this.animations.forEach((animation, name) => {
191
+ if (animation.startTime == undefined) {
192
+ animation.startTime = 0;
193
+ }
194
+ if (!this.childShouldAnimate(animation, prevLocalTime)) {
195
+ this.wrapUpAnimator({
196
+ animator: animation.animator,
197
+ startTime: animation.startTime,
198
+ name
199
+ }, prevLocalTime);
200
+ return;
201
+ }
202
+ if (prevLocalTime - this._delayTime < animation.startTime) {
203
+ animation.animator.animate(this.localTime - this._delayTime - animation.startTime);
204
+ } else {
205
+ animation.animator.animate(deltaTime);
206
+ }
207
+ });
208
+ }
209
+ childShouldAnimate(animation, prevLocalTime) {
210
+ if (animation.startTime == undefined) {
211
+ animation.startTime = 0;
212
+ }
213
+ if (this.localTime - this._delayTime >= animation.startTime && this.localTime - this._delayTime <= animation.startTime + animation.animator.duration) {
214
+ return true;
215
+ }
216
+ return false;
217
+ }
218
+ wrapUpAnimator(animation, prevLocalTime) {
219
+ if (animation.startTime == undefined) {
220
+ animation.startTime = 0;
221
+ }
222
+ if (this.localTime - this._delayTime > animation.startTime + animation.animator.duration && prevLocalTime - this._delayTime < animation.startTime + animation.animator.duration) {
223
+ animation.animator.animate(animation.startTime + animation.animator.duration - (prevLocalTime - this._delayTime));
224
+ }
225
+ }
226
+ pause() {
227
+ this.onGoing = false;
228
+ this.animations.forEach((animation) => {
229
+ animation.animator.pause();
230
+ });
231
+ }
232
+ resume() {
233
+ this.onGoing = true;
234
+ this.animations.forEach((animation) => {
235
+ animation.animator.resume();
236
+ });
237
+ }
238
+ start() {
239
+ this.onGoing = true;
240
+ this.setUp();
241
+ this.localTime = 0;
242
+ this.animations.forEach((animation) => {
243
+ animation.animator.start();
244
+ });
245
+ }
246
+ stop() {
247
+ this.onGoing = false;
248
+ this.playedTime = 0;
249
+ this.localTime = this._duration + 0.1;
250
+ this.animations.forEach((animation) => {
251
+ animation.animator.stop();
252
+ });
253
+ this.tearDown();
254
+ }
255
+ get duration() {
256
+ return this._duration + this._delayTime + this._dragTime;
257
+ }
258
+ set duration(duration) {
259
+ if (duration < 0) {
260
+ return;
261
+ }
262
+ const originalDuration = this._duration + this._delayTime + this._dragTime;
263
+ const scale = duration / originalDuration;
264
+ const newDelayTime = this._delayTime * scale;
265
+ const newDragTime = this._dragTime * scale;
266
+ this._delayTime = newDelayTime;
267
+ this._dragTime = newDragTime;
268
+ this.animations.forEach((animation) => {
269
+ if (animation.startTime == undefined) {
270
+ animation.startTime = 0;
271
+ }
272
+ animation.startTime *= scale;
273
+ const newDuration = animation.animator.duration * scale;
274
+ animation.animator.nonCascadingDuration(newDuration);
275
+ });
276
+ this.calculateDuration();
277
+ if (this.parent != null) {
278
+ this.parent.updateDuration();
279
+ }
280
+ }
281
+ nonCascadingDuration(newDuration) {
282
+ if (newDuration < 0) {
283
+ return;
284
+ }
285
+ const originalDuration = this._duration + this._delayTime + this._dragTime;
286
+ const scale = newDuration / originalDuration;
287
+ const newDelayTime = this._delayTime * scale;
288
+ const newDragTime = this._dragTime * scale;
289
+ this._delayTime = newDelayTime;
290
+ this._dragTime = newDragTime;
291
+ this.animations.forEach((animation) => {
292
+ if (animation.startTime == undefined) {
293
+ animation.startTime = 0;
294
+ }
295
+ animation.startTime *= scale;
296
+ const newDuration2 = animation.animator.duration * scale;
297
+ animation.animator.nonCascadingDuration(newDuration2);
298
+ });
299
+ this.calculateDuration();
300
+ }
301
+ resetAnimationState() {
302
+ this.onGoing = false;
303
+ this.animations.forEach((animation) => {
304
+ animation.animator.resetAnimationState();
305
+ });
306
+ }
307
+ getTrueDuration() {
308
+ return this._duration;
309
+ }
310
+ setUp() {
311
+ this.setUpFn();
312
+ this.animations.forEach((animation) => {
313
+ animation.animator.setUp();
314
+ });
315
+ }
316
+ tearDown() {
317
+ this.tearDownFn();
318
+ this.animations.forEach((animation) => {
319
+ animation.animator.tearDown();
320
+ });
321
+ }
322
+ addAnimation(name, animation, startTime = 0, endCallback = () => {}) {
323
+ if (this.animations.has(name)) {
324
+ return;
325
+ }
326
+ if (this.parent !== undefined && this.parent.containsAnimation(animation)) {
327
+ return;
328
+ }
329
+ this.animations.set(name, {
330
+ animator: animation,
331
+ startTime
332
+ });
333
+ animation.setParent(this);
334
+ if (this.localTime > startTime) {
335
+ animation.animate(this.localTime - startTime);
336
+ }
337
+ const endTime = startTime + animation.duration;
338
+ this._duration = Math.max(this._duration, endTime);
339
+ if (this.parent != null) {
340
+ this.parent.updateDuration();
341
+ }
342
+ }
343
+ addAnimationAfter(name, animation, afterName, delay = 0) {
344
+ let afterAnimation = this.animations.get(afterName);
345
+ if (afterAnimation == undefined) {
346
+ return;
347
+ }
348
+ if (afterAnimation.startTime == undefined) {
349
+ afterAnimation.startTime = 0;
350
+ }
351
+ let startTime = afterAnimation.startTime + afterAnimation.animator.duration;
352
+ startTime += delay;
353
+ this.addAnimation(name, animation, startTime);
354
+ this.calculateDuration();
355
+ if (this.parent != null) {
356
+ this.parent.updateDuration();
357
+ }
358
+ }
359
+ addAnimationAdmist(name, animation, admistName, delay) {
360
+ let admistAnimation = this.animations.get(admistName);
361
+ if (admistAnimation == undefined) {
362
+ return;
363
+ }
364
+ if (admistAnimation.startTime == undefined) {
365
+ admistAnimation.startTime = 0;
366
+ }
367
+ let startTime = admistAnimation.startTime + delay;
368
+ this.addAnimation(name, animation, startTime);
369
+ this.calculateDuration();
370
+ if (this.parent != null) {
371
+ this.parent.updateDuration();
372
+ }
373
+ }
374
+ addAnimationBefore(name, animation, beforeName, aheadTime = 0) {
375
+ let beforeAnimation = this.animations.get(beforeName);
376
+ if (beforeAnimation == undefined) {
377
+ return;
378
+ }
379
+ if (beforeAnimation.startTime == undefined) {
380
+ beforeAnimation.startTime = 0;
381
+ }
382
+ let startTime = beforeAnimation.startTime;
383
+ startTime -= aheadTime;
384
+ this.addAnimation(name, animation, startTime);
385
+ if (startTime < 0) {
386
+ const pushOver = 0 - startTime;
387
+ this.animations.forEach((animation2) => {
388
+ if (animation2.startTime == undefined) {
389
+ animation2.startTime = 0;
390
+ }
391
+ animation2.startTime += pushOver;
392
+ });
393
+ }
394
+ this.calculateDuration();
395
+ if (this.parent != null) {
396
+ this.parent.updateDuration();
397
+ }
398
+ }
399
+ removeAnimation(name) {
400
+ let animation = this.animations.get(name);
401
+ let deleted = this.animations.delete(name);
402
+ if (deleted) {
403
+ if (animation != null) {
404
+ animation.animator.detachParent();
405
+ }
406
+ this.calculateDuration();
407
+ if (this.parent != null) {
408
+ this.parent.updateDuration();
409
+ }
410
+ }
411
+ }
412
+ set delay(delayTime) {
413
+ this._delayTime = delayTime;
414
+ if (this.parent != null) {
415
+ this.parent.updateDuration();
416
+ }
417
+ }
418
+ get delay() {
419
+ return this._delayTime;
420
+ }
421
+ set drag(dragTime) {
422
+ this._dragTime = dragTime;
423
+ if (this.parent != null) {
424
+ this.parent.updateDuration();
425
+ }
426
+ }
427
+ get drag() {
428
+ return this._dragTime;
429
+ }
430
+ removeDelay() {
431
+ this._delayTime = 0;
432
+ if (this.parent != null) {
433
+ this.parent.updateDuration();
434
+ }
435
+ }
436
+ removeDrag() {
437
+ this._dragTime = 0;
438
+ if (this.parent != null) {
439
+ this.parent.updateDuration();
440
+ }
441
+ }
442
+ updateDuration() {
443
+ if (this.checkCyclicChildren()) {
444
+ return;
445
+ }
446
+ this.calculateDuration();
447
+ if (this.parent != null) {
448
+ this.parent.updateDuration();
449
+ }
450
+ }
451
+ calculateDuration() {
452
+ this._duration = 0;
453
+ this.animations.forEach((animation) => {
454
+ if (animation.startTime == undefined) {
455
+ animation.startTime = 0;
456
+ }
457
+ const endTime = animation.startTime + animation.animator.duration;
458
+ this._duration = Math.max(this._duration, endTime);
459
+ });
460
+ }
461
+ get loops() {
462
+ return this.loop;
463
+ }
464
+ set loops(loop) {
465
+ this.loop = loop;
466
+ }
467
+ checkCyclicChildren() {
468
+ const allChildren = [];
469
+ allChildren.push(this);
470
+ const visited = new Set;
471
+ while (allChildren.length > 0) {
472
+ const current = allChildren.pop();
473
+ if (current == undefined) {
474
+ continue;
475
+ }
476
+ if (visited.has(current)) {
477
+ return true;
478
+ }
479
+ visited.add(current);
480
+ if (current instanceof CompositeAnimation) {
481
+ current.animations.forEach((animation) => {
482
+ allChildren.push(animation.animator);
483
+ });
484
+ }
485
+ }
486
+ return false;
487
+ }
488
+ forceToggleLoop(loop) {
489
+ this.loop = true;
490
+ this.animations.forEach((animation) => {
491
+ animation.animator.loops = true;
492
+ });
493
+ }
494
+ containsAnimation(animationInInterest) {
495
+ if (this.parent !== undefined) {
496
+ return this.parent.containsAnimation(animationInInterest);
497
+ }
498
+ const allChildren = [];
499
+ allChildren.push(this);
500
+ const visited = new Set;
501
+ while (allChildren.length > 0) {
502
+ const current = allChildren.pop();
503
+ if (current == undefined) {
504
+ continue;
505
+ }
506
+ if (current == animationInInterest) {
507
+ return true;
508
+ }
509
+ if (visited.has(current)) {
510
+ continue;
511
+ }
512
+ visited.add(current);
513
+ if (current instanceof CompositeAnimation) {
514
+ current.animations.forEach((animation) => {
515
+ allChildren.push(animation.animator);
516
+ });
517
+ }
518
+ }
519
+ return false;
520
+ }
521
+ onEnd(callback) {
522
+ this.endCallbacks.push(callback);
523
+ return () => {
524
+ this.endCallbacks = this.endCallbacks.filter((cb) => cb != callback);
525
+ };
526
+ }
527
+ onStart(callback) {
528
+ this.startCallbacks.push(callback);
529
+ return () => {
530
+ this.startCallbacks = this.startCallbacks.filter((cb) => cb != callback);
531
+ };
532
+ }
533
+ clearOnEnd() {
534
+ this.endCallbacks = [];
535
+ }
536
+ clearOnStart() {
537
+ this.startCallbacks = [];
538
+ }
539
+ get playing() {
540
+ return this.onGoing;
541
+ }
542
+ get maxLoopCount() {
543
+ return this._maxLoopCount;
544
+ }
545
+ set maxLoopCount(maxLoopCount) {
546
+ this._maxLoopCount = maxLoopCount;
547
+ }
548
+ }
549
+
550
+ class Animation {
551
+ localTime;
552
+ _duration;
553
+ keyframes;
554
+ animatableAttributeHelper;
555
+ applyAnimationValue;
556
+ easeFn;
557
+ onGoing;
558
+ currentKeyframeIndex;
559
+ loop;
560
+ playedTime;
561
+ setUpFn;
562
+ tearDownFn;
563
+ parent;
564
+ delayTime = 0;
565
+ dragTime = 0;
566
+ reverse = false;
567
+ endCallbacks = [];
568
+ startCallbacks = [];
569
+ startAfterDelayCallbacks = [];
570
+ zeroPercentageValue;
571
+ _maxLoopCount;
572
+ _fillMode = "none";
573
+ constructor(keyFrames, applyAnimationValue, animatableAttributeHelper, duration = 1000, loop = false, parent = undefined, setUpFn = () => {}, tearDownFn = () => {}, easeFn = linear) {
574
+ this._duration = duration;
575
+ this.keyframes = keyFrames;
576
+ this.animatableAttributeHelper = animatableAttributeHelper;
577
+ this.applyAnimationValue = applyAnimationValue;
578
+ this.easeFn = easeFn;
579
+ this.onGoing = false;
580
+ this.localTime = duration + 0.1;
581
+ this.currentKeyframeIndex = 0;
582
+ this.loop = loop;
583
+ this.setUpFn = setUpFn;
584
+ this.tearDownFn = tearDownFn;
585
+ this.parent = parent;
586
+ this.playedTime = 0;
587
+ this.zeroPercentageValue = this.findValue(0, keyFrames, animatableAttributeHelper);
588
+ }
589
+ toggleReverse(reverse) {
590
+ this.reverse = reverse;
591
+ }
592
+ start() {
593
+ this.localTime = 0;
594
+ this.currentKeyframeIndex = 0;
595
+ this.onGoing = true;
596
+ this.setUp();
597
+ }
598
+ stop() {
599
+ this.onGoing = false;
600
+ this.localTime = this._duration + this.dragTime + this.delayTime + 0.1;
601
+ this.playedTime = 0;
602
+ this.tearDown();
603
+ }
604
+ pause() {
605
+ this.onGoing = false;
606
+ }
607
+ resume() {
608
+ this.onGoing = true;
609
+ }
610
+ get playing() {
611
+ return this.onGoing;
612
+ }
613
+ animate(deltaTime) {
614
+ if (this.onGoing != true || this.localTime < 0) {
615
+ return;
616
+ }
617
+ if (deltaTime == 0) {
618
+ return;
619
+ }
620
+ this.localTime += deltaTime;
621
+ if (this.localTime - deltaTime <= 0 && deltaTime > 0) {
622
+ this.startCallbacks.forEach((callback) => {
623
+ queueMicrotask(() => {
624
+ callback();
625
+ });
626
+ });
627
+ }
628
+ if (this.localTime >= this.delayTime && (this.localTime <= this.delayTime + this._duration + this.dragTime || this.localTime - deltaTime <= this.delayTime + this._duration + this.dragTime)) {
629
+ if (this.localTime - deltaTime <= this.delayTime && this.delayTime !== 0 && deltaTime > 0) {
630
+ this.startAfterDelayCallbacks.forEach((callback) => {
631
+ queueMicrotask(() => {
632
+ callback();
633
+ });
634
+ });
635
+ this.applyAnimationValue(this.zeroPercentageValue);
636
+ }
637
+ let localTimePercentage = (this.localTime - this.delayTime) / this._duration;
638
+ let targetPercentage = this.easeFn(localTimePercentage);
639
+ if (localTimePercentage > 1) {
640
+ targetPercentage = this.easeFn(1);
641
+ }
642
+ let value;
643
+ if (this.currentKeyframeIndex < this.keyframes.length && this.currentKeyframeIndex >= 0 && (this.reverse ? 1 - this.keyframes[this.currentKeyframeIndex].percentage == targetPercentage : this.keyframes[this.currentKeyframeIndex].percentage == targetPercentage)) {
644
+ value = this.keyframes[this.currentKeyframeIndex].value;
645
+ } else {
646
+ value = this.findValue(targetPercentage, this.keyframes, this.animatableAttributeHelper);
647
+ }
648
+ if (this.reverse) {
649
+ while (this.currentKeyframeIndex >= 0 && 1 - this.keyframes[this.currentKeyframeIndex].percentage <= targetPercentage) {
650
+ this.currentKeyframeIndex -= 1;
651
+ }
652
+ } else {
653
+ while (this.currentKeyframeIndex < this.keyframes.length && this.keyframes[this.currentKeyframeIndex].percentage <= targetPercentage) {
654
+ this.currentKeyframeIndex += 1;
655
+ }
656
+ }
657
+ this.applyAnimationValue(value);
658
+ if (this.localTime >= this._duration + this.dragTime + this.delayTime) {
659
+ this.playedTime += 1;
660
+ this.endCallbacks.forEach((callback) => {
661
+ queueMicrotask(() => {
662
+ callback();
663
+ });
664
+ });
665
+ if (!this.loops || this._maxLoopCount != null && this.playedTime >= (this.maxLoopCount ?? 0)) {
666
+ this.stop();
667
+ } else {
668
+ this.onGoing = true;
669
+ this.localTime = 0;
670
+ this.currentKeyframeIndex = 0;
671
+ this.start();
672
+ }
673
+ }
674
+ }
675
+ }
676
+ findValue(valuePercentage, keyframes, animatableAttributeHelper) {
677
+ if (valuePercentage > 1) {
678
+ if (this.reverse) {
679
+ return animatableAttributeHelper.lerp(valuePercentage, keyframes[1], keyframes[0]);
680
+ }
681
+ return animatableAttributeHelper.lerp(valuePercentage, keyframes[keyframes.length - 2], keyframes[keyframes.length - 1]);
682
+ }
683
+ if (valuePercentage < 0) {
684
+ if (this.reverse) {
685
+ return animatableAttributeHelper.lerp(valuePercentage, keyframes[keyframes.length - 2], keyframes[keyframes.length - 1]);
686
+ }
687
+ return animatableAttributeHelper.lerp(valuePercentage, keyframes[1], keyframes[0]);
688
+ }
689
+ let left = 0;
690
+ let right = keyframes.length - 1;
691
+ while (left <= right) {
692
+ let mid = left + Math.floor((right - left) / 2);
693
+ const midPercentage = this.reverse ? 1 - keyframes[mid].percentage : keyframes[mid].percentage;
694
+ if (midPercentage == valuePercentage) {
695
+ return keyframes[mid].value;
696
+ } else if (midPercentage < valuePercentage) {
697
+ if (this.reverse) {
698
+ right = mid - 1;
699
+ } else {
700
+ left = mid + 1;
701
+ }
702
+ } else {
703
+ if (this.reverse) {
704
+ left = mid + 1;
705
+ } else {
706
+ right = mid - 1;
707
+ }
708
+ }
709
+ }
710
+ if (left > keyframes.length - 1) {
711
+ left = keyframes.length - 1;
712
+ }
713
+ const interpolateStartFrame = this.reverse ? {
714
+ percentage: 1 - keyframes[left].percentage,
715
+ value: keyframes[left].value
716
+ } : keyframes[left - 1];
717
+ const interplateEndFrame = this.reverse ? {
718
+ percentage: 1 - keyframes[left - 1].percentage,
719
+ value: keyframes[left - 1].value
720
+ } : keyframes[left];
721
+ return animatableAttributeHelper.lerp(valuePercentage, interpolateStartFrame, interplateEndFrame);
722
+ }
723
+ setUp() {
724
+ this.setUpFn();
725
+ }
726
+ tearDown() {
727
+ this.tearDownFn();
728
+ }
729
+ get loops() {
730
+ return this.loop;
731
+ }
732
+ set loops(loop) {
733
+ this.loop = loop;
734
+ }
735
+ get duration() {
736
+ return this._duration + this.delayTime + this.dragTime;
737
+ }
738
+ set duration(duration) {
739
+ if (duration < 0) {
740
+ return;
741
+ }
742
+ const originalDuration = this._duration + this.delayTime + this.dragTime;
743
+ const scale = duration / originalDuration;
744
+ const newDelayTime = this.delayTime * scale;
745
+ const newDragTime = this.dragTime * scale;
746
+ this.delayTime = newDelayTime;
747
+ this.dragTime = newDragTime;
748
+ this._duration = this._duration * scale;
749
+ if (this.parent != null) {
750
+ this.parent.updateDuration();
751
+ }
752
+ }
753
+ nonCascadingDuration(newDuration) {
754
+ if (newDuration < 0) {
755
+ return;
756
+ }
757
+ const originalDuration = this._duration + this.delayTime + this.dragTime;
758
+ const scale = newDuration / originalDuration;
759
+ const newDelayTime = this.delayTime * scale;
760
+ const newDragTime = this.dragTime * scale;
761
+ this.delayTime = newDelayTime;
762
+ this.dragTime = newDragTime;
763
+ this._duration = newDuration;
764
+ }
765
+ resetAnimationState() {
766
+ this.onGoing = false;
767
+ this.applyAnimationValue(this.keyframes[0].value);
768
+ this.currentKeyframeIndex = 0;
769
+ this.setUp();
770
+ }
771
+ wrapUp() {
772
+ this.onGoing = false;
773
+ this.localTime = this._duration + this.dragTime + this.delayTime + 0.1;
774
+ this.currentKeyframeIndex = 0;
775
+ }
776
+ get delay() {
777
+ return this.delayTime;
778
+ }
779
+ set delay(delayTime) {
780
+ this.delayTime = delayTime;
781
+ if (this.parent != null) {
782
+ this.parent.updateDuration();
783
+ }
784
+ }
785
+ get drag() {
786
+ return this.dragTime;
787
+ }
788
+ set drag(dragTime) {
789
+ this.dragTime = dragTime;
790
+ if (this.parent != null) {
791
+ this.parent.updateDuration();
792
+ }
793
+ }
794
+ get trueDuration() {
795
+ return this._duration;
796
+ }
797
+ set trueDuration(duration) {
798
+ this._duration = duration;
799
+ if (this.parent != null) {
800
+ this.parent.updateDuration();
801
+ }
802
+ }
803
+ setParent(parent) {
804
+ this.parent = parent;
805
+ }
806
+ detachParent() {
807
+ this.parent = undefined;
808
+ }
809
+ set keyFrames(keyFrames) {
810
+ this.keyframes = keyFrames;
811
+ this.zeroPercentageValue = this.findValue(0, keyFrames, this.animatableAttributeHelper);
812
+ }
813
+ get keyFrames() {
814
+ return this.keyframes;
815
+ }
816
+ get easeFunction() {
817
+ return this.easeFn;
818
+ }
819
+ set easeFunction(easeFn) {
820
+ this.easeFn = easeFn;
821
+ }
822
+ onEnd(callback) {
823
+ this.endCallbacks.push(callback);
824
+ return () => {
825
+ this.endCallbacks = this.endCallbacks.filter((cb) => cb != callback);
826
+ };
827
+ }
828
+ onStart(callback) {
829
+ this.startCallbacks.push(callback);
830
+ return () => {
831
+ this.startCallbacks = this.startCallbacks.filter((cb) => cb != callback);
832
+ };
833
+ }
834
+ onStartAfterDelay(callback) {
835
+ this.startAfterDelayCallbacks.push(callback);
836
+ return () => {
837
+ this.startAfterDelayCallbacks = this.startAfterDelayCallbacks.filter((cb) => cb != callback);
838
+ };
839
+ }
840
+ clearOnEnd() {
841
+ this.endCallbacks = [];
842
+ }
843
+ clearOnStart() {
844
+ this.startCallbacks = [];
845
+ }
846
+ get maxLoopCount() {
847
+ return this._maxLoopCount;
848
+ }
849
+ set maxLoopCount(maxLoopCount) {
850
+ this._maxLoopCount = maxLoopCount;
851
+ }
852
+ }
853
+
854
+ class KeyFramesContiner {
855
+ _keyframes;
856
+ constructor() {
857
+ this._keyframes = [];
858
+ }
859
+ get keyframes() {
860
+ return this._keyframes;
861
+ }
862
+ from(value) {
863
+ if (this._keyframes.length == 0) {
864
+ this._keyframes.push({ percentage: 0, value });
865
+ } else {
866
+ if (this._keyframes[0].percentage == 0) {
867
+ this._keyframes[0].value = value;
868
+ } else {
869
+ this._keyframes.unshift({ percentage: 0, value });
870
+ }
871
+ }
872
+ return this;
873
+ }
874
+ to(value) {
875
+ if (this._keyframes.length == 0) {
876
+ this._keyframes.push({ percentage: 1, value });
877
+ } else {
878
+ if (this._keyframes[this._keyframes.length - 1].percentage == 1) {
879
+ this._keyframes[this._keyframes.length - 1].value = value;
880
+ } else {
881
+ this._keyframes.push({ percentage: 1, value });
882
+ }
883
+ }
884
+ return this;
885
+ }
886
+ insertAt(percentage, value) {
887
+ this._keyframes.push({ percentage, value });
888
+ }
889
+ clearFrames() {
890
+ this._keyframes = [];
891
+ }
892
+ }
893
+ export {
894
+ stringHelperFunctions,
895
+ rgbHelperFunctions,
896
+ pointHelperFunctions,
897
+ numberHelperFunctions,
898
+ linear,
899
+ integerHelperFunctions,
900
+ StringAnimationHelper,
901
+ RGBAnimationHelper,
902
+ PointAnimationHelper,
903
+ NumberAnimationHelper,
904
+ KeyFramesContiner,
905
+ IntegerAnimationHelper,
906
+ CompositeAnimation,
907
+ Animation
908
+ };
909
+
910
+ //# debugId=CA39ED3899929ABA64756E2164756E21
4
911
 
5
912
  //# sourceMappingURL=index.js.map