Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
CSS

CSS: Fix a Scroll-Driven Animation Running Only on First Load

- 21.11.26 - ErcanOPAK

🎨 CSS: Fix a Scroll-Driven Animation Running Only on First Load

A CSS scroll-driven animation using animation-timeline: scroll() computes its timeline range from the scroller’s content size at the moment the timeline attaches to an element. If content is added later — images lazy-loading in, or a list populated after an API response — the scrollable height changes, but an already-established timeline for elements that existed before that growth doesn’t get recalculated, so the animation plays correctly on a cold load and looks stuck or already-finished once a warm cache renders fuller content before the timeline attaches.

🔎 The Problem

.reveal {
  animation: fade-in linear;
  animation-timeline: scroll();
  animation-range: entry 0% cover 40%;
}
/* Works on first (cold-cache) load. On a warm-cache reload, images
   above .reveal finish loading before the timeline attaches, the
   scrollable height is already final, and .reveal appears to have
   skipped straight to its end state. */

✅ Fix: Stop the Scroller’s Size From Changing After the Timeline Attaches

  • Reserve layout space for dynamically-loaded content (fixed dimensions, aspect-ratio boxes) so the scrollable height doesn’t change after the timeline attaches, instead of letting layout shift happen afterward.
  • For content that must load asynchronously, delay attaching animation-timeline to the affected elements until that content has settled, by toggling the timeline-bearing class only once a load/render signal fires.
  • Test the animation against both a cold cache and a warm cache, since a warm cache loading content faster and more completely before the timeline attaches is exactly the condition that exposes this gap.

🚨 Why This Is Dangerous

  • An animation that looks correct in every manual test — where you watch it attach cleanly — but silently breaks for users with a faster connection or a warm cache can go unnoticed in review and ship broken to exactly the visitors with the best browsing conditions.

A scroll-driven timeline measures the scroller once, at the moment it attaches — grow the content after that moment, and the timeline keeps grading against a page that no longer exists.

— UI Engineer

Related posts:

CSS: Use Pseudo Elements (::before, ::after) for Extra Content

CSS: Use Pseudo Elements (::before, ::after) for Extra Content

CSS: Use Grid auto-fit and auto-fill for Responsive Layouts Without Media Queries

CSS: Use Grid auto-fit and auto-fill for Responsive Layouts Without Media Queries

CSS: Use Media Queries for Responsive Design

CSS: Use Media Queries for Responsive Design

Views: 4

Post navigation

C#: Fix an Interceptor Silently Skipping an Overloaded Call
Photoshop: Fix a Pattern Preview Mode Not Tiling at the Canvas Edge

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (661)
  • Add Constraint to SQL Table to ensure email contains @ (619)
  • Average of all values in a column that are not zero in SQL (577)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (553)
  • Find numbers with more than two decimal places in SQL (481)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • AÄŸ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store
  • WordPress: Fix a Navigation Block Losing Submenu Items After Sync
  • Visual Studio: Fix CodeLens Reference Counts Stuck at Stale Numbers
  • C#: Fix a UTF-8 String Literal Behaving Differently in a Switch
  • Photoshop: Fix a Liquify Mesh Snapping Back on a Smart Object
  • The AI Prompt That Turns a Crash Dump Into a Short Repro Script

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • AÄŸ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com