Merge pull request #24 from ok2/codex/disable-animation-during-state-reset

Fix analog clock wrap-around animation
This commit is contained in:
Kiyomichi Kosaka 2025-06-15 00:51:04 +02:00 committed by GitHub
commit 3a3bfc8ebb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,6 +37,31 @@
});
}
const lastAngles = {
handXeno: 0,
handQuantic: 0,
handChronon: 0,
handEonstrip: 0,
handMegasequence: 0
};
function rotateHand(id, angle) {
const el = document.getElementById(id);
if (!el) return;
const prev = lastAngles[id];
if (angle < prev) {
// Disable transition for wrap-around jumps
el.style.transition = 'none';
el.style.transform = `rotate(${angle}deg)`;
// Force reflow so the style takes effect immediately
void el.offsetWidth;
el.style.transition = '';
} else {
el.style.transform = `rotate(${angle}deg)`;
}
lastAngles[id] = angle;
}
function updateClock() {
const now = new Date();
const cob = toCobiets(now);
@ -46,11 +71,11 @@
const cf = (cob % COBIE_UNITS.eonstrip) / COBIE_UNITS.eonstrip;
const ef = (cob % COBIE_UNITS.megasequence) / COBIE_UNITS.megasequence;
const mf = (cob % COBIE_UNITS.cosmocycle) / COBIE_UNITS.cosmocycle;
document.getElementById('handXeno').style.transform = `rotate(${xf * 360}deg)`;
document.getElementById('handQuantic').style.transform = `rotate(${qf * 360}deg)`;
document.getElementById('handChronon').style.transform = `rotate(${cf * 360}deg)`;
document.getElementById('handEonstrip').style.transform = `rotate(${ef * 360}deg)`;
document.getElementById('handMegasequence').style.transform = `rotate(${mf * 360}deg)`;
rotateHand('handXeno', xf * 360);
rotateHand('handQuantic', qf * 360);
rotateHand('handChronon', cf * 360);
rotateHand('handEonstrip', ef * 360);
rotateHand('handMegasequence', mf * 360);
}
function initClock() {