feat(motion): scroll-reveal and cinematic entrance animations
- motion.css / motion.js: reveal-on-scroll (IntersectionObserver), hero word-by-word entrance, drifting warm orbs, sheen on primary CTA, section underline sweep, scroll progress bar, count-up numbers - content never hidden unless <html>.fx-motion: JS off or reduced-motion shows everything - hover lift moved to the translate property so reveal keyframes cannot override it - re-call initReveal after grid re-render and admin re-mount; SW precache + VERSION bump - docs: DESIGN.md §9 motion contract, AGENTS.md pitfalls
This commit is contained in:
1 parent
c00bc62272
commit
2950295690
10 files changed
+503
-12
No files matched your search
@@ -73,3 +73,29 @@
|
||||
- ไอคอน PNG จริง 192 / 512 / 512-maskable / 180 (สร้างจาก `make_icons` ด้วย PIL ไม่ใช้ตัวอักษร)
|
||||
- `sw.js`: network-first สำหรับ HTML/CSS/JS/JSON, cache-first สำหรับรูป/ฟอนต์, ข้าม `/api/`
|
||||
- แก้ `sw.js` หรือรายการ `PRECACHE` → ต้อง bump `VERSION` และ `<meta name="app-version">` พร้อมกัน
|
||||
|
||||
## 9. Motion (ลูกเล่นภาพเคลื่อนไหว)
|
||||
|
||||
ไฟล์: `assets/css/motion.css` + `ui/motion.js`
|
||||
|
||||
**สัญญาความปลอดภัยของเนื้อหา** — ห้ามซ่อนเนื้อหาใน CSS หลัก:
|
||||
- inline script ใน `<head>` ใส่ `.fx-motion` ที่ `<html>` ก่อนวาดเฟรมแรก เว้นแต่ผู้ใช้ตั้ง `prefers-reduced-motion: reduce`
|
||||
- CSS ซ่อนเฉพาะ `html.fx-motion [data-reveal]`; เมื่อ JS ปิด/ถูกบล็อก/ลดการเคลื่อนไหว → เนื้อหาเห็นครบ ไม่มีช่วงจอว่าง
|
||||
- ทุก keyframe มีคู่หูใน `@media (prefers-reduced-motion: reduce)` ที่สั่ง `animation: none; opacity: 1; transform: none`
|
||||
|
||||
**อนิเมตได้เฉพาะ `transform` / `opacity` / `filter`** — ห้ามอนิเมต `width` / `height` / `top`
|
||||
|
||||
| องค์ประกอบ | ท่า | เวลา |
|
||||
|---|---|---|
|
||||
| ชื่อเรื่องฮีโร่ | แยกเป็นคำ (`splitWordsHtml` ตัดด้วยช่องว่างเท่านั้น ปลอดภัยกับสระ/วรรณยุกต์ไทย) ยกขึ้น + คลายเบลอ | 760ms · เริ่ม 140ms · เว้น 85ms/คำ |
|
||||
| ป้ายเหนือหัวเรื่อง / คำโปรย / ช่องค้นหา / แถบข้อมูล | drop / rise / pop / fade ตามลำดับ | 520–760ms |
|
||||
| การ์ดลอยในฮีโร่ | สไลด์จากซ้าย ทีละใบ | 700ms · 320/440/560ms |
|
||||
| การ์ดโปรเจค | `data-reveal="pop"` ตอนเลื่อนถึง (IntersectionObserver, `rootMargin: 2000px 0px -6% 0px`) | 660ms · หน่วง 95ms × คอลัมน์ |
|
||||
| หัวข้อ section | เส้นใต้กวาดจากซ้าย (`scaleX`) | 760ms |
|
||||
| แถบความคืบหน้า | `scaleX` ตาม scroll ผ่าน rAF | — |
|
||||
|
||||
**กับดักที่ต้องจำ**
|
||||
- การ์ดที่สร้างใหม่ (กรองคำค้นหา) ต้องเรียก `initReveal(gridEl)` ซ้ำ ไม่งั้นค้างที่ `opacity: 0`
|
||||
- `mount()` ของหน้า admin ถูกเรียกซ้ำ (กด “ทิ้งการแก้ไข”) → ต้องเรียก `initReveal(root)` ทุกครั้ง
|
||||
- hover ยกการ์ดใช้พร็อพเพอร์ตี `translate` (ไม่ใช่ `transform`) เพราะ `animation-fill-mode: both` ของ reveal จะทับ `transform`
|
||||
- แท็บที่อยู่เบื้องหลัง: IntersectionObserver ไม่ยิงและ rAF หยุด — อย่าด่วนสรุปว่าโค้ดพัง ให้ยกแท็บขึ้นหน้าก่อนวัด
|
||||
Reference in new issue
Block a user