From 6cdd12d1d807dd9eb7cfdfc6e316f9787d33081e Mon Sep 17 00:00:00 2001 From: Kiyomichi Kosaka Date: Sat, 14 Jun 2025 23:28:55 +0200 Subject: [PATCH] Fix analog clock init timing --- clock.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/clock.js b/clock.js index 9276151..47c2afa 100644 --- a/clock.js +++ b/clock.js @@ -87,7 +87,7 @@ document.getElementById('handChronon').style.transform = `rotate(${cf * 360}deg)`; } - window.addEventListener('load', () => { + function initClock() { placeMarkers(); updateClock(); setInterval(updateClock, 1000); @@ -97,5 +97,11 @@ document.body.classList.toggle('fullscreen-clock'); }); } - }); + } + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', initClock); + } else { + initClock(); + } })();