Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 29x 30x 30x 30x 20x 30x 29x 30x 29x 30x 30x 90x 91x 93x | <script setup lang="ts">
import { computed } from "vue";
import { scaleSize, toCssSize, toPx } from "../../../utils/size";
interface Props {
size?: number | string;
color?: string;
speed?: number;
}
const props = withDefaults(defineProps<Props>(), {
size: 40,
color: "currentColor",
speed: 1,
});
const boxSize = computed(() => toCssSize(props.size));
const dotSize = computed(() => scaleSize(props.size, "/", 4));
const duration = computed(() => 1 / (props.speed > 0 ? props.speed : 1));
const angle = 120;
/** (size - dot) / 2, i.e. size * 3/8, and 28% of that for the inward pulse. */
const px = computed(() => toPx(props.size));
const orbitRadius = computed(() =>
px.value != null
? `${(px.value - px.value / 4) / 2}px`
: `calc(${props.size} * 0.375)`
);
const inwardOffset = computed(() =>
px.value != null
? `${((px.value - px.value / 4) / 2) * 0.28}px`
: `calc(${props.size} * 0.105)`
);
</script>
<template>
<div
class="vslk-spinner-orbit-dots"
:style="{
width: boxSize,
height: boxSize,
color: props.color,
animationDuration: duration + 's',
}"
>
<span
v-for="i in 3"
:key="i"
class="holder"
:style="{
transform: `rotate(${(i - 1) * angle}deg)`,
}"
>
<span
class="dot-orbit"
:style="{
transform: `translate(-50%, calc(-50% - ${orbitRadius}))`,
}"
>
<span
class="dot-core"
:style="{
width: dotSize,
height: dotSize,
backgroundColor: props.color,
animationDuration: duration + 's',
animationDelay: (-(i - 1) * duration) / 3 + 's',
'--orbit-radius': orbitRadius,
'--inward-offset': inwardOffset,
}"
/>
</span>
</span>
</div>
</template>
<style scoped>
.vslk-spinner-orbit-dots {
position: relative;
display: inline-block;
border-radius: 999px;
animation-name: vslk-orbit-dots-rotate;
animation-timing-function: linear;
animation-iteration-count: infinite;
max-width: 100%;
overflow: hidden;
flex-shrink: 0;
}
.holder {
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
transform-origin: 0 0;
}
.dot-orbit {
position: absolute;
left: 50%;
top: 50%;
transform-origin: center;
}
.dot-core {
position: absolute;
left: 50%;
top: 50%;
border-radius: 999px;
transform-origin: center;
animation-name: vslk-orbit-dots-pulse;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-fill-mode: both;
}
@keyframes vslk-orbit-dots-rotate {
to {
transform: rotate(360deg);
}
}
@keyframes vslk-orbit-dots-pulse {
0%,
100% {
transform: translate(
-50%,
calc(-50% + (var(--inward-offset) * 0) )
)
scale(0.7);
opacity: 0.45;
}
35% {
transform: translate(
-50%,
calc(-50% + var(--inward-offset) /* کمی به سمت مرکز (پایین) */)
)
scale(1.4);
opacity: 1;
}
60% {
transform: translate(-50%, calc(-50% + var(--inward-offset))) scale(1.4);
opacity: 1;
}
}
</style> |