-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<script lang="ts"> | ||
/** | ||
* The number of spinning circles. Must be even. | ||
* | ||
* Min: 2 | ||
* @default 2 | ||
*/ | ||
export let count = 2; | ||
$: count = Math.max(2, count) - (count % 2); | ||
/** | ||
* The speed of the animation in seconds. | ||
* @default 1 | ||
*/ | ||
export let speed = 1; | ||
/** | ||
* Whether the animation should play in reverse. | ||
* @default false | ||
*/ | ||
export let reverse = false; | ||
/** | ||
* The radius of the dots. | ||
* @default 15 | ||
*/ | ||
export let r = 15; | ||
</script> | ||
|
||
<svg viewBox="0 0 100 100" style:--speed="{speed}s" class:reverse style:--r="{r}px"> | ||
<circle cx="50" cy="50" /> | ||
{#key count} | ||
{#each new Array(count) as _, i} | ||
<circle class="outer" cx="50" cy="50" style:--angle="{(i * 360) / count}deg" /> | ||
{/each} | ||
{/key} | ||
</svg> | ||
|
||
<style lang="scss"> | ||
circle { | ||
--offset: calc(50px - var(--r)); | ||
r: var(--r); | ||
fill: currentcolor; | ||
transform-origin: center; | ||
transform: translate( | ||
calc(cos(var(--angle)) * var(--offset)), | ||
calc(sin(var(--angle)) * var(--offset)) | ||
); | ||
} | ||
.outer { | ||
animation: spin var(--speed) infinite ease-out; | ||
} | ||
.reverse .outer { | ||
animation-direction: reverse; | ||
animation-timing-function: ease-in; | ||
} | ||
@keyframes spin { | ||
0%, | ||
30% { | ||
rotate: 0deg; | ||
} | ||
to { | ||
rotate: 180deg; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<script lang="ts"> | ||
/** | ||
* The number of spinning circles. | ||
* The number of bars. | ||
* | ||
* Min: 1 | ||
* @default 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters