I'm considering a single-stylesheet library that uses data attributes and CSS scroll-driven animations, without JavaScript. Is that a practical approach for a public site, and what should I watch out for?
Is a CSS-only scroll animation library practical?
Answers
Yes, as progressive enhancement. Keep the default state readable and put any hidden or offset starting state inside the animation, rather than in a base rule. If the browser doesn't support scroll-driven animations, visitors should just get a static page with all the content visible.
Also provide a reduced-motion option that shows the final state without the scroll sequence. The animation should add something, not be required to find or read the content.
Reply to this answer
Check browser support against the versions your audience actually uses. Scroll-driven animations aren't available everywhere, and support may depend on the browser version or a feature flag. A static fallback makes that less risky, but it doesn't help if the animation itself is essential to the experience.
Reply to this answer
No JavaScript doesn't automatically mean smooth. Test the actual page on phones, including less powerful devices, and don't assume a desktop demo tells the whole story. A busy demo can be slow because of its combination of effects, even if a single animation runs fine.
I'd start with transforms and opacity where possible, then check how the page behaves as you add more animated elements. Effects such as blur can be worth testing especially carefully.
Reply to this answer
The reusable vocabulary is the appealing bit. A data attribute with a short motion name is easier to apply consistently than rebuilding scroll timelines for every element. I'd still want clear examples of what each effect does and how to adjust it before adding another stylesheet to a project.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions