-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheasings.js
More file actions
45 lines (31 loc) · 1.12 KB
/
easings.js
File metadata and controls
45 lines (31 loc) · 1.12 KB
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
export const easeInCubic = (x) => x * x * x;
export const easeInOutSine = (x) => -(Math.cos(Math.PI * x) - 1) / 2;
export const easeInOutBack = (x) => {
const c1 = 1.70158;
const c2 = c1 * 1.525;
return x < 0.5
? (Math.pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2)) / 2
: (Math.pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2;
};
export const easeOutBack = (x) => {
const c1 = 1.70158;
const c3 = c1 + 1;
return 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2);
};
export const easeOutCubic = (x) => {
return 1 - Math.pow(1 - x, 3);
};
export const easeOutElastic = (x) => {
const c4 = (2 * Math.PI) / 5;
return x === 0
? 0
: x === 1
? 1
: Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1;
};
export const easeOutQuart = (x) => 1 - Math.pow(1 - x, 4);
export const easeOutCirc = (x) => Math.sqrt(1 - Math.pow(x - 1, 2));
export const easeOutSine = (x) => Math.sin((x * Math.PI) / 2);
export const easeOutQuint = (x) => 1 - Math.pow(1 - x, 5);
export const easeOutQuad = (x) => 1 - (1 - x) * (1 - x);
export const easeOutExpo = (x) => (x === 1 ? 1 : 1 - Math.pow(2, -10 * x));