axi0motion

Count up

A number counts up to its value when it scrolls into view, in the page's own format.

  • enhancer
  • number
  • entrance
  • scroll
  • stats
  • since 0.1

Background Studio: tune it below, then copy the code

Your system asks for reduced motion: the demo shows its final state and nothing moves.

Live demo

Count up example

2,048 pixels 98.6 degrees

Controls

0
1800 ms
0 ms

Code

It follows the controls above: change an option and the code changes with it.

<link rel="stylesheet" href="/axi0/motion/motion.css?v=6">
<script src="/axi0/motion/motion.js?v=10" defer></script>

<p class="demo-stats"><span class="demo-num" data-motion="count-up">2,048</span> pixels <span class="demo-num" data-motion="count-up" data-duration="2400">98.6</span> degrees</p>

The wrappers: CountUp.tsx (React, TypeScript) and CountUp.vue (Vue). Both render the same attributes as the HTML; the loader does the rest.

Options

AttributeDefaultWhat it does
data-motion-from0the starting number
data-motion-duration1800milliseconds
data-motion-delay0milliseconds before it starts

Accessibility

The page holds the real number, so it reads correctly without JavaScript, to screen readers and under reduced motion (no counting then). Decimals, a thousands comma, a prefix and a suffix are kept. The final text keeps the width while it counts: nothing beside it moves.

Size

count-up.js is 0.9 KB gzip. A page loads the loader (2.7 KB) and core.js (1.4 KB) once, whatever it uses.