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
@@ -123,6 +123,8 @@
|
||||
window.__route = route; // ให้ script ใน partial อ่าน params ได้
|
||||
|
||||
|
||||
if (window.Motion) Motion.loading(true); // แถบโหลดบาง ๆ ระหว่าง fetch
|
||||
|
||||
fetch(view.partial, { cache: 'no-store' })
|
||||
.then(function (res) {
|
||||
if (!res.ok) throw new Error('HTTP ' + res.status);
|
||||
@@ -140,10 +142,14 @@
|
||||
document.title = (window.I18N && view.tkey) ? I18N.t(view.tkey) : ('Atroute — ' + view.title);
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
/* อนิเมชันเข้าหน้า + สแกนการ์ดที่จะค่อย ๆ โผล่ตอนเลื่อน (ui/motion.js) */
|
||||
if (window.Motion) { Motion.loading(false); Motion.enter(viewEl); }
|
||||
|
||||
/* footer "สายที่เปิดดูบ่อย" — เรนเดอร์ทุกครั้ง (ตามภาษา + อันดับล่าสุด) */
|
||||
mountPopular();
|
||||
})
|
||||
.catch(function () {
|
||||
if (window.Motion) Motion.loading(false);
|
||||
viewEl.innerHTML =
|
||||
'<div class="mu-container" style="padding:64px 28px;text-align:center;color:#6f7b95;">' +
|
||||
(window.I18N ? I18N.t('router.loadFail') : 'โหลดเนื้อหาไม่สำเร็จ') + '</div>';
|
||||
|
||||
Reference in new issue
Block a user