1 | type FunctionBasedParameter = (element: HTMLElement, index: number, length: number) => number;
|
2 | type AnimeCallbackFunction = (anim: anime.AnimeInstance) => void;
|
3 | type CustomEasingFunction = (el: HTMLElement, index: number, length: number) => (time: number) => number;
|
4 |
|
5 | type AnimeTarget = string | object | HTMLElement | SVGElement | NodeList | null;
|
6 |
|
7 | declare namespace anime {
|
8 | type EasingOptions =
|
9 | | "linear"
|
10 | | "easeInQuad"
|
11 | | "easeInCubic"
|
12 | | "easeInQuart"
|
13 | | "easeInQuint"
|
14 | | "easeInSine"
|
15 | | "easeInExpo"
|
16 | | "easeInCirc"
|
17 | | "easeInBack"
|
18 | | "easeInElastic"
|
19 | | "easeInBounce"
|
20 | | "easeOutQuad"
|
21 | | "easeOutCubic"
|
22 | | "easeOutQuart"
|
23 | | "easeOutQuint"
|
24 | | "easeOutSine"
|
25 | | "easeOutExpo"
|
26 | | "easeOutCirc"
|
27 | | "easeOutBack"
|
28 | | "easeOutElastic"
|
29 | | "easeOutBounce"
|
30 | | "easeInOutQuad"
|
31 | | "easeInOutCubic"
|
32 | | "easeInOutQuart"
|
33 | | "easeInOutQuint"
|
34 | | "easeInOutSine"
|
35 | | "easeInOutExpo"
|
36 | | "easeInOutCirc"
|
37 | | "easeInOutBack"
|
38 | | "easeInOutElastic"
|
39 | | "easeInOutBounce";
|
40 | type DirectionOptions = "reverse" | "alternate" | "normal";
|
41 |
|
42 | interface AnimeCallBack {
|
43 | begin?: AnimeCallbackFunction | undefined;
|
44 | change?: AnimeCallbackFunction | undefined;
|
45 | update?: AnimeCallbackFunction | undefined;
|
46 | complete?: AnimeCallbackFunction | undefined;
|
47 | loopBegin?: AnimeCallbackFunction | undefined;
|
48 | loopComplete?: AnimeCallbackFunction | undefined;
|
49 | changeBegin?: AnimeCallbackFunction | undefined;
|
50 | changeComplete?: AnimeCallbackFunction | undefined;
|
51 | }
|
52 |
|
53 | interface AnimeInstanceParams extends AnimeCallBack {
|
54 | loop?: number | boolean | undefined;
|
55 | autoplay?: boolean | undefined;
|
56 | direction?: DirectionOptions | string | undefined;
|
57 | }
|
58 |
|
59 | interface AnimeAnimParams extends AnimeCallBack {
|
60 | targets?: AnimeTarget | readonly AnimeTarget[] | undefined;
|
61 |
|
62 | duration?: number | FunctionBasedParameter | undefined;
|
63 | delay?: number | FunctionBasedParameter | undefined;
|
64 | endDelay?: number | FunctionBasedParameter | undefined;
|
65 | elasticity?: number | FunctionBasedParameter | undefined;
|
66 | round?: number | boolean | FunctionBasedParameter | undefined;
|
67 | keyframes?: readonly AnimeAnimParams[] | undefined;
|
68 |
|
69 | easing?: EasingOptions | string | CustomEasingFunction | ((el: HTMLElement) => string) | undefined;
|
70 |
|
71 | [AnyAnimatedProperty: string]: any;
|
72 | }
|
73 |
|
74 | interface AnimeParams extends AnimeInstanceParams, AnimeAnimParams {
|
75 | // Just need this to merge both Params interfaces.
|
76 | }
|
77 |
|
78 | interface Animatable {
|
79 | id: number;
|
80 | target: HTMLElement;
|
81 | total: number;
|
82 | transforms: object;
|
83 | }
|
84 |
|
85 | interface Animation {
|
86 | animatable: Animatable;
|
87 | currentValue: string;
|
88 | delay: number;
|
89 | duration: number;
|
90 | endDelay: number;
|
91 | property: string;
|
92 | tweens: readonly object[];
|
93 | type: string;
|
94 | }
|
95 |
|
96 | interface AnimeInstance extends AnimeCallBack {
|
97 | play(): void;
|
98 | pause(): void;
|
99 | restart(): void;
|
100 | reverse(): void;
|
101 | seek(time: number): void;
|
102 | tick(time: number): void;
|
103 |
|
104 | began: boolean;
|
105 | paused: boolean;
|
106 | completed: boolean;
|
107 | finished: Promise<void>;
|
108 |
|
109 | autoplay: boolean;
|
110 | currentTime: number;
|
111 | delay: number;
|
112 | direction: string;
|
113 | duration: number;
|
114 | loop: number | boolean;
|
115 | timelineOffset: number;
|
116 | progress: number;
|
117 | remaining: number;
|
118 | reversed: boolean;
|
119 |
|
120 | animatables: readonly Animatable[];
|
121 | animations: readonly Animation[];
|
122 | }
|
123 |
|
124 | interface AnimeTimelineAnimParams extends AnimeAnimParams {
|
125 | timelineOffset: number | string | FunctionBasedParameter;
|
126 | }
|
127 |
|
128 | interface AnimeTimelineInstance extends AnimeInstance {
|
129 | add(params: AnimeAnimParams, timelineOffset?: string | number): AnimeTimelineInstance;
|
130 | }
|
131 |
|
132 | interface StaggerOptions {
|
133 | start?: number | string | undefined;
|
134 | direction?: "normal" | "reverse" | undefined;
|
135 | easing?: CustomEasingFunction | string | EasingOptions | undefined;
|
136 | grid?: readonly number[] | undefined;
|
137 | axis?: "x" | "y" | undefined;
|
138 | from?: "first" | "last" | "center" | number | undefined;
|
139 | }
|
140 |
|
141 | // Helpers
|
142 | const version: string;
|
143 | const speed: number;
|
144 | const running: AnimeInstance[];
|
145 | const easings: { [EasingFunction: string]: (t: number) => any };
|
146 | function remove(targets: AnimeTarget | readonly AnimeTarget[]): void;
|
147 | function get(targets: AnimeTarget, prop: string, unit?: string): string | number;
|
148 | function path(path: string | HTMLElement | SVGElement | null, percent?: number): (prop: string) => {
|
149 | el: HTMLElement | SVGElement;
|
150 | property: string;
|
151 | totalLength: number;
|
152 | };
|
153 | function setDashoffset(el: HTMLElement | SVGElement | null): number;
|
154 | function bezier(x1: number, y1: number, x2: number, y2: number): (t: number) => number;
|
155 | function stagger(
|
156 | value: number | string | ReadonlyArray<number | string>,
|
157 | options?: StaggerOptions,
|
158 | ): FunctionBasedParameter;
|
159 | function set(targets: AnimeTarget, value: { [AnyAnimatedProperty: string]: any }): void;
|
160 |
|
161 | function timeline(params?: AnimeParams | readonly AnimeInstance[]): AnimeTimelineInstance;
|
162 | function random(min: number, max: number): number;
|
163 | }
|
164 |
|
165 | declare function anime(params: anime.AnimeParams): anime.AnimeInstance;
|
166 |
|
167 | export = anime;
|
168 | export as namespace anime;
|