forked from Schum123/svelte-loading-spinners
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSyncLoader.svelte
68 lines (63 loc) · 1.73 KB
/
SyncLoader.svelte
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
<script lang="ts">
import type { SpinnerTypes } from "./types/spinner.type";
import { range, durationUnitRegex } from "./utils";
export let color: SpinnerTypes["color"] = "#FF3E00";
export let unit: SpinnerTypes["unit"] = "px";
export let duration: SpinnerTypes["duration"] = "0.6s";
export let size: SpinnerTypes["size"] = "60";
let durationUnit = duration.match(durationUnitRegex)[0];
let durationNum = duration.replace(durationUnitRegex, "");
</script>
<style>
.wrapper {
height: var(--size);
width: var(--size);
display: flex;
align-items: center;
justify-content: center;
}
.dot {
height: var(--dotSize);
width: var(--dotSize);
background-color: var(--color);
margin: 2px;
display: inline-block;
border-radius: 100%;
animation: sync var(--duration) ease-in-out infinite alternate both running;
}
@-webkit-keyframes sync {
33% {
-webkit-transform: translateY(10px);
transform: translateY(10px);
}
66% {
-webkit-transform: translateY(-10px);
transform: translateY(-10px);
}
100% {
-webkit-transform: translateY(0);
transform: translateY(0);
}
}
@keyframes sync {
33% {
-webkit-transform: translateY(10px);
transform: translateY(10px);
}
66% {
-webkit-transform: translateY(-10px);
transform: translateY(-10px);
}
100% {
-webkit-transform: translateY(0);
transform: translateY(0);
}
}
</style>
<div class="wrapper" style="--size:{size}{unit}; --duration: {duration};">
{#each range(3, 1) as i}
<div
class="dot"
style="--dotSize:{+size * 0.25}{unit}; --color:{color}; animation-delay: {i * (+durationNum / 10)}{durationUnit};" />
{/each}
</div>