Spinner.svelte
1.17 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<script>
let { size = 40, color = 'currentColor' } = $props();
</script>
<svg
fill={color}
viewBox="0 -10 40 28"
xmlns="http://www.w3.org/2000/svg"
width={size}
height={size * 0.7}
class="spinner"
>
<circle cx="8" cy="12" r="3" class="first"/>
<circle cx="16" cy="12" r="3"/>
<circle cx="24" cy="12" r="3"/>
<circle cx="32" cy="12" r="3" class="second"/>
</svg>
<style>
@keyframes swing {
0% {
transform: rotate(0deg);
animation-timing-function: ease-out;
}
25% {
transform: rotate(50deg);
animation-timing-function: ease-in;
}
50% {
transform: rotate(0deg);
animation-timing-function: linear;
}
}
@keyframes swing2 {
0% {
transform: rotate(0deg);
animation-timing-function: linear;
}
50% {
transform: rotate(0deg);
animation-timing-function: ease-out;
}
75% {
transform: rotate(-50deg);
animation-timing-function: ease-in;
}
}
.spinner .first {
animation: swing 1.2s linear infinite;
transform-origin: center top;
}
.spinner .second {
animation: swing2 1.2s linear infinite;
transform-origin: center top;
}
</style>