This component no longer exists. It was in Svelte Animations’s manifest when we first indexed it and is not there now — the registry served its inventory on 2026-08-05 and this item was not on it. The install command below will fail. It is kept here because a tutorial somewhere still tells people to run it.
Number Ticker
svelte-animations/number-tickerRemovedBlock
An animated number counter component with spring physics that smoothly animates from a start value to an end value.
Install it
npx shadcn@latest add https://sv-animations.vercel.app/r/number-ticker.jsonSource
1<script lang="ts">2 import { onMount } from "svelte";3 import { useInView } from "motion-sv";4 import { cn } from "$UTILS$";56 interface NumberTickerProps {7 value: number;8 startValue?: number;9 direction?: "up" | "down";10 delay?: number;11 decimalPlaces?: number;12 class?: string;13 prefix?: string;14 suffix?: string;15 once?: boolean;16 }1718 let {19 value,20 startValue = 0,21 direction = "up",22 delay = 0,23 decimalPlaces = 0,24 class: className,25 prefix = "",26 suffix = "",27 once = true,28 }: NumberTickerProps = $props();2930 let spanRef: HTMLSpanElement | null = $state(null);3132 // Spring configuration33 const damping = 60;34 const stiffness = 100;3536 // Spring physics simulation37 function animateValue(from: number, to: number) {38 const startTime = performance.now();39 const duration = 2000; // Duration in ms4041 let velocity = 0;42 let position = from;43 const target = to;4445 function step(currentTime: number) {46 const elapsed = currentTime - startTime;47 const dt = 16.67 / 1000; // ~60fps in seconds4849 // Spring physics50 const springForce = -stiffness * (position - target);51 const dampingForce = -damping * velocity;52 const acceleration = springForce + dampingForce;5354 velocity += acceleration * dt;55 position += velocity * dt;5657 // Update display58 if (spanRef) {59 spanRef.textContent = `${prefix}${Intl.NumberFormat("en-US", {60 minimumFractionDigits: decimalPlaces,61 maximumFractionDigits: decimalPlaces,62 }).format(Number(position.toFixed(decimalPlaces)))}${suffix}`;63 }6465 // Continue animation if not settled66 const isSettled = Math.abs(velocity) < 0.01 && Math.abs(position - target) < 0.01;67 if (!isSettled && elapsed < duration * 2) {68 requestAnimationFrame(step);69 } else if (spanRef) {70 // Ensure final value is exact71 spanRef.textContent = `${prefix}${Intl.NumberFormat("en-US", {72 minimumFractionDigits: decimalPlaces,73 maximumFractionDigits: decimalPlaces,74 }).format(Number(target.toFixed(decimalPlaces)))}${suffix}`;75 }76 }7778 requestAnimationFrame(step);79 }8081 const view = useInView(82 () => spanRef!,83 () =>84 ({85 once: once,86 margin: "0px",87 }) as any88 );89 $effect(() => {90 let timer: ReturnType<typeof setTimeout> | null = null;91 if (view.current) {92 timer = setTimeout(() => {93 animateValue(94 direction === "down" ? value : startValue,95 direction === "down" ? startValue : value96 );97 }, delay);98 }99 return () => {100 if (timer !== null) {101 clearTimeout(timer);102// … truncated
What it pulls in
npm packages
