Stats count-up on enter

A row of statistics counts from 0 to its value the first time it scrolls into view, each number offset slightly.

ListEnter view Vanilla JSGSAP time-based Targets: Web · App All browsers
Effects
0
Copies
0
Stars
0
Target
Implement the "Stats count-up on enter" effect in vanilla HTML/CSS/JS.

Context: A row of statistics counts from 0 to its value the first time it scrolls into view, each number offset slightly.
Trigger: the element enters the viewport (first time only).
Timeline: time-based (duration + easing).

Motion tokens (normal):
- number: 0 → target value
- translateY (label): 8px → 0
- opacity (label): 0 → 1
- duration: 1200ms
- easing: cubic-bezier(0.16, 1, 0.3, 1)
- stagger: 120ms
- note: number is text, updated with requestAnimationFrame; keep tabular figures to avoid jitter

Motion tokens (prefers-reduced-motion):
- number: target value → target value
- opacity (label): 0 → 1
- duration: 0ms
- note: show final values immediately; fade labels 200ms

Technique: plain JavaScript (requestAnimationFrame / class toggles), no animation library required; GSAP (ScrollTrigger where relevant) is acceptable as an alternative.

Acceptance:
- animate only transform and opacity unless the spec lists other properties
- no layout shift; content is visible without the animation
- when prefers-reduced-motion is set, use the reduced tokens only
- use font-variant-numeric: tabular-nums so the width does not jump
- format with thousands separators on every frame

Generated from the spec. Prompts differ by target name only; the tokens are the source of truth.