UNPKG

10.4 kBTypeScriptView Raw
1// Last module patch version validated against: 3.0.1
2
3// --------------------------------------------------------------------------
4// Easing Functions
5// --------------------------------------------------------------------------
6
7/**
8 * Linear easing; the identity function; linear(t) returns t.
9 *
10 * @param normalizedTime Normalized time typically in the range [0, 1]
11 */
12export function easeLinear(normalizedTime: number): number;
13
14/**
15 * Symmetric quadratic easing; scales quadIn for t in [0, 0.5] and quadOut for t in [0.5, 1]. Also equivalent to poly.exponent(2).
16 *
17 * @param normalizedTime Normalized time typically in the range [0, 1]
18 */
19export function easeQuad(normalizedTime: number): number;
20
21/**
22 * Quadratic easing; equivalent to polyIn.exponent(2).
23 *
24 * @param normalizedTime Normalized time typically in the range [0, 1]
25 */
26export function easeQuadIn(normalizedTime: number): number;
27
28/**
29 * Reverse quadratic easing; equivalent to 1 - quadIn(1 - t). Also equivalent to polyOut.exponent(2).
30 *
31 * @param normalizedTime Normalized time typically in the range [0, 1]
32 */
33export function easeQuadOut(normalizedTime: number): number;
34
35/**
36 * Symmetric quadratic easing; scales quadIn for t in [0, 0.5] and quadOut for t in [0.5, 1]. Also equivalent to poly.exponent(2).
37 *
38 * @param normalizedTime Normalized time typically in the range [0, 1]
39 */
40export function easeQuadInOut(normalizedTime: number): number;
41
42/**
43 * Symmetric cubic easing; scales cubicIn for t in [0, 0.5] and cubicOut for t in [0.5, 1]. Also equivalent to poly.exponent(3).
44 *
45 * @param normalizedTime Normalized time typically in the range [0, 1]
46 */
47export function easeCubic(normalizedTime: number): number;
48
49/**
50 * Cubic easing; equivalent to polyIn.exponent(3).
51 *
52 * @param normalizedTime Normalized time typically in the range [0, 1]
53 */
54export function easeCubicIn(normalizedTime: number): number;
55
56/**
57 * Reverse cubic easing; equivalent to 1 - cubicIn(1 - t). Also equivalent to polyOut.exponent(3).
58 *
59 * @param normalizedTime Normalized time typically in the range [0, 1]
60 */
61export function easeCubicOut(normalizedTime: number): number;
62
63/**
64 * Symmetric cubic easing; scales cubicIn for t in [0, 0.5] and cubicOut for t in [0.5, 1]. Also equivalent to poly.exponent(3).
65 *
66 * @param normalizedTime Normalized time typically in the range [0, 1]
67 */
68export function easeCubicInOut(normalizedTime: number): number;
69
70/**
71 * Polynomial easing function factory
72 */
73export interface PolynomialEasingFactory {
74 /**
75 * Calculate eased time.
76 * @param normalizedTime Normalized time typically in the range [0, 1]
77 */
78 (normalizedTime: number): number;
79 /**
80 * Returns a new polynomial easing with the specified exponent e.
81 * If the exponent is not specified, it defaults to 3, equivalent to cubic.
82 *
83 * @param e Exponent for polynomial easing.
84 */
85 exponent(e: number): PolynomialEasingFactory;
86}
87
88/**
89 * Symmetric polynomial easing/easing factory; scales polyIn for t in [0, 0.5] and polyOut for t in [0.5, 1].
90 * If the exponent is not specified, it defaults to 3, equivalent to cubic.
91 */
92export const easePoly: PolynomialEasingFactory;
93/**
94 * Polynomial easing/easing factory; raises t to the specified exponent.
95 * If the exponent is not specified, it defaults to 3, equivalent to cubicIn.
96 */
97export const easePolyIn: PolynomialEasingFactory;
98
99/**
100 * Reverse polynomial easing/easing factory; equivalent to 1 - polyIn(1 - t).
101 * If the exponent is not specified, it defaults to 3, equivalent to cubicOut.
102 */
103export const easePolyOut: PolynomialEasingFactory;
104
105/**
106 * Symmetric polynomial easing/easing factory; scales polyIn for t in [0, 0.5] and polyOut for t in [0.5, 1].
107 * If the exponent is not specified, it defaults to 3, equivalent to cubic.
108 */
109export const easePolyInOut: PolynomialEasingFactory;
110
111/**
112 * Symmetric sinusoidal easing; scales sinIn for t in [0, 0.5] and sinOut for t in [0.5, 1].
113 *
114 * @param normalizedTime Normalized time typically in the range [0, 1]
115 */
116export function easeSin(normalizedTime: number): number;
117
118/**
119 * Sinusoidal easing; returns sin(t).
120 *
121 * @param normalizedTime Normalized time typically in the range [0, 1]
122 */
123export function easeSinIn(normalizedTime: number): number;
124
125/**
126 * Reverse sinusoidal easing; equivalent to 1 - sinIn(1 - t).
127 *
128 * @param normalizedTime Normalized time typically in the range [0, 1]
129 */
130export function easeSinOut(normalizedTime: number): number;
131
132/**
133 * Symmetric sinusoidal easing; scales sinIn for t in [0, 0.5] and sinOut for t in [0.5, 1].
134 *
135 * @param normalizedTime Normalized time typically in the range [0, 1]
136 */
137export function easeSinInOut(normalizedTime: number): number;
138
139/**
140 * Symmetric exponential easing; scales expIn for t in [0, 0.5] and expOut for t in [0.5, 1].
141 *
142 * @param normalizedTime Normalized time typically in the range [0, 1]
143 */
144export function easeExp(normalizedTime: number): number;
145
146/**
147 * Exponential easing; raises 2 to the exponent 10 * (t - 1).
148 *
149 * @param normalizedTime Normalized time typically in the range [0, 1]
150 */
151export function easeExpIn(normalizedTime: number): number;
152
153/**
154 * Reverse exponential easing; equivalent to 1 - expIn(1 - t).
155 *
156 * @param normalizedTime Normalized time typically in the range [0, 1]
157 */
158export function easeExpOut(normalizedTime: number): number;
159
160/**
161 * Symmetric exponential easing; scales expIn for t in [0, 0.5] and expOut for t in [0.5, 1].
162 *
163 * @param normalizedTime Normalized time typically in the range [0, 1]
164 */
165export function easeExpInOut(normalizedTime: number): number;
166
167/**
168 * Symmetric circular easing; scales circleIn for t in [0, 0.5] and circleOut for t in [0.5, 1].
169 *
170 * @param normalizedTime Normalized time typically in the range [0, 1]
171 */
172export function easeCircle(normalizedTime: number): number;
173
174/**
175 * Circular easing.
176 *
177 * @param normalizedTime Normalized time typically in the range [0, 1]
178 */
179export function easeCircleIn(normalizedTime: number): number;
180
181/**
182 * Reverse circular easing; equivalent to 1 - circleIn(1 - t).
183 *
184 * @param normalizedTime Normalized time typically in the range [0, 1]
185 */
186export function easeCircleOut(normalizedTime: number): number;
187
188/**
189 * Symmetric circular easing; scales circleIn for t in [0, 0.5] and circleOut for t in [0.5, 1].
190 *
191 * @param normalizedTime Normalized time typically in the range [0, 1]
192 */
193export function easeCircleInOut(normalizedTime: number): number;
194
195/**
196 * Reverse bounce easing; equivalent to 1 - bounceIn(1 - t).
197 *
198 * @param normalizedTime Normalized time typically in the range [0, 1]
199 */
200export function easeBounce(normalizedTime: number): number;
201
202/**
203 * Bounce easing, like a rubber ball.
204 *
205 * @param normalizedTime Normalized time typically in the range [0, 1]
206 */
207export function easeBounceIn(normalizedTime: number): number;
208
209/**
210 * Reverse bounce easing; equivalent to 1 - bounceIn(1 - t).
211 *
212 * @param normalizedTime Normalized time typically in the range [0, 1]
213 */
214export function easeBounceOut(normalizedTime: number): number;
215
216/**
217 * Symmetric bounce easing; scales bounceIn for t in [0, 0.5] and bounceOut for t in [0.5, 1].
218 *
219 * @param normalizedTime Normalized time typically in the range [0, 1]
220 */
221export function easeBounceInOut(normalizedTime: number): number;
222
223/**
224 * Anticipatory easing function factory
225 */
226export interface BackEasingFactory {
227 /**
228 * Calculate eased time.
229 * @param normalizedTime Normalized time typically in the range [0, 1]
230 */
231 (normalizedTime: number): number;
232 /**
233 * Returns a new back easing with the specified overshoot s.
234 * The degree of overshoot is configurable; if not specified, it defaults to 1.70158.
235 *
236 * @param s Overshoot parameter
237 */
238 overshoot(s: number): BackEasingFactory;
239}
240
241/**
242 * Symmetric anticipatory easing; scales backIn for t in [0, 0.5] and backOut for t in [0.5, 1].
243 * The degree of overshoot is configurable; it not specified, it defaults to 1.70158.
244 */
245export const easeBack: BackEasingFactory;
246
247/**
248 * Anticipatory easing, like a dancer bending their knees before jumping off the floor.
249 * The degree of overshoot is configurable; it not specified, it defaults to 1.70158.
250 */
251export const easeBackIn: BackEasingFactory;
252
253/**
254 * Reverse anticipatory easing; equivalent to 1 - backIn(1 - t).
255 * The degree of overshoot is configurable; it not specified, it defaults to 1.70158.
256 */
257export const easeBackOut: BackEasingFactory;
258
259/**
260 * Symmetric anticipatory easing; scales backIn for t in [0, 0.5] and backOut for t in [0.5, 1].
261 * The degree of overshoot is configurable; it not specified, it defaults to 1.70158.
262 */
263export const easeBackInOut: BackEasingFactory;
264
265/**
266 * Elastic easing function factory
267 */
268export interface ElasticEasingFactory {
269 /**
270 * Calculate eased time.
271 * @param normalizedTime Normalized time typically in the range [0, 1]
272 */
273 (normalizedTime: number): number;
274 /**
275 * Returns a new elastic easing with the specified amplitude a.
276 * Defaults to 1,if not specified.
277 *
278 * @param a Amplitude for elastic easing.
279 */
280 amplitude(a: number): ElasticEasingFactory;
281 /**
282 * Returns a new elastic easing with the specified amplitude a.
283 * Defaults to 0.3,if not specified.
284 *
285 * @param p Period for elastic easing.
286 */
287 period(p: number): ElasticEasingFactory;
288}
289
290/**
291 * Reverse elastic easing; equivalent to 1 - elasticIn(1 - t).
292 * The amplitude and period of the oscillation are configurable;
293 * if not specified, they default to 1 and 0.3, respectively.
294 */
295export const easeElastic: ElasticEasingFactory;
296
297/**
298 * Elastic easing, like a rubber band.
299 * The amplitude and period of the oscillation are configurable;
300 * if not specified, they default to 1 and 0.3, respectively.
301 */
302export const easeElasticIn: ElasticEasingFactory;
303
304/**
305 * Reverse elastic easing; equivalent to 1 - elasticIn(1 - t).
306 * The amplitude and period of the oscillation are configurable;
307 * if not specified, they default to 1 and 0.3, respectively.
308 */
309export const easeElasticOut: ElasticEasingFactory;
310
311/**
312 * Symmetric elastic easing; scales elasticIn for t in [0, 0.5] and elasticOut for t in [0.5, 1].
313 * The amplitude and period of the oscillation are configurable;
314 * if not specified, they default to 1 and 0.3, respectively.
315 */
316export const easeElasticInOut: ElasticEasingFactory;