ui: add shared motion layer (page enter, scroll reveal, loading bar)
- ui/motion.js: Motion.enter/scan/loading, IntersectionObserver reveal with sweep fallback for jump-scroll, hidden tab and late-rendered cards - _shared.css: --mu-ease token, .mu-loadbar, #view.mu-view-in, .mu-reveal - router.js: start/stop loading bar, replay enter animation per view - reduced-motion disables everything; maps are never transformed - sw.js: precache motion.js, VERSION 2026.09.27.104
This commit is contained in:
1 parent
ba5f4fd887
commit
5381e0690a
7 files changed
+351
-6
No files matched your search
@@ -130,6 +130,25 @@ python -m http.server 8090 # เปิด http://localhost:8090/ui/index.
|
||||
- `.gitignore` ว่างเปล่า — ถ้าเพิ่มไฟล์ขยะ (เช่น .DS_Store) ให้เพิ่มใน .gitignore
|
||||
- งานถัดไปที่คาดว่าเกี่ยวข้อง: นำดีไซน์นี้ไป implement ใน `web-at-transit` (Next.js)
|
||||
|
||||
## การเคลื่อนไหว (ui/motion.js) — อนิเมชันร่วมทุกหน้า
|
||||
|
||||
**ไฟล์:** `ui/motion.js` (โหลดใน `index.html` ก่อน `router.js`) + CSS ท้าย `_shared.css` (`.mu-loadbar`, `#view.mu-view-in`, `.mu-reveal`)
|
||||
**สเปก/โทเคน:** `DESIGN.md §8` — อย่าคิดระยะเวลาใหม่เอง
|
||||
|
||||
| ทำอะไร | เรียกจากไหน |
|
||||
|---|---|
|
||||
| แถบโหลดบางบนสุดระหว่าง fetch partial | `router.js` → `Motion.loading(true/false)` |
|
||||
| หน้าใหม่ค่อย ๆ โผล่ (fade + 10px) | `router.js` → `Motion.enter(viewEl)` หลัง inject |
|
||||
| การ์ดโผล่ตอนเลื่อน | อัตโนมัติ: `scan()` ใน `#view` + `MutationObserver` (การ์ดจาก JSON ก็ได้) |
|
||||
|
||||
**กติกา**
|
||||
- อนิเมตเฉพาะ `opacity` + `transform` · ห้าม width/height/top/left
|
||||
- **ห้าม**ใส่ `.mu-reveal` ให้อิลิเมนต์ที่ครอบแผนที่ (`.at-map`, `.leaflet-container`, `.blog-mapx`) — ใส่ `data-no-reveal` ถ้าต้องการยกเว้นเอง
|
||||
- ของที่เห็นบนจอตอนโหลดไม่ถูกอนิเมต · หลังจบจะลบ class ทิ้ง (hover lift เดิมไม่เพี้ยน)
|
||||
- `prefers-reduced-motion: reduce` → ปิดทั้งหมด (ทั้ง JS และ CSS)
|
||||
- เพิ่มหน้าใหม่: ไม่ต้องแก้อะไร (router + observer จัดการ) — เพียงใช้คลาสการ์ดเดิม (`mu-card`, `mu-stop-card`, `mu-zone`, `mu-summary`, `mu-stat`, …)
|
||||
- อย่าลืม `./motion.js` ใน `PRECACHE` ของ `sw.js` (มีแล้ว) และ bump `VERSION` เมื่อแก้ SW
|
||||
|
||||
## หน้ารายละเอียดป้าย `#/stops/<รหัสป้าย>` — ข้อมูลมาจากไหน
|
||||
|
||||
หน้า `ui/partials/stopDetail.html` เป็น "โครงเปล่า" ล้วน ๆ (มีแต่ `<style>` + element ที่มี id)
|
||||
|
||||
Reference in new issue
Block a user