fix(js): boot guard + cache-busted script, नav breakpoint, docs
- wrap init ใน boot() พร้อม retry จนกว่า #progress จะมีใน DOM - กันแคชสคริปต์ด้วย ?v=7 + defer - ปรับ breakpoint เมนูเป็น 960px และแก้สีหัวข้อ dorm บนพื้นขาว - DESIGN.md: motion tokens, กติกา section #why, reduced-motion - README: แหล่งอ้างอิง NYT/Verge และ Microsoft Q&A
This commit is contained in:
1 parent
e26cc685d0
commit
3dcbdb88e7
2 files changed
+28
-1
No files matched your search
@@ -8,6 +8,14 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
/* รอให้ DOM พร้อมก่อนเสมอ — กันกรณีสคริปต์ถูกเรียกก่อน element ถูก parse */
|
||||
var booted = false;
|
||||
|
||||
function boot() {
|
||||
if (booted) return true;
|
||||
if (!document.getElementById("progress")) return false;
|
||||
booted = true;
|
||||
|
||||
var ORDER_EMAIL = "[email protected]"; // TODO: เปลี่ยนเป็นอีเมลร้านจริง
|
||||
var reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
|
||||
@@ -307,4 +315,23 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function tryBoot() {
|
||||
if (boot()) return;
|
||||
document.addEventListener("DOMContentLoaded", tryBoot, { once: true });
|
||||
window.addEventListener("load", tryBoot, { once: true });
|
||||
var tries = 0;
|
||||
(function retry() {
|
||||
if (boot() || ++tries > 30) return;
|
||||
setTimeout(retry, 100);
|
||||
})();
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", tryBoot, { once: true });
|
||||
} else {
|
||||
tryBoot();
|
||||
}
|
||||
window.addEventListener("load", tryBoot);
|
||||
})();
|
||||
+1
-1
@@ -871,6 +871,6 @@
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="assets/js/main.js"></script>
|
||||
<script src="assets/js/main.js?v=7" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user