-
Notifications
You must be signed in to change notification settings - Fork 13.5k
/
spinner-configs.ts
154 lines (142 loc) · 3.4 KB
/
spinner-configs.ts
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import type { SpinnerConfigs } from './spinner-interface';
const spinners = {
bubbles: {
dur: 1000,
circles: 9,
fn: (dur: number, index: number, total: number) => {
const animationDelay = `${(dur * index) / total - dur}ms`;
const angle = (2 * Math.PI * index) / total;
return {
r: 5,
style: {
top: `${32 * Math.sin(angle)}%`,
left: `${32 * Math.cos(angle)}%`,
'animation-delay': animationDelay,
},
};
},
},
circles: {
dur: 1000,
circles: 8,
fn: (dur: number, index: number, total: number) => {
const step = index / total;
const animationDelay = `${dur * step - dur}ms`;
const angle = 2 * Math.PI * step;
return {
r: 5,
style: {
top: `${32 * Math.sin(angle)}%`,
left: `${32 * Math.cos(angle)}%`,
'animation-delay': animationDelay,
},
};
},
},
circular: {
dur: 1400,
elmDuration: true,
circles: 1,
fn: () => {
return {
r: 20,
cx: 48,
cy: 48,
fill: 'none',
viewBox: '24 24 48 48',
transform: 'translate(0,0)',
style: {},
};
},
},
crescent: {
dur: 750,
circles: 1,
fn: () => {
return {
r: 26,
style: {},
};
},
},
dots: {
dur: 750,
circles: 3,
fn: (_: number, index: number) => {
const animationDelay = -(110 * index) + 'ms';
return {
r: 6,
style: {
left: `${32 - 32 * index}%`,
'animation-delay': animationDelay,
},
};
},
},
lines: {
dur: 1000,
lines: 8,
fn: (dur: number, index: number, total: number) => {
const transform = `rotate(${(360 / total) * index + (index < total / 2 ? 180 : -180)}deg)`;
const animationDelay = `${(dur * index) / total - dur}ms`;
return {
y1: 14,
y2: 26,
style: {
transform: transform,
'animation-delay': animationDelay,
},
};
},
},
'lines-small': {
dur: 1000,
lines: 8,
fn: (dur: number, index: number, total: number) => {
const transform = `rotate(${(360 / total) * index + (index < total / 2 ? 180 : -180)}deg)`;
const animationDelay = `${(dur * index) / total - dur}ms`;
return {
y1: 12,
y2: 20,
style: {
transform: transform,
'animation-delay': animationDelay,
},
};
},
},
'lines-sharp': {
dur: 1000,
lines: 12,
fn: (dur: number, index: number, total: number) => {
const transform = `rotate(${30 * index + (index < 6 ? 180 : -180)}deg)`;
const animationDelay = `${(dur * index) / total - dur}ms`;
return {
y1: 17,
y2: 29,
style: {
transform: transform,
'animation-delay': animationDelay,
},
};
},
},
'lines-sharp-small': {
dur: 1000,
lines: 12,
fn: (dur: number, index: number, total: number) => {
const transform = `rotate(${30 * index + (index < 6 ? 180 : -180)}deg)`;
const animationDelay = `${(dur * index) / total - dur}ms`;
return {
y1: 12,
y2: 20,
style: {
transform: transform,
'animation-delay': animationDelay,
},
};
},
},
};
export const SPINNERS: SpinnerConfigs = spinners;
export type SpinnerTypes = keyof typeof spinners;