fix(motion): คืนอนิเมชัน reveal ที่หายไป + จดข้อยกเว้นเบราว์เซอร์
สาเหตุ: hydration เขียนทับ class ของ <html> ทำให้ `fx-motion` หลุด และอนิเมชันเดิมผูกกับคลาสนั้นอย่างเดียว → อนิเมชันหายทั้งเว็บ - ผูก "ตัวอนิเมชัน" กับ @media (prefers-reduced-motion: no-preference) (สถานะซ่อนก่อน reveal ยังผูกกับ html.fx-motion เพื่อกันเนื้อหาหายเมื่อปิด JS) - เพิ่ม <MotionBootstrap/> เติมคลาส fx-motion ซ้ำหลัง hydration + ฟังการเปลี่ยน reduced-motion - คืน @keyframes fx-swap-in ที่หลุดไประหว่างแก้ CSS - DESIGN.md: Motion contract สองชั้น + ตารางข้อยกเว้นต่อเบราว์เซอร์ (scrollbar/share/install/blur/ฟอนต์ไทย/ITP) - sw VERSION v2.0.4
This commit is contained in:
1 parent
2eb625c8bc
commit
cfb24b8138
4 files changed
+92
-40
No files matched your search
+46
-37
@@ -400,31 +400,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* สถานะตั้งต้น: ซ่อนเฉพาะเมื่อ motion เปิดอยู่ (JS ใส่คลาสแล้วเท่านั้น) */
|
||||
html.fx-motion [data-reveal] {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
html.fx-motion [data-reveal="rise"][data-revealed] {
|
||||
animation: fx-rise-in var(--fx-slow) var(--fx-ease-out) var(--fx-delay, 0ms)
|
||||
both;
|
||||
}
|
||||
|
||||
html.fx-motion [data-reveal="fade"][data-revealed] {
|
||||
animation: fx-fade-in var(--fx-base) var(--fx-ease-out) var(--fx-delay, 0ms)
|
||||
both;
|
||||
}
|
||||
|
||||
html.fx-motion [data-reveal="zoom"][data-revealed] {
|
||||
animation: fx-pop-in var(--fx-slow) var(--fx-ease-out) var(--fx-delay, 0ms)
|
||||
both;
|
||||
}
|
||||
|
||||
/* อนิเมชันตอนโหลด (ไม่ผูกกับ scroll) */
|
||||
html.fx-motion .fx-page {
|
||||
animation: fx-page-in var(--fx-page) var(--fx-ease-out) both;
|
||||
}
|
||||
|
||||
/* สลับภาพในแกลเลอรี (ปุ่มลูกศร) — จางเข้าเบา ๆ ไม่กระตุก */
|
||||
@keyframes fx-swap-in {
|
||||
from {
|
||||
@@ -437,25 +412,59 @@ html.fx-motion .fx-page {
|
||||
}
|
||||
}
|
||||
|
||||
html.fx-motion .fx-swap {
|
||||
animation: fx-swap-in 320ms var(--fx-ease-out) both;
|
||||
/* ══ สถานะตั้งต้น + อนิเมชัน reveal ══════════════════════════════════════
|
||||
กันสองทาง:
|
||||
1) เนื้อหาห้ามหายถ้าปิด JS → สถานะ "ซ่อน" ผูกกับคลาส `html.fx-motion`
|
||||
(คลาสถูกใส่โดยสคริปต์ใน <head> และเสริมอีกครั้งจาก client effect)
|
||||
2) อนิเมชันต้องทำงานแม้คลาสหลุด (เคยเกิดจาก hydration ลบคลาส) → ตัวอนิเมชัน
|
||||
ผูกกับ `@media (prefers-reduced-motion: no-preference)` แทน
|
||||
ผลคือทุกเอนจิน (Chromium / Firefox / Safari) ได้อนิเมชันเหมือนกัน และ
|
||||
ผู้ใช้ที่ขอ reduced motion ได้เนื้อหานิ่งครบทันที */
|
||||
html.fx-motion [data-reveal] {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
html.fx-motion .fx-drop {
|
||||
animation: fx-drop-in var(--fx-base) var(--fx-ease-out) both;
|
||||
}
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
[data-reveal="rise"][data-revealed] {
|
||||
animation: fx-rise-in var(--fx-slow) var(--fx-ease-out) var(--fx-delay, 0ms)
|
||||
both;
|
||||
}
|
||||
|
||||
html.fx-motion .fx-hero-image {
|
||||
animation: fx-hero-zoom 1400ms var(--fx-ease-out) both;
|
||||
[data-reveal="fade"][data-revealed] {
|
||||
animation: fx-fade-in var(--fx-base) var(--fx-ease-out) var(--fx-delay, 0ms)
|
||||
both;
|
||||
}
|
||||
|
||||
[data-reveal="zoom"][data-revealed] {
|
||||
animation: fx-pop-in var(--fx-slow) var(--fx-ease-out) var(--fx-delay, 0ms)
|
||||
both;
|
||||
}
|
||||
|
||||
/* อนิเมชันตอนโหลด (ไม่ผูกกับ scroll) */
|
||||
.fx-page {
|
||||
animation: fx-page-in var(--fx-page) var(--fx-ease-out) both;
|
||||
}
|
||||
|
||||
.fx-swap {
|
||||
animation: fx-swap-in 320ms var(--fx-ease-out) both;
|
||||
}
|
||||
|
||||
.fx-drop {
|
||||
animation: fx-drop-in var(--fx-base) var(--fx-ease-out) both;
|
||||
}
|
||||
|
||||
.fx-hero-image {
|
||||
animation: fx-hero-zoom 1400ms var(--fx-ease-out) both;
|
||||
}
|
||||
}
|
||||
|
||||
/* ทางออกสุดท้าย: ถ้าผู้ใช้ขอ reduced motion ให้ทุกอย่างนิ่งและเห็นครบ */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
html.fx-motion [data-reveal],
|
||||
html.fx-motion .fx-page,
|
||||
html.fx-motion .fx-drop,
|
||||
html.fx-motion .fx-swap,
|
||||
html.fx-motion .fx-hero-image {
|
||||
[data-reveal],
|
||||
.fx-page,
|
||||
.fx-drop,
|
||||
.fx-swap,
|
||||
.fx-hero-image {
|
||||
animation: none !important;
|
||||
opacity: 1 !important;
|
||||
transform: none !important;
|
||||
|
||||
Reference in new issue
Block a user