How to Debug Scroll-Driven Animations with Chrome DevTools AI assistance
There's a moment in every web developer's life when you're asked, "Can the cards do that cool thing as you scroll?" You used to reach for a JavaScript library. Now you can reach for one CSS property and look like you know a magic trick.
So you ask your AI coding assistant for it. Many assistants have historically reached for a scroll listener here, but you’ve heard CSS can do this now, so you ask for modern CSS instead. This time the code looks great. Short, clean, not a line of JavaScript in sight. Then one innocent-looking rule lands in the wrong place, and it does absolutely nothing.
No error in the console. No warning. The cards just sit there, ignoring your scrolling. That's the annoying thing about CSS: when it fails, it fails silently.
This is where a lot of developers give up and go back to JavaScript. You should not though, because the fix is often a single word, once you know where to look.
In this article, you'll learn how scroll-driven animations work (with a mental model that sticks), how to prompt your AI assistant so it gets them right, and how to debug them when it doesn't, using Chrome DevTools' built-in AI assistance. We'll debug a small, ready-made demo together: My Web Platform Awards 2026, a stack of award cards that should pile up as you scroll, but doesn't.
Prerequisites: the latest version of Chrome plus HTML and CSS knowledge.
Table of Contents
- Why Do AI Assistants Still Use JavaScript for Scroll Animations?
- What Are CSS Scroll-Driven Animations?
- How to Prompt AI for CSS Scroll-Driven Animations (with Modern Web Guidance)
- How to Debug a Broken Scroll-Driven Animation Step by Step
- The Fixed Version of our Scroll Animation
- Scroll-Driven Animation Debugging Checklist
- Conclusion
Why Do AI Assistants Still Use JavaScript for Scroll Animations?
Scroll-driven animations shipped in Chrome and Microsoft Edge 115 in 2023, Safari 26 in 2025, and became Baseline when Firefox 159 joined in October 2026. For over a decade before that, JavaScript was the only option, so that's what AI models mostly learned from.
Ask for a scroll effect, and historically, you’d often get something like this:
// ❌ The classic: JavaScript watching every scroll event
window.addEventListener('scroll', () => {
document.querySelectorAll('.card').forEach((card) => {
const rect = card.getBoundingClientRect(); // measure where the card is
const progress = Math.min(Math.max(1 - rect.top / window.innerHeight, 0), 1);
card.style.opacity = progress; // update it by hand
});
});
It works, but think of the main thread as a single waiter running a whole restaurant. Every time the page scrolls, the scroll listener rings a bell and the waiter drops everything: loops through every table (forEach), measures where each card is sitting (getBoundingClientRect()), and turns its lamp up or down by hand (card.style.opacity). On a quiet night you won’t notice. But that same waiter is also taking orders (your click handlers) and clearing plates (rendering), so on a busy page or a mid-range phone, the lamps start lagging behind your scrolling.
What about Intersection Observer? It's great for knowing when something crosses a line, but not for following every pixel of your scroll. (For one-time reveals, there’s a separate feature called scroll-triggered animations. It starts a normal animation when an element reaches a scroll position, instead of following your scrolling. It’s only in Chrome and Edge 146 so far.)
The browser can now do this job by itself.
What Are CSS Scroll-Driven Animations?
A scroll-driven animation is a normal CSS animation where the scrollbar, not the clock, decides how far along it is.
As of October 2026, they’re Baseline Newly available, which means they work in the latest version of every major browser.
Think of a video. A regular animation works with time. A scroll-driven animation is the same video, but you're dragging the scrubber, and the scrollbar is the scrubber. Scroll down to play, scroll up to rewind, stop to freeze.
Let’s see what that looks like in code. The code below shows a regular animation that grows a bar from nothing to full width over three seconds:
/* Regular CSS animation: the clock decides the progress */
.progress-bar {
transform-origin: left;
animation-name: grow;
animation-duration: 3s;
animation-timing-function: linear;
animation-timeline: auto; /* implicit default: the document's clock */
}
@keyframes grow {
from { transform: scaleX(0); }
to { transform: scaleX(1); }
}
Every animation has a timeline, which tells it how far along it is. By default (animation-timeline: auto) that’s the clock, which is why you have to say how long the animation lasts.
Now code below shows the scroll-driven version of the animation above. The keyframes and the linear easing stay the same. Two things change: the duration disappears, because there’s nothing to count, and you give the animation-timeline property a value of scroll():
/* Scroll-driven version: the scrollbar decides the progress */
.progress-bar {
position: fixed;
inset: 0 0 auto 0;
height: 6px;
background: #4f46e5;
transform-origin: left;
animation: grow linear both;
animation-timeline: scroll(); /* the scrollbar is now the clock */
}
@keyframes grow {
from { transform: scaleX(0); }
to { transform: scaleX(1); }
}
That’s a reading progress bar with no JavaScript. Use linear easing so the animation moves at exactly the speed of your scroll.
Notice that animation-timeline comes after the animation shorthand. Hold onto that detail, because it comes back when we talk about prompting.
Two Timelines, Two Questions
| Timeline | The question it answers | Best for |
|---|---|---|
scroll() | "How far has this container been scrolled?" | Progress bars, parallax, header changes |
view() | "Where is this element as it enters and leaves the visible area?" | Reveals, fade-ins, cards that react to position |
Think of view() like a stage: your element is an actor walking on, standing center stage, then walking off. animation-range picks which part of that walk the animation covers:
.card {
animation: reveal linear both;
animation-timeline: view();
animation-range: entry 0% entry 60%; /* run while the card walks on */
}
The keywords you'll use most are entry, exit, cover (the whole journey, the default), and contain (only while fully visible).
Three Gotchas Worth Knowing
- Named timelines only reach descendants. You can name a timeline on one element (
view-timeline-name: --cards-timeline) and use it on another (animation-timeline: --cards-timeline), but only the element and its descendants can see that name. Our demo uses one. - Fill modes matter. An animation only applies its keyframes during its range. Use
backwardsto apply the first keyframe before the range starts,forwardsto keep the last one after it ends, orboth. - Performance. Only
transformandopacityanimations can run on the compositor, which keeps them smooth when the main thread is busy. Animatewidthortopand the browser still does layout work.
How to Prompt AI for CSS Scroll-Driven Animations (with Modern Web Guidance)
The best bug is the one your AI never writes. Modern Web Guidance (MWG) is a set of skills from the Chrome team that gives your coding agent current web platform guidance and browser support data (1.0 came out in October 2026). I covered the setup in my Modern Web Guidance article, but here’s the short version:
npx modern-web-guidance@latest install
MWG has a guide for scroll entry and exit effects, so your agent picks up rules like declaring animation-timeline after the animation shorthand (which would otherwise reset it), animating only transform and opacity, and respecting reduced motion. It also taught me a stricter feature check, one that filters out browsers with only partial support:
/* ❌ Before */
@supports (animation-timeline: view()) { ... }
/* ✅ After: what Modern Web Guidance recommends */
@supports ((animation-timeline: view()) and (animation-range: entry)) { ... }
MWG covers the platform. Your prompt covers your page. Here’s the prompt I used. The last line is one I added afterwards, and I’ll explain why in a moment:
Build a stack of award cards that pile up as you scroll, using CSS scroll-driven animations only. No JavaScript.
- Each card sticks to the top, and earlier cards shrink slightly as new ones stack on top
# I added this line afterwards
- Do not add overflow: hidden, auto, or scroll to any ancestor of the animated or sticky elements. Use overflow: clip instead
I ran everything above the last line twice (with a note to put it all in one index.html), once in a fresh project and once with MWG installed. Both versions worked in Chrome, so this isn’t a broken versus fixed story. The difference is in the safety nets.
Without MWG, the agent wrote clean, JavaScript-free CSS, but with no feature check and no reduced-motion handling, so everything ran for everyone. With MWG, the animation sat inside the prefers-reduced-motion and @supports checks from the guide, and the sticky stack stayed outside them so older browsers still got the pile of cards.
So why that oddly specific last line? Both agents put overflow-x: hidden on html or body, where the browser passes it up to the viewport and it’s harmless. Put the same rule on a wrapper element, which is easy to do in a real project, and everything quietly breaks. That’s the bug we’re about to chase.
How to Debug a Broken Scroll-Driven Animation Step by Step
For the demo we’re using My Web Platform Awards 2026. Five award cards should stick to the top as you scroll, with earlier cards shrinking back as new ones pile on. It's based on Bramus Van Damme's stacking cards demo.
This year's winners: Container Queries (Lifetime Achievement), Modern Web Guidance (Best Supporting Role), Chrome DevTools for agents (Best Debugging Sidekick), MWG's extension skill (Best Extension Glow-up), and scroll-driven animations (Breakout Star of 2026).
Open it in Chrome and scroll. The cards don't stick and don't shrink. You get a plain list.
Here's the CSS that matters (the rest is in the CodePen above):
.page {
/* Stop the hero glow from causing a horizontal scrollbar */
overflow-x: hidden;
}
.cards-stack {
/* Every card watches this list as it scrolls past */
view-timeline-name: --cards-timeline;
}
/* Each card sticks to the top, offset a little more than the one before it */
.card-item {
position: sticky;
top: var(--stack-top);
}
@media (prefers-reduced-motion: no-preference) {
@supports ((animation-timeline: view()) and (animation-range: entry)) {
@keyframes shrink-card {
to { transform: scale(calc(1 - 0.04 * var(--reverse-index0))); }
}
.award-card {
/* Shorthand first, then the timeline and range, so the shorthand can't reset them */
animation: shrink-card auto linear forwards;
animation-timeline: --cards-timeline;
/* --start-range and --end-range are set in the full CodePen */
animation-range: exit-crossing var(--start-range) exit-crossing var(--end-range);
}
}
}
The shorthand comes before the timeline. It only animates transform. So what's wrong? (Hint: look for the rule someone added to be helpful.)
Before You Start
Turn on AI assistance. In DevTools settings, find the AI innovations section and enable AI assistance. You’ll need to be signed in to Chrome, and availability depends on your region and age. Menu names vary by Chrome version, so check the DevTools AI assistance docs if yours differ.
⚠️ What you share with AI assistance goes to Google, so check the privacy notice in DevTools before using it on private code.
Step 1: Check the Styles Pane
Right-click the first award card and choose Inspect. In the Elements panel, select the <article class="award-card"> line, not the <li> around it.
In the Styles pane, find animation-timeline: --cards-timeline. It sits inside the @media and @supports blocks. Is it there, and not crossed out? Crossed out or missing means a typo or an old browser.
Here it’s fine, so the browser understood the CSS. (The Console has no errors either: CSS never throws them.) The problem is somewhere else.
Step 2: Ask DevTools AI for a Lead
With the <article class="award-card"> selected, open the AI assistance panel. Check that it shows the card as its context: the AI only sees what you select. A vague prompt gets a vague answer, so give it the symptoms (Prompt 1):
This element uses a named view timeline (--cards-timeline) but never
animates when I scroll, and its sticky parent doesn't stick either.
Which scroll container are they attached to, and why isn't it scrolling?
It found the right suspect straight away: div.page is the scroll container, and it can’t scroll, because its scrollHeight equals its clientHeight. It also explained why both effects broke together: sticky elements and view timelines both depend on the nearest scroll container.
But it never said why .page was a scroll container, and it suggested giving .page a fixed height. That would move your page’s scrollbar into a box. Ironically, its answer even included the rule that solves the case: no ancestor between a sticky element and its scroller should have overflow: hidden. It just never checked .page against it.
So I asked a follow-up (Prompt 2):
I never set overflow-y on .page. Why is it a scroll container?
It read the computed value correctly (overflow-x: hidden, overflow-y: auto), then guessed: maybe an external stylesheet, a CSS reset, or a framework like Tailwind. None of those apply. The “external stylesheet” was just CodePen serving my own CSS, which the AI said it couldn’t read. When the AI can’t see the evidence, it fills the gap with plausible guesses.
One more follow-up, this time stating what I wanted (Prompt 3):
I don't want the page scrollbar moved into a box. Is there a way to
stop the horizontal overflow without making .page a scroll container?
This time it explained the real cause: when one axis isn’t visible, the browser promotes visible on the other axis to auto. It offered two fixes:
/* The AI's main suggestion */
.page { overflow: visible; }
html, body {
overflow-x: hidden;
overflow-y: visible;
}
/* Its "modern alternative" */
.page {
overflow-x: clip;
overflow-y: visible;
}
Two good lessons in three prompts. Telling the AI your constraint (“don’t move my scrollbar”) got a much better answer than asking it to fix things. But which of those two fixes actually works? Don’t take the AI’s word for it. Check.
Step 3: Check the AI’s Work in DevTools
Every scroll timeline attaches to the nearest scroll container. Let’s ask the browser directly which one it picked. With the <article class="award-card"> selected, run this in the Console:
$0.getAnimations()[0].timeline.source
$0 is the element you have selected, and source is the scroller its timeline is attached to. You’d expect the page itself (<html>). Instead, it returns <div class="page">. The AI’s lead was right.
Running this in CodePen? The preview lives inside an iframe, which can make $0 come back undefined. In CodePen 2.0, collapse the code panels and maximize the Preview pane to fullscreen, then inspect the card again. Selecting the card again after that matters, because $0 only updates when you select an element.
Here’s the analogy. You’ve tied your animation to a rope, expecting the other end to be attached to the scrollbar. Instead, it’s tied to a fence post. You can pull the page up and down all day, and the fence post never moves.
So why is .page a scroller at all? Select the <div class="page"> line and open the Computed tab. overflow-y says auto, just as the AI said, and the Styles pane shows no overflow-y rule anywhere. No reset, no framework. Just overflow-x: hidden. So .page became a scroll container that never scrolls, because it grows to fit its content.
And position: sticky uses the same nearest scroll container, which is why the cards stopped sticking too. One line broke two effects.
Now test the AI’s main suggestion before trusting it. In the CodePen CSS, swap the .page rule for the AI’s html, body version, select the card again, and rerun the Console check. It returns <body>. The bug didn’t go away. It moved up a level. Overflow on body only gets passed up to the viewport when html has no overflow rule of its own, and the AI’s fix gave html one. So body became the new fence post.
Step 4: Apply the Fix
The AI’s “modern alternative” was the real fix. The goal behind the original overflow rule was right too: the hero’s gold glow pokes out past the right edge of the page, and without any rule, every screen gets a 160px sideways scroll. The tool was wrong. overflow: clip clips the same way, without creating a scroll container.
/* ❌ Before */
.page {
overflow-x: hidden; /* secretly makes .page a scroll container */
}
/* ✅ After */
.page {
overflow-x: clip; /* clips overflow without becoming a scroller */
}
One word. That’s the whole fix.
Side note: the trap is a wrapper element. overflow-x: hidden on html or body is usually passed up to the viewport, so it doesn’t cause this bug. That’s where my agent put it, in both of my test runs. But it only works when html has no overflow rule of its own, which is exactly the condition the AI’s main fix broke.
Step 5: Verify, Don't Assume
Reload. The cards stick, stack, and shrink. Select the <article class="award-card"> and run the Step 3 check again: it now returns <html lang="en">, the page’s real scroller.
“It looks like it works” has a habit of breaking on the next screen size, so always confirm with the tools.
The Fixed Version
Here's the fix, plus two safety nets, so the animation is a bonus rather than a requirement:
.page {
overflow-x: clip; /* ✅ clips the glow without becoming a scroller */
}
.cards-stack {
view-timeline-name: --cards-timeline; /* every card watches the whole list */
}
/* Sticky stays outside the checks: every browser gets the stack */
.card-item {
position: sticky;
top: var(--stack-top);
}
/* Only animate if the user is fine with motion
AND the browser fully supports it */
@media (prefers-reduced-motion: no-preference) {
@supports ((animation-timeline: view()) and (animation-range: entry)) {
@keyframes shrink-card {
to { transform: scale(calc(1 - 0.04 * var(--reverse-index0))); }
}
.award-card {
animation: shrink-card auto linear forwards;
animation-timeline: --cards-timeline;
/* --start-range and --end-range are set in the full CodePen */
animation-range: exit-crossing var(--start-range) exit-crossing var(--end-range);
}
}
}
On older browsers, or with reduced motion turned on, the cards still stack. They just don’t shrink. Nothing is hidden and nothing breaks.
Why not a polyfill? Modern Web Guidance advises against the scroll-timeline polyfill because it isn’t feature complete and has a lot of known issues. For decorative effects like this one, progressive enhancement is the better choice: the page works everywhere, and the animation is a bonus.
Scroll-Driven Animation Debugging Checklist
When your scroll-driven animation does nothing:
- Is the declaration valid? In the Styles pane, look for a crossed-out or missing
animation-timeline. - Is
animation-timelineafter theanimationshorthand? If not, the shorthand resets it. - Is the browser new enough? Test with
@supports ((animation-timeline: view()) and (animation-range: entry)). - Which scroller is it attached to? Run
$0.getAnimations()[0].timeline.sourcein the Console (or use Bramus Van Damme’s free Scroll-Driven Animations Debugger extension). You want the page’s scrolling element (html), not a wrapper. If you get an error orundefined, the element you selected has no scroll-driven animation. Check you selected the animated element (not its parent), then go back to checks 1 and 2. - Does that scroller actually scroll? An ancestor with
overflow: hidden,auto, orscrollbecomes the scroller, even if it never scrolls. If you only wanted to clip content, switch tooverflow: clip. This fixes brokenposition: stickytoo. Watch out: puttingoverflow-x: hiddenon bothhtmlandbodyturnsbodyinto the scroller. - Can the element see the timeline name? Named timelines only reach the element and its descendants. Use
timeline-scopeon a shared ancestor if you need to share one. - Is the fill mode right? Jumps at the start? Add
backwards. Snaps back at the end? Addforwards.
Before you ship:
- Are you animating
transformandopacity? Animatingwidthortopstill triggers main-thread work. - Does the page still work with reduced motion turned on?
Conclusion
The web platform can now tie animations to scrolling with no JavaScript. Even though AI assistants are catching up, sometimes they reach for old patterns, and even good modern CSS can end up attached to the wrong thing when one overflow rule lands in the wrong place.
AI helped along the way here, but keep your own judgment switched on:
- AI only sees what it’s shown. When it couldn’t read my CSS, it guessed at resets and frameworks that weren’t there.
- It can be confidently wrong, especially on newer features. Treat its answer as a hypothesis.
- It may fix the symptom, not the cause. Its main fix moved the bug from
.pagetobody. Its afterthought,overflow-x: clip, was the real answer. Test every fix with the tool that found the bug.
The winning workflow: the tools show you what's true, the AI helps you read it, and you decide.
If you remember one thing, make it this question. When a scroll-driven animation does nothing, ask: which scroller is it attached to? It solves most of these bugs.
Now try it yourself. Pick one scroll effect on your site that still uses JavaScript and replace it with CSS. Then break it on purpose by adding overflow-x: hidden to a wrapper, and use the checklist to find your way back. You’ll remember it far better than anything you read here.
Here are some helpful resources:
- Scroll-driven animations demos by Bramus Van Damme
- Scroll-Driven Animations by Josh W. Comeau
- Chrome DevTools for agents
- How to Stop Your AI Coding Agent from Writing Outdated Code with Modern Web Guidance