1
export type EasingFunction = (t: number) => number
2

3 1
// linear
4 1
export const linear = (t: number) => t
5
// accelerating from zero velocity
6 1
export const easeInQuad = (t: number) => t ** 2
7
// decelerating to zero velocity
8 1
export const easeOutQuad = (t: number) => t * (2 - t)
9
// acceleration until halfway, then deceleration
10 1
export const easeInOutQuad = (t: number) => (t < 0.5 ? 2 * t ** 2 : -1 + (4 - 2 * t) * t)
11
// accelerating from zero velocity
12 1
export const easeInCubic = (t: number) => t ** 3
13
// decelerating to zero velocity
14 1
export const easeOutCubic = (t: number) => --t ** 3 + 1
15
// acceleration until halfway, then deceleration
16 1
export const easeInOutCubic = (t: number) => t < 0.5 ? 4 * t ** 3 : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1
17
// accelerating from zero velocity
18 1
export const easeInQuart = (t: number) => t ** 4
19
// decelerating to zero velocity
20 1
export const easeOutQuart = (t: number) => 1 - --t ** 4
21
// acceleration until halfway, then deceleration
22 1
export const easeInOutQuart = (t: number) => (t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t)
23
// accelerating from zero velocity
24 1
export const easeInQuint = (t: number) => t ** 5
25
// decelerating to zero velocity
26 1
export const easeOutQuint = (t: number) => 1 + --t ** 5
27
// acceleration until halfway, then deceleration
28 1
export const easeInOutQuint = (t: number) => t < 0.5 ? 16 * t ** 5 : 1 + 16 * --t ** 5

Read our documentation on viewing source code .

Loading