惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
D
Docker
GbyAI
GbyAI
宝玉的分享
宝玉的分享
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Vercel News
Vercel News
博客园_首页
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
S
SegmentFault 最新的问题
Microsoft Security Blog
Microsoft Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
V
V2EX
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
IT之家
IT之家
Apple Machine Learning Research
Apple Machine Learning Research
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Opposing scroll columns with one view() timeline and thre...
Leo · 2026-06-25 · via DEV Community

Leo

You have adjacent columns of cards and you want them drifting in opposite directions as the visitor scrolls — one rising while the other falls. The reflex is to reach for a scroll handler, request a frame, translate each column by hand. CSS-Tricks just walked through the version where you write none of that. One scroll-driven animation primitive does the lift.

The timeline lives on the item, not the page

The mechanism is animation-timeline: view(). Set it on each card and the card's own progress through the scrollport becomes the animation's clock. Scroll past it, the animation completes. Scroll back, it reverses. No scroll listener and no global state. The browser ties the playhead to the geometry it already computes during scrolling.

This is the move worth slowing down on. With view() the timeline is per-element. Two columns side by side each generate their own clocks. From there, opposite directions are just opposite keyframes.

What animation-range: entry 0% cover 100% actually does

The other half is the range. animation-range: entry 0% cover 100% starts the animation the instant the card enters the scrollport and runs it through the cover range. The animation does not fire from a midpoint. It begins at first contact and ends when the card is on its way out. Cards never sit still during their visible life. They are always somewhere along the timeline.

.card {
  animation-timeline: view();
  animation-range: entry 0% cover 100%;
}

Three keyframe sets, with one offset

The article defines three separate @keyframes blocks, not two. Two carry the basic opposite-direction motion. The third is offset from the first so the outer columns land staggered against the inner ones. Same primitive, same timeline, different keyframes. That is all the variation needs to be.

If you have ever hand-tuned a scroll handler to do this, the size of the win is in what you stop writing. Three keyframe sets and a timeline replace the deltas, the per-direction velocity, the scroll lock.

Linear motion is not a default to ignore

The motion runs linearly. That matters because the scroll position is already an input the user controls. Easing on top of scroll fights the user's hand. Linear lets the animation track the scroll one for one and feel like direct manipulation rather than something the page is doing to itself.

The author also wraps the whole effect in prefers-reduced-motion. If the OS has been told to keep motion calm, the animation does not run.

@media (prefers-reduced-motion: reduce) {
  .card {
    animation: none;
  }
}

This is not optional craft. Anything driven by scroll position is motion in response to interaction, and prefers-reduced-motion is the platform's way of asking you to stop. Honour it.

Feature detection because Firefox is not there yet

At the time the source was written, scroll-driven animations were still pending in Firefox. The author wraps the effect in feature detection so the layout degrades gracefully where the timeline is not available. The columns sit as ordinary stacks, the page still works, and nobody gets a broken-looking shell. If you ship this, that wrapper is the part you cannot skip.

What this unlocks for your next layout

The interesting thing about animation-timeline: view() is not that you can make columns drift opposite ways. It is that any per-element visual state you used to push from JavaScript can collapse into a @keyframes block and a range. Once you have internalised "the item's own scrollport progress is the clock", the surface area of scroll-tied UI shrinks. You stop reaching for libraries that translate transforms inside a scroll handler.

What is still missing is uniform support, which is why the feature detect matters more than the keyframes. Try the technique on a side project this week, build the no-script fallback as the real layout, and treat the timeline as the enhancement. That is the shape of the new CSS for now.