Delivering scroll-driven animations—such as reveal-on-scroll cards, reading progress bars, and parallax imagery—historically required binding JavaScript event handlers to window.addEventListener('scroll') or utilizing IntersectionObserver. These JavaScript loops frequently choked the browser main thread during aggressive scrolling, causing frame drops and poor Interaction to Next Paint (INP) scores. The CSS Scroll-Driven Animations specification introduces declarative view-timeline and animation-timeline properties, offloading animation timing directly to the browser compositor thread. This tutorial covers configuring view timelines and auditing animation progress in Google Chrome.
The Mechanics of CSS View Timelines
Unlike scroll timelines (which link animation progress to the overall scroll position of a container), a view timeline tracks an element’s position as it enters and exits its scrollport (visibility box). Authors declare view-timeline-name: --timeline-name and view-timeline-axis: block on the target element. The animation is attached via animation-timeline: --timeline-name. The animation range is fine-tuned using animation-range: entry 0% cover 100%, allowing animations to trigger exactly when the element crosses the viewport edge.
Authoring Declarative Scroll-Driven Cards in CSS
Configure a reveal and scale effect that animates automatically on scroll without JavaScript:
/* 1. Define standard keyframes */
@keyframes revealCard {
from {
opacity: 0;
transform: translateY(60px) scale(0.92);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
/* 2. Bind declarative view timeline to scroll container items */
.editorial-card {
/* Establish anonymous view timeline shorthand */
animation: revealCard linear both;
animation-timeline: view();
/* Animate strictly while the card enters the viewport */
animation-range: entry 15% entry 85%;
background-color: #ffffff;
border-radius: 1rem;
padding: 2rem;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}
Auditing Scroll Timelines in Chrome DevTools
- Launch Google Chrome and navigate to your editorial page.
- Press
F12orCtrl + Shift + Ito open DevTools. - Open the Animations drawer. (Press
Ctrl + Shift + P, typeShow Animations, and press Enter). - Scroll the page down past the animated cards.
- Chrome DevTools captures the scroll-driven animation snapshot, displaying the exact scrub bar, timeline range, and computed keyframe values.
- Inspect the Rendering panel and check Scrolling performance issues to verify that animations execute completely off the main thread with zero non-composited scroll bottlenecks.
Providing Graceful Progressive Enhancement
Wrap view timeline animations inside an @supports feature query to protect legacy browser clients:
.editorial-card {
opacity: 1;
transform: none;
}
@supports (animation-timeline: view()) {
.editorial-card {
animation: revealCard linear both;
animation-timeline: view();
animation-range: entry 15% entry 85%;
}
}
This ensures legacy browsers render cards immediately in their fully revealed state, while modern Chrome users experience fluid 120 FPS hardware-accelerated animations.