Counter Effect
Animated number counting with easing, formatting, and scroll-triggered activation. Perfect for stats and dashboards.

See Also

All JavaScript Effects Breathe Pulse Scribe Reveal Scramble Ripple Shake Twinkle

Domma.effects.counter()

The counter() effect smoothly counts from one number to another using requestAnimationFrame with configurable easing. Supports thousands separators, prefixes, suffixes, decimals, and scroll-triggered activation.

// Count from 0 to the number in the element
Domma.effects.counter('.stat-number');

// With full formatting
Domma.effects.counter('.revenue', {
  from: 0,
  to: 1250000,
  duration: 3000,
  separator: ',',
  prefix: '$',
  decimals: 2,
  easing: 'ease-out'
});

// Scroll-triggered
Domma.effects.counter('.stat', {
  trigger: 'scroll',
  threshold: 0.5
});

Demo: Dashboard Stats

Click to animate stat counters with staggered timing.

12500
Users
847
Projects
99
Uptime %
3200000
API Calls
Domma.effects.counter('.stat-number', {
  duration: 2000,
  stagger: 200,
  separator: ','
});

Demo: Prefix & Suffix

Add currency symbols, percentage signs, and other formatting.

0
Revenue
0
Satisfaction
0
Temperature
Domma.effects.counter('#revenue', {
  to: 84750, prefix: '$', separator: ','
});

Domma.effects.counter('#percent', {
  to: 98.7, suffix: '%', decimals: 1
});

Domma.effects.counter('#temp', {
  to: 23.5, suffix: '°C', decimals: 1
});

Demo: Easing Comparison

Compare different easing functions counting to 1,000.

0
Linear
0
Ease Out
0
Ease In-Out
Domma.effects.counter('#linear', { to: 1000, easing: 'linear', duration: 3000 });
Domma.effects.counter('#easeout', { to: 1000, easing: 'ease-out', duration: 3000 });
Domma.effects.counter('#easeinout', { to: 1000, easing: 'ease-in-out', duration: 3000 });

Demo: Scroll Triggered

These counters start when they scroll into view. Scroll down if they haven't started yet.

5280
Downloads
142
Contributors
28
Countries
Domma.effects.counter('.counter-scroll', {
  trigger: 'scroll',
  threshold: 0.5,
  stagger: 150,
  separator: ','
});

Demo: Decimal Precision

Count with decimal places for financial or scientific data.

0
Portfolio Value
Domma.effects.counter('#counter-decimal', {
  to: 42867.53,
  prefix: '$',
  decimals: 2,
  separator: ',',
  duration: 2500
});

Options Reference

OptionTypeDefaultDescription
fromnumber0Start value
tonumbernullEnd value (reads from element if null)
durationnumber2000Total count duration in ms
easingstring'ease-out''linear', 'ease-out', 'ease-in-out'
decimalsnumber0Decimal places
separatorstring','Thousands separator
prefixstring''Text before number
suffixstring''Text after number
staggernumber0Delay between elements (ms)
triggerstring'immediate''immediate' or 'scroll'
thresholdnumber0.5Observer threshold when trigger is scroll
respectMotionPreferencebooleantrueHonour prefers-reduced-motion
onUpdatefunctionnullCallback on each frame (currentValue)
onCompletefunctionnullCallback when counting completes