Loading...
Loading...
Hiệu ứng cuộn trang thuần CSS qua Native CSS Scroll-Driven Animations API (animation-timeline scroll()/view(), animation-range) — ZERO JavaScript. Gọi khi user nói "css scroll driven animation", "animation-timeline", "scroll animation không js", "css thuần cuộn trang", "scroll-driven CSS", hoặc /css-scroll-driven-native. KHÁC `skills/scroll-effects` (đó dùng IntersectionObserver JS, chạy MỌI trình duyệt hiện đại) — skill này 0 JS nhưng trình duyệt CHƯA hỗ trợ đủ (Firefox/Safari còn behind flag/rollout), dùng làm progressive enhancement phía trên scroll-effects, không thay thế khi cần chạy chắc trên mọi trình duyệt.
npx skill4agent add rheinmir/setup css-scroll-driven-nativeanimation-timeline: scroll()view()animation-rangeanimation-timelinescroll-effectsscroll-effectsscroll-effectstimeline (scroll(root) | view()) + animation-range → keyframes; toàn bộ nằm trong @supports → @media not (prefers-reduced-motion: reduce); ngoài hai khối đó = trạng thái tĩnh hiện đủ nội dung| Field | Required? | Ý nghĩa | |
|---|---|---|---|
| In | cơ chế cần (progress / reveal / parallax) | có | chọn 1–3 trong 3 cơ chế |
| In | | không | có thì đổi token màu/spacing theo nó |
| Out | CSS (+ markup tối thiểu) adapt từ | có | mọi animation trong |
| Out | bằng chứng verify | có | ảnh 0%/50%/100% scroll + ảnh reduce-motion qua |
@supports@supports (animation-timeline: scroll())@supports (animation-timeline: view())@supportsopacity:0@supportsprefers-reduced-motion@media not (prefers-reduced-motion: reduce)@supportsdemo.cssanimation-duration1msplaywright-verifyprefers-reduced-motion: reduceemulateMediadesign.mdscroll-effects@supportsanimation-duration| Step | Type | Inputs | Action | Outputs/exit | Failure/next |
|---|---|---|---|---|---|
| W01 | judgment | yêu cầu + đích trình duyệt | Chọn skill này hay | quyết định | cần chắc đa trình duyệt → B01 |
| W02 | deterministic | | Đọc | snippet | — |
| W03 | effect | snippet, | ADAPT token màu/spacing; đặt animation trong | CSS trong dự án | — |
| W04 | deterministic | trang đã gắn | Verify RULE-05: chụp 0/50/100% + | ảnh + assert | assert đỏ → sửa, lặp W04 |
| ID | Kind | Guard | Hành vi | Skip / failure | Rejoin |
|---|---|---|---|---|---|
| B01 | user_optional | cần chạy chắc đa trình duyệt nhưng vẫn muốn 0-JS mượt hơn | kết hợp: | chỉ cần Chromium → skip | W02 |
.csdn-progressanimation-timeline: scroll(root)@supportsopacity:0opacity:0@supportsscroll-effects | | |
|---|---|---|
| JS | 0 dòng | IntersectionObserver + rAF |
| Hỗ trợ trình duyệt | Chrome/Edge tốt; Firefox/Safari đang rollout, có thể chưa bật mặc định | Mọi trình duyệt hiện đại |
| Khi dùng | Progressive enhancement — thêm "độ mượt" cho trình duyệt đã hỗ trợ, KHÔNG phải cơ chế chính nếu cần chạy chắc production đa trình duyệt ngay | Cơ chế chính khi cần chạy chắc ngay, không đợi rollout |
@supports (animation-timeline: scroll())scroll-effects| Trình duyệt | | |
|---|---|---|
| Chrome / Edge | Có | Có |
| Firefox | Behind flag / đang rollout | Behind flag / đang rollout |
| Safari | Đang rollout, chưa ổn định | Đang rollout, chưa ổn định |
assets/demo.htmlassets/demo.cssdesign.md<div class="csdn-progress"></div>.csdn-progress {
animation-name: progress-scale;
animation-duration: 1ms; /* giá trị bất kỳ để kích hoạt engine — thời lượng thật do timeline điều khiển */
animation-timeline: scroll(root);
animation-fill-mode: both;
}
@keyframes progress-scale {
from { transform: scaleX(0); }
to { transform: scaleX(1); }
}scroll(root)scrollscrollY / scrollHeight<article class="csdn-card">…</article>.csdn-card {
animation-name: reveal-in;
animation-timeline: view();
animation-range: entry 0% cover 40%;
animation-fill-mode: both;
}view()animation-range: entry 0% cover 40%entry 0%view()animation-rangeview()scrollY.parallax-bg { animation-timeline: view(); animation-range: cover 0% cover 100%; } /* trôi chậm, suốt cả quãng */
.parallax-content { animation-timeline: view(); animation-range: entry 0% cover 35%; } /* chạy nhanh, chỉ đoạn đầu */assets/demo.cssskills/scroll-effects