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
@@ -518,3 +518,73 @@ body:has(.mu-site-footer) .mu-footer { display: none; }
|
||||
}
|
||||
.mu-install-btn:active { transform: translateY(1px); }
|
||||
.mu-install-btn svg { width: 20px; height: 20px; }
|
||||
|
||||
/* =========================================================
|
||||
Motion — อนิเมชันร่วมทุกหน้า (ไฟล์ JS: ui/motion.js)
|
||||
---------------------------------------------------------
|
||||
โทเคนเดียวทั้งเว็บ: ระยะ/ความเร็ว/เส้นโค้ง อยู่ที่นี่ที่เดียว
|
||||
· --mu-ease = deceleration (เข้าช้า ออกเร็ว ตาม MD motion)
|
||||
· 420ms = เข้าหน้า · 520ms = reveal · 45ms = ระยะเหลื่อมต่อชิ้น
|
||||
ปิดทั้งชุดเมื่อผู้ใช้ตั้ง prefers-reduced-motion: reduce
|
||||
========================================================= */
|
||||
:root {
|
||||
--mu-ease: cubic-bezier(.22, .61, .36, 1);
|
||||
}
|
||||
|
||||
/* ---------- แถบโหลดบาง ๆ บนสุด (ระหว่าง fetch partial) ---------- */
|
||||
.mu-loadbar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 3px;
|
||||
z-index: 1200; /* เหนือ topbar (1100) แต่ใต้ vreset (3000) */
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transition: opacity .25s ease; /* ออกเร็วกว่าเข้า (60–70%) */
|
||||
}
|
||||
.mu-loadbar.is-on { opacity: 1; }
|
||||
.mu-loadbar-fill {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
transform: scaleX(0);
|
||||
transform-origin: 0 50%;
|
||||
border-radius: 0 2px 2px 0;
|
||||
background: linear-gradient(90deg, #7a4cc0, #b694f6);
|
||||
box-shadow: 0 0 8px rgba(122, 76, 192, .45);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
/* ---------- เข้าหน้าใหม่: จาง + เลื่อนขึ้นเล็กน้อย ---------- */
|
||||
#view.mu-view-in {
|
||||
animation: muViewIn .42s var(--mu-ease) both;
|
||||
}
|
||||
@keyframes muViewIn {
|
||||
from { opacity: 0; transform: translate3d(0, 10px, 0); }
|
||||
to { opacity: 1; transform: none; }
|
||||
}
|
||||
|
||||
/* ---------- เลื่อนแล้วค่อยโผล่ ---------- */
|
||||
/* JS ใส่ .mu-reveal เฉพาะของที่ยังไม่เห็นบนจอ → ไม่มีอะไรกะพริบตอนโหลด
|
||||
ใช้เฉพาะ opacity + transform = ไม่ดันเลย์เอาต์ (CLS 0) */
|
||||
.mu-reveal {
|
||||
opacity: 0;
|
||||
transform: translate3d(0, 18px, 0);
|
||||
transition:
|
||||
opacity .52s var(--mu-ease),
|
||||
transform .52s var(--mu-ease);
|
||||
transition-delay: var(--mu-d, 0ms);
|
||||
}
|
||||
.mu-reveal.is-in {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* ลดการเคลื่อนไหว: ไม่มีอนิเมชัน แต่เนื้อหาต้องอ่านได้ทันที */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
#view.mu-view-in { animation: none; }
|
||||
.mu-reveal { opacity: 1; transform: none; transition: none; }
|
||||
.mu-loadbar { display: none; }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user