Animated Counter

Numbers roll from 0 to the target, fast then slow, landing softly

All platformsMotion & BackgroundsContent areaEffect

Live preview (drag the parameters, watch it change)

Code

<div id="counter">0</div>
<script>
function countTo(el, target, duration = 1600) {
  const t0 = performance.now();
  const ease = t => 1 - Math.pow(1 - t, 3); // easeOutCubic
  (function step(t) {
    const k = Math.min(1, (t - t0) / duration);
    el.textContent = Math.round(target * ease(k)).toLocaleString('en-US');
    if (k < 1) requestAnimationFrame(step);
  })(t0);
}
countTo(document.getElementById('counter'), 12800);
</script>

Code snippets are MIT-licensed — copy and adapt freely.

How this effect works

它是怎么工作的(中文)

用 requestAnimationFrame 按进度取缓动值,把「已过时间 ÷ 总时长」喂给 easeOutCubic 再乘目标值。数字字体记得开 tabular-nums(等宽数字),否则滚动时整行会左右抖。计数只用在「数字本身是主角」的统计场景,别给每个小数字都加。

How it works (English)

Drive it with requestAnimationFrame: feed elapsed/duration through easeOutCubic and multiply by the target. Turn on tabular-nums (monospaced figures) or the line will jitter as digits change width. Reserve counters for stats where the number is the hero — not every small figure deserves one.

参考与来源 Sources

本条为「批次 1(重建)」成果(2026-11-10 用户决定:原 妞妞老师 素材不导出,改由公开材料重建):效果概念参考开源效果生态——Magic UI(MIT)、Uiverse(MIT)、Animista、Paper Shaders(Apache-2.0)、tsParticles(MIT)、CSS Loaders(MIT)等(见 /resources 对应条目,许可以各项目为准);本站的实现代码、参数体系与全部文案均为 Aglaia 原创,未复制上述项目的代码或文案,也与 妞妞老师 原始素材无关。

Matching prompt

Animated Counter PromptStale · →