Meteors
svelte-animations/meteorsFreeBlock
A meteor shower effect component with customizable number of meteors and animated falling effects.
Install it
npx shadcn@latest add https://sv-animations.vercel.app/r/meteors.jsonSource
1<script lang="ts">2 import { cn } from "$UTILS$";3 import { onMount } from "svelte";45 interface Props {6 number?: number;7 minDelay?: number;8 maxDelay?: number;9 minDuration?: number;10 maxDuration?: number;11 angle?: number;12 class?: string;13 }1415 let {16 number = 20,17 minDelay = 0.2,18 maxDelay = 1.2,19 minDuration = 2,20 maxDuration = 10,21 angle = 215,22 class: className,23 }: Props = $props();2425 type MeteorStyle = {26 angle: string;27 top: string;28 left: string;29 animationDelay: string;30 animationDuration: string;31 };3233 let meteorStyles: MeteorStyle[] = $state([]);3435 let updateMeteors = () => {36 const styles = [...new Array(number)].map(() => ({37 angle: -angle + "deg",38 top: "-5%",39 left: `calc(0% + ${Math.floor(Math.random() * window.innerWidth)}px)`,40 animationDelay: Math.random() * (maxDelay - minDelay) + minDelay + "s",41 animationDuration:42 Math.floor(Math.random() * (maxDuration - minDuration) + minDuration) + "s",43 }));44 meteorStyles = styles;45 };46 onMount(() => {47 updateMeteors();48 });49</script>5051{#each meteorStyles as style, idx (idx)}52 <span53 style="--angle: {style.angle}; top: {style.top}; left: {style.left}; animation-delay: {style.animationDelay}; animation-duration: {style.animationDuration};"54 class={cn(55 "animate-meteor pointer-events-none absolute size-0.5 rotate-(--angle) rounded-full bg-zinc-500 shadow-[0_0_0_1px_#ffffff10]",56 className57 )}58 >59 <div60 class="pointer-events-none absolute top-1/2 -z-10 h-px w-12.5 -translate-y-1/2 bg-linear-to-r from-zinc-500 to-transparent"61 ></div>62 </span>63{/each}
Files it writes
More from Svelte Animations
All 66 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Beamanimated-beam | Svelte Animations | Blocks | Free | 1 dep · 6 files | |
| Animated Circular Progress Baranimated-circular-progress-bar | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Animated Gradient Textanimated-gradient-text | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Animated Grid Patternanimated-grid-pattern | Svelte Animations | Blocks | Free | 1 dep · 2 files | |
| Animated Listanimated-list | Svelte Animations | Blocks | Free | 1 dep · 2 files | |
| Animated Shiny Textanimated-shiny-text | Svelte Animations | Blocks | Free | no deps | |
| Animated Theme Toggleranimated-theme-toggler | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Arc Timelinearc-timeline | Svelte Animations | Blocks | Free | no deps · 3 files |
