WEB-34Optional
Animate on scroll with CSS
Drive scroll effects with CSS animation-timeline instead of scroll event listeners in JavaScript.
How to do it
Use animation-timeline: scroll() or view() with animation-range for scroll effects. Chrome and Safari 26 support it, and Firefox does not yet by default. Wrap it in @supports, animate only opacity or transform, and turn it off under prefers-reduced-motion: reduce. Handle reduced motion as Respect people who turn motion off says. The linter allows it only inside @supports, as Lint every feature against one Baseline target says.
Examples
CSS example
@supports (animation-timeline: scroll()) {
@media (prefers-reduced-motion: no-preference) {
.progress {
transform-origin: left;
animation: grow linear both;
animation-timeline: scroll();
animation-range: 0% 100%;
}
}
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}
How to check
A grep of the scripts finds no scroll event listener used for visual effects.
Sources
Related rules
- AXS-41 Respect people who turn motion off in Accessibility
- CSS-32 Lint every feature against one Baseline target in HTML and CSS
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/interface/scroll-driven-animations">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.