One Line of CSS Replaces a 1,300-Word Staggered Animation Formula
Lee Meyer shows one line of CSS — animation-range-start with sibling-index() — replacing a 1,300-word custom formula for staggering scroll-driven animations, easing included.
- AuthorJames Calloway
- ChannelInteraction & Visual Craft
- Filed
- Read3 min

- Meyer replaces a 1.3k-word staggered-animation formula with one line: animation-range-start: contain calc(10% + 2.5% * sibling-index())
- The demo staggers eight characters at 2.5% increments, with the last digit animating at 30% of the containment range
- animation-delay does not affect scroll-driven animations; animation-range-start exists specifically for scroll-progress delays
- MDN confirms animation-timing-function works the same in scroll-driven and time-based animations
- Biswas's original Frontend Masters article paired emergent CSS features with a formula he called intimidating
A single line of CSS can replace the 1.3k-word staggered-animation formula Ashutosh Biswas published on Frontend Masters. That's the claim Lee Meyer makes in a new CSS-Tricks piece, and he demonstrates it with a working fork:
animation-range-start: contain calc(10% + 2.5% * sibling-index());
The line staggers the reveal of eight characters — a donation tally in a footer — by delaying each one 2.5% further into the containment range, so the last digit animates in at the 30% mark (10% plus 20%).
How the argument started
It began in the CSS-Tricks Slack channel, where Danny Schwartz shared Biswas's article and described it as "CSS on drugs." Biswas had combined several emergent CSS features with a substantial amount of math — a formula he admits "is a huge formula and can look intimidating" — to stagger scrolling animations generically.
Meyer read the piece multiple times (he notes, wryly, that he was recovering from a serious injury on heavy prescription painkillers at the time) and concluded the scroll-driven use case was reinventing something browsers already ship. His test: his eight-year-old son narrates a side-by-side video comparing the original source code with the simplified fork, making the point that the web we hand to the next generation should be simpler.
What does animation-range-start actually change?
The spec for scroll-driven animations already anticipates the problem Biswas solved by hand. Because these animations run on scroll progress rather than time, animation-delay — which only means something on the default time-based document timeline — has no effect. That's precisely why CSS introduced animation-range-start, which delays an animation relative to scroll position instead of elapsed time.
Biswas also wrote that "unfortunately, we can't use easing keywords or cubic-bezier() or linear() functions here. We are left on our own to create easing functions." Meyer pushes back: MDN is clear that animation-timing-function behaves identically in scroll-driven animations as in time-based ones, and he has used it with steps() to animate a ladder-climbing sprite in a CSS scrollytelling game. The real catch in the custom approach is that once all staggered animations merge into one master timeline, easing applies to the whole effect rather than each element — a logical consequence, not a browser flaw.
When is reinventing the wheel worth it?
Meyer doesn't dismiss custom implementations outright. He catalogs cases where developers rebuilt browser capabilities and gained something:
- React rebuilt DOM updates and reconciliation; it cost bundle size and a virtual DOM, but delivered declarative UI and a component model.
- Pretext rebuilt browser text measurement and line breaking; it cost a duplicate layout engine to maintain, but enabled DOM-free layout and virtualized lists.
- CSSTree rebuilt CSS parsing; it cost parser complexity, but provided AST access for linting and optimization.
Scroll timelines themselves, he notes, reinvented what JavaScript developers had done for decades. His verdict is narrower: the custom-functions approach was overkill for this specific demo.
He does grant the original article one genuine strength — a use case where a karaoke machine highlights lyrics based on vocal progress measured via speech recognition, running "not as a collection of independently timed objects, but as a single predictable, holistic effect driven by one progress value." There, the input isn't built into the browser, and rolling your own timeline logic earns its keep.
What comes next for custom timelines?
Meyer first wrote about scroll timelines in 2024, and even then wished for more input types: "I would love to see other input controls that can manipulate animation timelines. Imagine text fields progressing animations as you fill them out." He adds password-scheme strength, quiz progress, and shopping-cart state to that wishlist. Adam Argyle's Prop For That library, recently covered on CSS-Tricks, already makes it easier to expose field validation through CSS custom properties.
For now, Biswas's code may be the closest front-end developers get to driving CSS animations from values other than time or scroll progress — until the platform catches up with what Meyer, and a growing number of practitioners, are asking for.
Original: developer.mozilla.org
More from James Calloway
Show full bio
Senior reporter covering regulation, policy and their impact on Product and interaction design, design systems at Interface Wire.
174 articles