-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.d.ts
1580 lines (1367 loc) · 62.4 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
declare module 'anim8js'
{
// S = Subject
// A = Attributes with strict type
// V = A "primitive" data type (2d, 3d, color, number, quaternion, string)
export type AttributesInput<A> = keyof A | (keyof A)[] | { [P in keyof A]?: any };
export type AttributesValues<A> = Partial<A>;
export type Dynamic<V> =
(() => V) |
((index: number, delta: number) => V);
export interface Computed<V>
{
(attrimator: Attrimator, animator: Animator): (V | Dynamic<V>);
computed: true;
}
export type Value<V> =
V |
Dynamic<V> |
Computed<V> |
Parameters<V>;
export type Value2d = { x: number, y: number };
export type Value3d = { x: number, y: number, z: number };
export type ValueNumber = number;
export type ValueRGB = { r: number, g: number, b: number };
export type ValueRGBA = { r: number, g: number, b: number, a: number };
export type ValueString = string;
export type ValueQuat = { x: number, y: number, z: number, angle: number };
export type InputScalar<V> =
number |
string |
true |
Dynamic<V> |
Computed<V> |
Parameters<V> |
(number | string)[];
export type InputObject<V> =
InputScalar<V> |
{ [P in keyof V]?: number | string };
export type Input<V> =
V extends object ? InputObject<V> : InputScalar<V>;
export type Inputs<A> =
{ [K in keyof A]?: Input<A[K]> };
export class Calculator<V>
{
public readonly ZERO: V;
public readonly ONE: V;
public readonly INFINITY: V;
public createConstants (): void;
public parse (input: Input<V>, defaultValue?: V, ignoreRelative?: boolean): Value<V>;
public parseArray (input: Input<V>[], output: Value<V>[], defaultValue?: Input<V>): Value<V>;
public copy (out: V, copy: V): V;
public zero (out: V): V;
public clone (clone: V): V;
public create (): V;
public scale (out: V, scale: number): V;
public add (out: V, amount: V): V;
public adds (out: V, amount: V, amountScale: number): V;
public sub (out: V, amount: V): V;
public mul (out: V, scale: V): V;
public div (out: V, denominator: V): V;
public interpolate (out: V, start: V, end: V, delta: number): V;
public random (out: V, min: V, max: V): V;
public distance (a: V, b: V): number;
public distanceSq (a: V, b: V): number;
public length (a: V): number;
public lengthSq (a: V): number;
public isValid (a: any): a is V;
public isNaN (a: V): boolean;
public isZero (a: V, epsilon: number): boolean;
public isEqual (a: V, b: V, epsilon: number): boolean;
public min (out: V, a: V, b: V): V;
public max (out: V, a: V, b: V): V;
public dot (a: V, b: V): number;
public clamp (out: V, min: number, max: number): V;
public setLength (out: V, length: number): V;
}
export type CalculatorInput<V> = keyof CalculatorMap | Calculator<V>;
export interface CalculatorMap
{
'number': Calculator<ValueNumber>;
'2d': Calculator<Value2d>;
'3d': Calculator<Value3d>;
'quat': Calculator<ValueQuat>;
'quaternion': Calculator<ValueQuat>;
'rgb': Calculator<ValueRGB>;
'rgba': Calculator<ValueRGBA>;
'color': Calculator<ValueRGBA>;
'string': Calculator<ValueString>;
'default': Calculator<ValueNumber>;
}
export const Calculators: CalculatorMap;
export const Calculator2d: Calculator<Value2d>;
export const Calculator3d: Calculator<Value3d>;
export const CalculatorNumber: Calculator<ValueNumber>;
export const CalculatorQuaternion: Calculator<ValueQuat>;
export const CalculatorRGB: Calculator<ValueRGB>;
export const CalculatorRGBA: Calculator<ValueRGBA>;
export const CalculatorString: Calculator<ValueString>;
export class FastMap<V>
{
public values: V[];
public keys: string[];
public indices: { [key: string]: number };
public constructor (input?: FastMap<V> | { [prop: string]: V });
public reset (): this;
public put (key: string, value: V): this;
public rekey (fromKey: string, toKey: string): this;
public putMap (map: FastMap<V>): this;
public get (key: string): V | undefined;
public remove (key: string): this;
public removeAt (index: number): this;
public indexOf (key: string): number;
public has (key: string): boolean;
public hasOverlap (map: FastMap<V>): boolean;
public size (): number
public clear (): this;
}
export class AttrimatorMap<A> extends FastMap<Attrimator<A, keyof A>>
{
public setGroup (groupId: number, force?: boolean, deep?: boolean): void;
public delay (time: number): this;
public queue<K extends keyof A> (attrimator: Attrimator<A, K>): Attrimator<A, K> | undefined;
public queueMap (map: AttrimatorMap<A>, offset: number, onNewAttribute?: <K extends keyof A>(attrimator: Attrimator<A, K>) => void, context?: object): this;
public insertMap (map: AttrimatorMap<A>, onNewAttribute?: <K extends keyof A>(attrimator: Attrimator<A, K>) => any, context?: object): this;
public unqueueAt (index: number): this;
public playMapAt (attrimatorMap: AttrimatorMap<A>, all: boolean, time: number): this;
public playAttrimatorAt (attrimator: Attrimator<A, keyof A>, time: number): void;
public transitionMap (transition: Transition, attrimatorMap: AttrimatorMap<A>, getValue: <K extends keyof A>(attr: K) => A[K], getAttribute: <K extends keyof A>(attr: K) => Attribute<A, K> | undefined, placeAttrimator: <K extends keyof A>(attrimator: Attrimator<A, K>) => Attrimator<A, K> | undefined, getValueAt: <K extends keyof A>(attrimator: Attrimator<A, K>, relativeTime: number, out: AttributesValues<A>) => A[K], stopAttrimator: <K extends keyof A>(attrimator: Attrimator<A, K>, relativeTime: number) => void, context: object): this;
public finishNotPresent (attrimatorMap: AttrimatorMap<A>, delay?: number): this;
public stopNotPresentAt (attrimatorMap: AttrimatorMap<A>, time: number): this;
public clone (): AttrimatorMap<A>;
public timeRemaining (returnInfinity?: boolean): number;
public applyCycle (nextCycle: number): number;
public iterate (callback: <K extends keyof A>(attrimator: Attrimator<A, K>, depth: number, previous?: Attrimator<A, K>) => void): this;
}
export interface Attribute<A, K extends keyof A>
{
name: K;
calculatorName: keyof CalculatorMap;
calculator: Calculator<A[K]>;
defaultValue: A[K];
parse (input: Input<A[K]>, defaultValue?: A[K]): Value<A[K]>;
cloneDefault (): A[K];
}
export class Animator<A = any, S = any> extends EventSource implements Animatable<A, S>
{
public subject: S;
public attrimators: AttrimatorMap<A>;
public attrimatorsAdded: string[];
public frame: AttributesValues<A>;
public updated: AttributesValues<A>;
public finished: boolean;
public factory: Factory<A, S>;
public active: boolean;
public cycleCurrent: number;
public cycleNext: number;
public cycleEnded: number;
public constructor (subject: S);
public reset (subject: S): this;
public newCycle<K extends keyof A> (attrimators: AttrimatorMap<A> | Attrimator<A, K>): this;
public applyCurrentCycle (): this;
public endCurrentCycle (): this;
public getAttribute<K extends keyof A> (attr: K): Attribute<A, K> | undefined;
public restore (): this;
public applyInitialState (): this;
public preupdate (now: number): this;
public setDefault (attr: keyof A): void;
public update (now: number): this;
public placeAttrimator<K extends keyof A> (attrimator: Attrimator<A, K>): Attrimator<A, K> | undefined;
public apply (): this;
public trimAttrimators (): this;
public value (attr: keyof A): any;
public activate (): this;
public deactivate (): this;
public destroy (): this;
public spring<K extends keyof A> (spring: SpringLinearDefinition<A, K>): SpringLinear<A, K>;
public spring<K extends keyof A> (spring: SpringDistanceDefinition<A, K>): SpringDistance<A, K>;
public play (animation: AnimationInput<A>, options?: OptionsInput, all?: boolean, cache?: boolean): this;
public playAttrimators (attrimatorMap: AttrimatorMap<A>, all?: boolean): this;
public unplay (animation: AnimationInput<A>, transition?: TransitionInput, options?: OptionsInput, all?: boolean, cache?: boolean): this;
public unplayAttrimators (attrimatorMap: AttrimatorMap<A>, transition?: Transition, all?: boolean): this;
public queue (animation: AnimationInput<A>, options?: OptionsInput, cache?: boolean): this;
public queueAttrimators (attrimatorMap: AttrimatorMap<A>): this;
public insert (animation: AnimationInput<A>, options?: OptionsInput, cache?: boolean): this;
public insertAttrimators (attrimatorMap: AttrimatorMap<A>): this;
public transition (transition: TransitionInput, animation: AnimationInput<A>, options?: OptionsInput, all?: boolean, cache?: boolean): this;
public transitionAttrimators (transition: Transition, attrimatorMap: AttrimatorMap<A>, all?: boolean): this;
private transitionGetValue <K extends keyof A>(attr: K): A[K];
private transitionGetValueAt <K extends keyof A>(attrimator: Attrimator<A, K>, relativeTime: number, out: AttributesValues<A>): A[K];
private transitionStopAttrimator <K extends keyof A>(attrimator: Attrimator<A, K>, relativeTime: number): void;
public tweenTo<K extends keyof A> (attr: K, target: Input<A[K]>, options?: OptionsInput, cache?: boolean, placeholder1?: any): this;
public tweenManyTo (targets: Inputs<A>, options?: OptionsInput, cache?: boolean, placeholder1?: any): this;
public tweenFrom<K extends keyof A> (attr: K, starting: Input<A[K]>, options?: OptionsInput, cache?: boolean, placeholder1?: any): this;
public tweenManyFrom (startings: Inputs<A>, options?: OptionsInput, placeholder1?: any): this;
public tween<K extends keyof A> (attr: K, starts: Input<A[K]>, ends: Input<A[K]>, options?: OptionsInput, cache?: boolean, placeholder1?: any): this;
public tweenMany (starts: Inputs<A>, ends: Inputs<A>, options?: OptionsInput, cache?: boolean, placeholder1?: any): this;
public move<K extends keyof A> (attr: K, amount: Input<A[K]>, options?: OptionsInput, cache?: boolean, placeholder1?: any): this;
public moveMany (amounts: Inputs<A>, options?: OptionsInput, cache?: boolean, placeholder1?: any): this;
public ref<K extends keyof A> (attr: K, placeholder1?: any, placeholder2?: any): () => A[K];
public follow<K extends keyof A> (attr: K, path: PathInput<A[K]>, options?: OptionsInput, cache?: boolean, placeholder1?: any): this;
public attrimatorsFor (): Attrimator<A, keyof A>[];
public attrimatorsFor (attributes: AttributesInput<A>): Attrimator<A, keyof A>[];
public attrimatorsFor (attributes: AttributesInput<A>, callback: <K extends keyof A>(attrimator: Attrimator<A, K>, attr: K) => void): this;
public attrimatorsFor (attributes: undefined, callback: <K extends keyof A>(attrimator: Attrimator<A, K>, attr: K) => void): this;
public stop (attributes?: AttributesInput<A>): this;
public end (attributes?: AttributesInput<A>): this;
public finish (attributes?: AttributesInput<A>): this;
public nopeat (attributes?: AttributesInput<A>): this;
public pause (attributes?: AttributesInput<A>): this;
public resume (attributes?: AttributesInput<A>): this;
public set (attributes: AttributesValues<A>): this;
public unset (attributes?: AttributesInput<A>): this;
public get (attributes: AttributesValues<A>): this;
public timeRemaining (): number;
public hasAttrimators (): boolean;
public getSubject<T> (wrapper?: (subject: S) => T): T;
public invoke (func: EventCallback, context?: object, args?: any[]): this;
public defer (eventType: 'on' | 'once', event: string, callback?: EventCallback): Defer<Animator<A, S>, Animator<A, S>>;
public onCycleStart (callback: EventCallback, context?: object): this;
public onCycleEnd (callback: EventCallback, context?: object): this;
}
export class Animators<A = any, S = any> implements Animatable<A, S>
{
public $: Animator<A, S>[];
public constructor (input?: Animator<A, S>[]);
public push (animator: Animator<A, S>): this;
public length (): number;
public at (index: number): Animator<A, S>;
public each (iterator: (animator: Animator<A, S>, index: number) => void, context?: object): this;
public fill (animators: Animator<A, S>[]): this;
public filter (filterer: (animator: Animator<A, S>) => boolean): this;
public getSubjects<T> (wrapper?: (subject: S) => T): T[];
public first (): Animator<A, S>;
public reverse (): this;
public activate (): this;
public sequence (delay?: number, easing?: Easing): Sequence<A, S>;
public timeRemaining (): number;
public preupdate (now: number, max?: number): this;
public update (now: number, max?: number): this;
public apply (max?: number): this;
public handleFinished (animator: Animator<A, S>): boolean;
public restore (): this;
public placeAttrimator<K extends keyof A> (attrimator: Attrimator<A, K>): Attrimator<A, K> | undefined;
public applyInitialState (): this;
public trimAttrimators (): this;
public deactivate (): this;
public destroy (): this;
public spring<K extends keyof A> (spring: SpringLinearDefinition<A, K>): SpringLinear<A, K>;
public spring<K extends keyof A> (spring: SpringDistanceDefinition<A, K>): SpringDistance<A, K>;
public play (animation: AnimationInput<A>, options?: OptionsInput, all?: boolean, cache?: boolean): this;
public playAttrimators (attrimatorMap: AttrimatorMap<A>, all?: boolean): this;
public unplay (animation: AnimationInput<A>, transition?: TransitionInput, options?: OptionsInput, all?: boolean, cache?: boolean): this;
public unplayAttrimators (attrimatorMap: AttrimatorMap<A>, transition?: Transition, all?: boolean): this;
public queue (animation: AnimationInput<A>, options?: OptionsInput, cache?: boolean): this;
public queueAttrimators (attrimatorMap: AttrimatorMap<A>): this;
public insert (animation: AnimationInput<A>, options?: OptionsInput, cache?: boolean): this;
public insertAttrimators (attrimatorMap: AttrimatorMap<A>): this;
public transition (transition: TransitionInput, animation: AnimationInput<A>, options?: OptionsInput, all?: boolean, cache?: boolean): this;
public transitionAttrimators (transition: Transition, attrimatorMap: AttrimatorMap<A>, all?: boolean): this;
public tweenTo<K extends keyof A> (attr: K, target: Input<A[K]>, options?: OptionsInput, cache?: boolean): this;
public tweenManyTo (targets: Inputs<A>, options?: OptionsInput, cache?: boolean): this;
public tweenFrom<K extends keyof A> (attr: K, starting: Input<A[K]>, options?: OptionsInput, cache?: boolean): this;
public tweenManyFrom (startings: Inputs<A>, options?: OptionsInput): this;
public tween<K extends keyof A> (attr: K, starts: Input<A[K]>, ends: Input<A[K]>, options?: OptionsInput, cache?: boolean): this;
public tweenMany (starts: Inputs<A>, ends: Inputs<A>, options?: OptionsInput, cache?: boolean): this;
public move<K extends keyof A> (attr: K, amount: Input<A[K]>, options?: OptionsInput, cache?: boolean): this;
public moveMany (amounts: Inputs<A>, options?: OptionsInput, cache?: boolean): this;
public follow<K extends keyof A> (attr: K, path: PathInput<A[K]>, options?: OptionsInput, cache?: boolean): this;
public attrimatorsFor (): Attrimator<A, keyof A>[];
public attrimatorsFor (attributes: AttributesInput<A>): Attrimator<A, keyof A>[];
public attrimatorsFor (attributes: AttributesInput<A>, callback: <K extends keyof A>(attrimator: Attrimator<A, K>, attr: K) => void): this;
public attrimatorsFor (attributes: undefined, callback: <K extends keyof A>(attrimator: Attrimator<A, K>, attr: K) => void): this;
public stop (attributes?: AttributesInput<A>): this;
public end (attributes?: AttributesInput<A>): this;
public finish (attributes?: AttributesInput<A>): this;
public nopeat (attributes?: AttributesInput<A>): this;
public pause (attributes?: AttributesInput<A>): this;
public resume (attributes?: AttributesInput<A>): this;
public set (attributes: AttributesValues<A>): this;
public unset (attributes?: AttributesInput<A>): this;
public get (attributes: AttributesValues<A>): this;
public hasAttrimators (): boolean;
public invoke (func: EventCallback, context?: object, args?: any[]): this;
public onCycleStart (callback: EventCallback, context?: object): this;
public onCycleEnd (callback: EventCallback, context?: object): this;
}
export interface Animatable<A = any, S = any>
{
activate (): this;
timeRemaining (): number;
preupdate (now: number, max?: number): this;
update (now: number, max?: number): this;
apply (max?: number): this;
restore (): this;
placeAttrimator<K extends keyof A> (attrimator: Attrimator<A, K>): Attrimator<A, K> | undefined;
applyInitialState (): this;
trimAttrimators (): this;
deactivate (): this;
destroy (): this;
spring<K extends keyof A> (spring: SpringInput<A, K>): Spring<A, K>;
play (animation: AnimationInput<A>, options?: OptionsInput, all?: boolean, cache?: boolean): this;
playAttrimators (attrimatorMap: AttrimatorMap<A>, all?: boolean): this;
unplay (animation: AnimationInput<A>, transition?: TransitionInput, options?: OptionsInput, all?: boolean, cache?: boolean): this;
unplayAttrimators (attrimatorMap: AttrimatorMap<A>, transition?: Transition, all?: boolean): this;
queue (animation: AnimationInput<A>, options?: OptionsInput, cache?: boolean): this;
queueAttrimators (attrimatorMap: AttrimatorMap<A>): this;
insert (animation: AnimationInput<A>, options?: OptionsInput, cache?: boolean): this;
insertAttrimators (attrimatorMap: AttrimatorMap<A>): this;
transition (transition: TransitionInput, animation: AnimationInput<A>, options?: OptionsInput, all?: boolean, cache?: boolean): this;
transitionAttrimators (transition: Transition, attrimatorMap: AttrimatorMap<A>, all?: boolean): this;
tweenTo<K extends keyof A> (attr: K, target: Input<A[K]>, options?: OptionsInput, cache?: boolean): this;
tweenManyTo (targets: Inputs<A>, options?: OptionsInput, cache?: boolean): this;
tweenFrom<K extends keyof A> (attr: K, starting: Input<A[K]>, options?: OptionsInput, cache?: boolean): this;
tweenManyFrom (startings: Inputs<A>, options?: OptionsInput): this;
tween<K extends keyof A> (attr: K, starts: Input<A[K]>, ends: Input<A[K]>, options?: OptionsInput, cache?: boolean): this;
tweenMany (starts: Inputs<A>, ends: Inputs<A>, options?: OptionsInput, cache?: boolean): this;
move<K extends keyof A> (attr: K, amount: Input<A[K]>, options?: OptionsInput, cache?: boolean): this;
moveMany (amounts: Inputs<A>, options?: OptionsInput, cache?: boolean): this;
follow<K extends keyof A> (attr: K, path: PathInput<A[K]>, options?: OptionsInput, cache?: boolean): this;
attrimatorsFor (): Attrimator<A, keyof A>[];
attrimatorsFor (attributes: AttributesInput<A>): Attrimator<A, keyof A>[];
attrimatorsFor (attributes: AttributesInput<A>, callback: <K extends keyof A>(attrimator: Attrimator<A, K>, attr: K) => void): this;
attrimatorsFor (attributes: undefined, callback: <K extends keyof A>(attrimator: Attrimator<A, K>, attr: K) => void): this;
stop (attributes?: AttributesInput<A>): this;
end (attributes?: AttributesInput<A>): this;
finish (attributes?: AttributesInput<A>): this;
nopeat (attributes?: AttributesInput<A>): this;
pause (attributes?: AttributesInput<A>): this;
resume (attributes?: AttributesInput<A>): this;
set (attributes: AttributesValues<A>): this;
unset (attributes?: AttributesInput<A>): this;
get (attributes: AttributesValues<A>): this;
hasAttrimators (): boolean;
invoke (func: EventCallback, context?: object, args?: any[]): this;
onCycleStart (callback: EventCallback, context?: object): this;
onCycleEnd (callback: EventCallback, context?: object): this;
}
export class Sequence<A = any, S = any>
{
public animators: Animators<A, S>;
public delay: number;
public easing: Easing;
public constructor (animators: Animators<A, S>, delay?: Delay, easing?: EasingInput);
public maxDelay (): number;
public createAttrimators (template: Animation<A>, i: number): AttrimatorMap<A>;
public reverse (): this;
public play (animation: AnimationInput<A>, options?: OptionsInput, all?: boolean, cache?: boolean): this;
public queue (animation: AnimationInput<A>, options?: OptionsInput, cache?: boolean): this;
public insert (animation: AnimationInput<A>, options?: OptionsInput, cache?: boolean): this;
public transition (transition: TransitionInput, animation: AnimationInput<A>, all?: boolean, options?: OptionsInput, cache?: boolean): this;
public add (): this;
}
export class EventSource
{
public on (events: EventsInput, callback: EventCallback, context?: object): this;
public once (events: EventsInput, callback: EventCallback, context?: object): this;
public off (events?: EventsInput, callback?: EventCallback): this;
public trigger (event: string, argument: any): this;
}
export type EventCallback = (...args: any) => any;
export type EventsInput = string | string[] | { [event: string]: any };
export type BuilderInput<A> = string | Builder<A>;
export class Builder<A>
{
public parse (animation: AnimationDefinition<A>, options: Options, attrimatorMap: AttrimatorMap<A>, helper: BuilderHelper<A>): void;
public merge (animation: AnimationDefinition<A>, newOptions: Options, oldOptions: Options, attrimatorMap: AttrimatorMap<A>, helper: BuilderHelper<A>): void;
public mergeAttrimator<K extends keyof A> (e: Attrimator<A, K>, attr: K, helper: BuilderHelper<A>, factory: Factory<A, any>): void;
public submerge (animation: AnimationDefinition<A>, newOptions: Options, oldOptions: Options, attrimatorMap: AttrimatorMap<A>): void;
public static nextMergeId (): number;
}
export const BuilderAnd: Builder<any>;
export const BuilderDeltas: Builder<any>;
export const BuilderFinal: Builder<any>;
export const BuilderInitial: Builder<any>;
export const BuilderKeyframe: Builder<any>;
export const BuilderMove: Builder<any>;
export const BuilderPath: Builder<any>;
export const BuilderPhysics: Builder<any>;
export const BuilderQueue: Builder<any>;
export const BuilderSpring: Builder<any>;
export const BuilderTravel: Builder<any>;
export const BuilderTweenFrom: Builder<any>;
export const BuilderTweenTo: Builder<any>;
export class BuilderHelper<A>
{
public input: AnimationDefinition<A>;
public oldOptions: Options;
public newOptions: Options;
public forObject: any;
public prepareSpecifics (specifics: string): void;
public parseEasing (attr: keyof A): EasingInput;
public parseRepeat (attr: keyof A): number;
public parseDelay (attr: keyof A): number;
public parseSleep (attr: keyof A): number;
public parseDuration (attr: keyof A): number;
public parseOffset (attr: keyof A): number;
public parseScale (attr: keyof A): number;
public parseScaleBase<K extends keyof A> (attr: K): A[K];
public parseFirst (attr: keyof A, option: keyof A, specifics: keyof A): any;
public parseEvent<K extends keyof A> (attr: K, path: Path<A[K]>, builder: Builder<A>, hasInitialState: boolean, mergeId: number): Event<A, K>
public parseNumber (attr: keyof A, parseFunction: (input: any) => any, parseOptionsFunction: (options: Options) => Options, option: string, optionAdd: string, optionScale: string, specifics: string): number;
public parseParameters (): object;
public mergeEasing (attr: keyof A, current?: Easing): Easing;
public mergeRepeat (attr: keyof A, current?: number): number;
public mergeDelay (attr: keyof A, current?: number): number;
public mergeSleep (attr: keyof A, current?: number): number;
public mergeDuration (attr: keyof A, current?: number): number;
public mergeOffset (attr: keyof A, current?: number): number;
public mergeScale (attr: keyof A, current?: number): number;
public mergeScaleBase<K extends keyof A> (attr: keyof A, current?: A[K]): A[K];
public mergeParameters (current?: object): object;
public mergeFirst<T> (attr: keyof A, current: T, parseOptionFunction: (value: T, current: T) => T, option: string, specifics: string): T;
public mergeNumber (attr: keyof A, current: number, parseOptionFunction: (value: number, current: number) => number, option: string, optionAdd: string, optionScale: string, specifics: string): number;
}
export type FactoryInput<A, S> = string | Factory<A, S>;
export class Factory<A, S>
{
public priority: number;
public is (subject: any): subject is S;
public animatorFor (subject: S): Animator<A, S>;
public animatorsFor (subject: S, animators: Animators<A, S>): void;
public destroy (animator: Animator<A, S>): void;
public attribute<K extends keyof A> (attr: K): Attribute<A, K> | undefined;
}
export class FactoryObject extends Factory<any, any>
{
public attributes: {
[attr: string]: Attribute<any, any>
};
}
export const Factories:
{
[factoryName: string]: Factory<any, any>
}
export const object:
{
[custom: string]: Partial<Attribute<any, any>>
}
export class Attrimator<A = any, K extends keyof A = any>
{
public attribute: K;
public builder: Builder<A>;
public next: Attrimator<A, K> | undefined;
public startTime: number;
public pauseTime: number;
public elapsed: number;
public stopTime: number;
public paused: boolean;
public cycle: number;
public delay: Delay;
public offset: Offset;
public reset (attribute: K, builder: Builder<A>, next?: Attrimator<A, K>): void;
public prestart (now: number): void;
public prestartNext (overrideNext?: boolean): void;
public start (now: number, animator: Animator<A>): void;
public startCycle (frame: AttributesValues<A>): boolean;
public setTime (now: number, frame: AttributesValues<A>): boolean;
public update (elapsed: number, frame: AttributesValues<A>): boolean;
public getElapsed (): number;
public stopIn (milliseconds: number): this;
public stopAt (time: number): this;
public nopeat (): this;
public valueAt (time: number, out: A[K]): A[K];
public valueAtSearch (time: number, out: A[K]): A[K] | false;
public attrimatorAt (time: number): Attrimator<A, K>;
public totalTime (): number;
public timeRemaining (): number;
public clone (): Attrimator<A, K>;
public hasComputed (): boolean;
public isInfinite (): boolean;
public pause (): this;
public resume (): this;
public isPaused (): boolean;
public finish (frame: AttributesValues<A>): boolean;
public isFinished (): boolean;
public getBuilder (): Builder<A>
public queue (next: Attrimator<A, K>): this;
public nextAt (next: Attrimator<A, K>, time: number): this;
public parseValue (animator: Animator<A>, value: Input<A[K]>, defaultValue?: A[K]): A[K];
}
export type SpringInput<A = any, K extends keyof A = any> =
string |
Spring<A, K> |
SpringDefinition<A, K>
export interface SpringDefinition<A = any, K extends keyof A = any>
{
type: keyof SpringMap;
attribute?: K;
calculator?: CalculatorInput<A[K]>;
position?: Input<A[K]>;
rest?: Input<A[K]>;
velocity?: Input<A[K]>;
gravity?: Input<A[K]>;
finishOnRest?: boolean;
}
export class Spring<A = any, K extends keyof A = any> extends Attrimator<A, K>
{
public calculator: Calculator<A[K]>;
public rest: Value<A[K]>;
public position: Value<A[K]>;
public gravity: Value<A[K]>;
public velocity: Value<A[K]>;
public finishOnRest: boolean;
public set (attribute: K, calculator: CalculatorInput<A[K]>, rest: Input<A[K]>, position: Input<A[K]>, velocity?: Input<A[K]>, gravity?: Input<A[K]>, finishOnRest?: boolean): void;
public resolveRest (): A[K];
public updateVelocity (dt: number): void;
public static MAX_DT: number;
public static EPSILON: number;
}
export interface SpringMap
{
'distance': <A, K extends keyof A>(def: SpringDistanceDefinition<A, K>) => SpringDistance<A, K>;
'linear': <A, K extends keyof A>(def: SpringLinearDefinition<A, K>) => SpringLinear<A, K>;
}
export interface SpringDistanceDefinition<A = any, K extends keyof A = any> extends SpringDefinition<A, K>
{
type: 'distance';
distance: number;
damping: number;
stiffness: number;
}
export class SpringDistance<A = any, K extends keyof A = any> extends Spring<A, K>
{
public distance: number;
public damping: number;
public stiffness: number;
public constructor (attribute: K, calculator: Calculator<A[K]>, position: Input<A[K]>, rest: Input<A[K]>, distance: number, damping: number, stiffness: number, velocity?: Input<A[K]>, gravity?: Input<A[K]>, finishOnRest?: boolean);
}
export interface SpringLinearDefinition<A = any, K extends keyof A = any> extends SpringDefinition<A, K>
{
type: 'linear';
damping: Input<A[K]>;
stiffness: Input<A[K]>;
}
export class SpringLinear<A = any, K extends keyof A = any> extends Spring<A, K>
{
public damping: Value<A[K]>;
public stiffness: Value<A[K]>;
public constructor (attribute: K, calculator: Calculator<A[K]>, position: Input<A[K]>, rest: Input<A[K]>, damping: Input<A[K]>, stiffness: Input<A[K]>, velocity?: Input<A[K]>, gravity?: Input<A[K]>, finishOnRest?: boolean);
}
export const enum EventState
{
DELAYED = 1,
ANIMATING = 2,
SLEEPING = 4,
FINISHED = 8
}
export class Event<A = any, K extends keyof A = any> extends Attrimator<A, K>
{
public path: Path<A[K]>;
public duration: Duration;
public easing: EasingInput;
public sleep: Sleep;
public repeat: Repeat;
public scale: Scale;
public scaleBase: ScaleBase<A[K]>;
public hasInitialState: boolean;
public input: AnimationDefinition<A> | undefined;
public mergeId: number | undefined;
public state: EventState;
public constructor (attribute: K, path: Path<A[K]>, duration: Duration, easing: EasingInput, delay: Delay, sleep: Sleep, offset: Offset, repeat: Repeat, scale: Scale, scaleBase: ScaleBase<A[K]>, parameters: object, hasInitialState: boolean, builder: Builder<A>, next?: Attrimator<A, K>, input?: AnimationDefinition<A>, mergeId?: number);
public computeValue (baseValue: A[K], delta: number): A[K];
public applyValue (frame: AttributesValues<A>, baseValue: A[K], delta: number): A[K];
public static fromOptions <A, K extends keyof A>(attr: K, path: Path<A[K]>, options?: Options): Event<A, K>;
}
export class Oncer<A = any, K extends keyof A = any> extends Attrimator<A, K>
{
public value: Value<A[K]>;
public delay: number;
public applied: boolean;
public input: AnimationInput<A>;
public constructor (attribute: K, value: Input<A[K]>, delay: Delay, hasInitialState: boolean, builder: Builder<A>, next?: Attrimator<A, K>, input?: AnimationInput<A>);
public getValue (): A[K];
}
export class Physics<A = any, K extends keyof A = any> extends Attrimator<A, K>
{
public value: Value<A[K]>;
public delay: number;
public applied: boolean;
public input: AnimationInput<A>;
public constructor (attribute: K, value: Input<A[K]>, delay: Delay, hasInitialState: boolean, builder: Builder<A>, next?: Attrimator<A, K>, input?: AnimationInput<A>);
public getValue (): A[K];
}
export type AnimationInput<A = any> = string | Animation<A> | AnimationDefinition<A>;
export interface AnimationDefinition<A = any>
{
factory?: FactoryInput<A, any>;
initial?: BuilderInitialInputs<A>;
values?: BuilderDeltasValuesInputs<A>;
deltas?: BuilderDeltasDeltasInputs<A>;
point?: BuilderPointInput<A>;
keyframe?: BuilderKeyframeInputs<A>;
move?: BuilderMoveInputs<A>;
path?: BuilderPathInputs<A>;
physics?: BuilderPhysicsInput<A>;
springs?: BuilderSpringsInputs<A>;
travel?: BuilderTravelInputs<A>;
tweenFrom?: BuildeTweenFromInputs<A>;
tweenTo?: BuildeTweenToInputs<A>,
final?: BuilderFinalInputs<A>;
and?: AnimationDefinition<A>;
queue?: AnimationDefinition<A>;
easings?: AnimationOptions<A, EasingInput>;
repeats?: AnimationOptions<A, Repeat>;
delays?: AnimationOptions<A, Delay>;
sleeps?: AnimationOptions<A, Sleep>;
durations?: AnimationOptions<A, Duration>;
offsets?: AnimationOptions<A, Offset>;
scales?: AnimationOptions<A, number>;
scaleBases?: Inputs<A>;
parameters?: AnimationOptions<A, object>;
}
export type AnimationOptions<A, T> =
T | { [P in keyof A]?: T };
export type BuilderDeltasValuesInputs<A> =
{ [P in keyof A]?: Input<A[P]>[]; }
export type BuilderDeltasDeltasInputs<A> =
{ [P in keyof A]?: number[]; } | number[];
export type BuilderFinalInputs<A> =
Inputs<A>;
export type BuilderInitialInputs<A> =
Inputs<A>;
export type BuilderKeyframeInputs<A> =
{ [frame: string]: Inputs<A> };
export type BuilderMoveInputs<A> =
Inputs<A>;
export type BuilderPathInputs<A> =
{ [P in keyof A]?: PathInput<A[P]>; };
export type BuilderPhysicsInput<A> =
{
[P in keyof A]?: {
calculator?: CalculatorInput<A[P]>;
position?: Input<A[P]>;
velocity?: Input<A[P]>;
acceleration?: Input<A[P]>;
terminal?: number;
stopAt?: number | string;
}
};
export type BuilderPointInput<A> =
Inputs<A>;
export type BuilderSpringsInputs<A> =
{ [P in keyof A]?: SpringInput<A, P>; };
export type BuilderTravelInputs<A> =
{
[P in keyof A]?: {
from?: Input<A[P]>;
to?: Input<A[P]>;
velocity?: number;
acceleration?: number;
terminal?: number;
epsilon?: number;
}
};
export type BuildeTweenFromInputs<A> =
Inputs<A>;
export type BuildeTweenToInputs<A> =
Inputs<A>;
export class Animation<A = any>
{
public name: string | undefined;
public input: AnimationDefinition<A>;
public options: Options | undefined;
public attrimators: AttrimatorMap<A>;
public newAttrimators (): AttrimatorMap<A>;
public merge (options: Options | undefined, attrimatorMap: AttrimatorMap<A>): void;
}
export const Animations:
{
[animationName: string]: Animation<any>
}
export type OptionsInput = string | string[] | Options;
export interface Options
{
repeat?: Repeat;
repeatAdd?: Repeat;
repeatScale?: Repeat;
sleep?: Sleep;
sleepAdd?: Sleep;
sleepScale?: Sleep;
delay?: Delay;
delayAdd?: Delay;
delayScale?: Delay;
scale?: Scale;
scaleAdd?: Scale;
scaleScale?: Scale;
offset?: Offset;
offsetAdd?: Offset;
offsetScale?: Offset;
duration?: Duration;
durationAdd?: Duration;
durationScale?: Duration;
easing?: EasingInput;
parameters?: object;
}
// export const Options: { [name: string]: Options }
export type TransitionInput = string | string[] | Transition;
export interface Transition
{
time: number;
outro: number;
intro: number;
easing: Easing;
granularity: number;
lookup: number;
}
export const Transitions: {
[name: string]: Transition
};
export type PathInput<V> = keyof PathMap | Path<V> | PathDefinition;
export interface PathDefinition
{
type: keyof PathMap;
name?: string;
}
export class Path<V>
{
public name: string | undefined;
public points: Value<V>[];
public calculator: Calculator<V>;
public computed: boolean;
public deterministic: boolean;
public reset (calculator: Calculator<V>, points: Value<V>[]): void;
public compute (out: V, delta: number): V;
public hasComputed (): boolean;
public isDeterministic (): boolean;
public examinePoints<T> (examiner: (point: V) => boolean, returnOnTrue: T, returnOnFalse: T): T;
public replaceComputed<A> (attrimator: Attrimator<A, keyof A>, animator: Animator<A>): (V | Dynamic<V>)[]
public resolvePoint (i: number, dt: number): V;
public isLinear (): boolean;
public length (granularity: number): number;
}
export interface PathMap
{
'point': <V>(def: PathPointDefinition<V>) => PathPoint<V>;
'combo': <V>(def: PathComboDefinition<V>) => PathCombo<V>;
'compiled': <V>(def: PathCompiledDefinition<V>) => PathCompiled<V>;
'cubic': <V>(def: PathCubicDefinition<V>) => PathCubic<V>;
'delta': <V>(def: PathDeltaDefinition<V>) => PathDelta<V>;
'series': <V>(def: PathSeriesDefinition<V>) => PathSeries<V>;
'jump': <V>(def: PathJumpDefinition<V>) => PathJump<V>;
'keyframe': <V>(def: PathKeyframeDefinition<V>) => PathKeyframe<V>;
'quadratic': <V>(def: PathQuadraticDefinition<V>) => PathQuadratic<V>;
'tween': <V>(def: PathTweenDefinition<V>) => PathTween<V>;
'sub': <V>(def: PathSubDefinition<V>) => PathSub<V>;
'quadratic-corner': <V>(def: PathQuadraticCornerDefinition<V>) => PathQuadraticCorner<V>;
'linear': <V>(def: PathLinearDefinition<V>) => PathLinear<V>;
'uniform': <V>(def: PathUniformDefinition<V>) => PathUniform<V>;
'hermite': <V>(def: PathHermiteDefinition<V>) => PathHermite<V>;
'bezier': <V>(def: PathBezierDefinition<V>) => PathBezier<V>;
'parametric': <V>(def: PathParametricDefinition<V>) => PathParametric<V>;
'catmull-rom': <V>(def: PathCatmullRomDefinition<V>) => PathCatmullRom<V>;
'basis-spline': <V>(def: PathBasisSplineDefinition<V>) => PathBasisSpline<V>;
}
export const Paths: PathMap;
export interface PathPointDefinition<V> extends PathDefinition
{
type: 'point';
calculator?: CalculatorInput<V>;
defaultValue?: Input<V>;
point: Input<V>;
}
export class PathPoint<V> extends Path<V>
{
public constructor (name: string | undefined, calculator: Calculator<V>, point: V);
public set (calculator: Calculator<V>, point: V): void;
}
export interface PathComboDefinition<V> extends PathDefinition
{
type: 'combo';
paths: PathInput<V>[];
uniform?: boolean;
granularity?: number;
}
export class PathCombo<V> extends Path<V>
{
public paths: Path<V>[];
public deltas: number[];
public uniform: boolean;
public granularity: number;
public linear: boolean;
public cachedLength: number | false;
public constructor (name: string | undefined, paths: Path<V>[], uniform?: boolean, granularity?: boolean);
public set (paths: Path<V>[], uniform?: boolean, granularity?: boolean): void;
}
export interface PathCompiledDefinition<V> extends PathDefinition
{
type: 'compiled';
path: PathInput<V>;
n?: number;
pointCount?: number;
}
export class PathCompiled<V> extends Path<V>
{
public path: Path<V>;
public pointCount: number;
public constructor (name: string | undefined, path: Path<V>, pointCoint: number);
public set (path: Path<V>, pointCoint: number): void;
public static compile<V> (calc: Calculator<V>, path: Path<V>, pointCount: number): V[];
}
export interface PathCubicDefinition<V> extends PathDefinition
{
type: 'cubic';
calculator?: CalculatorInput<V>;
defaultValue?: Input<V>;
p0: Input<V>;
p1: Input<V>;
p2: Input<V>;
p3: Input<V>;
}
export class PathCubic<V> extends Path<V>
{
public constructor (name: string | undefined, calculator: Calculator<V>, p0: Value<V>, p1: Value<V>, p2: Value<V>, p3: Value<V>);
public set (calculator: Calculator<V>, p0: Value<V>, p1: Value<V>, p2: Value<V>, p3: Value<V>): void;
}
export interface PathDeltaDefinition<V> extends PathDefinition
{
type: 'delta';
calculator?: CalculatorInput<V>;
defaultValue?: Input<V>;
deltas?: number[];
points: Input<V>[];
}
export class PathDelta<V> extends Path<V>
{
public deltas: number[];
public constructor (name: string | undefined, calculator: Calculator<V>, points: Value<V>, deltas: number[]);
public set (calculator: Calculator<V>, points: Value<V>, deltas: number[]): void;
}
export interface PathSeriesDefinition<V> extends PathDefinition
{
type: 'series',
calculator?: CalculatorInput<V>;
defaultValue?: Input<V>;
series?: number[];
points: Input<V>[]
}
export class PathSeries<V> extends Path<V>
{
public series: number[];
public constructor (name: string | undefined, calculator: Calculator<V>, points: Value<V>, series: number[]);
public set (calculator: Calculator<V>, points: Value<V>, series: number[]): void;
public between (i: number, delta: number): boolean;
}
export interface PathJumpDefinition<V> extends PathDefinition
{
type: 'jump',
calculator?: CalculatorInput<V>;
defaultValue?: Input<V>;
points: Input<V>[]
}
export class PathJump<V> extends Path<V>
{
public constructor (name: string | undefined, calculator: Calculator<V>, points: Value<V>);
public set (calculator: Calculator<V>, points: Value<V>): void;
}
export interface PathKeyframeDefinition<V> extends PathDefinition
{
type: 'keyframe',
calculator?: CalculatorInput<V>;
defaultValue?: Input<V>;
deltas?: number[];
easings?: EasingInput | EasingInput[];
points: Input<V>[]
}
export class PathKeyframe<V> extends Path<V>
{
public deltas: number[];
public easings: Easing[];
public constructor (name: string | undefined, calculator: Calculator<V>, points: Value<V>, deltas: number[], easings: Easing[]);
public set (calculator: Calculator<V>, points: Value<V>, deltas: number[], easings: Easing[]): void;
}