UNPKG

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