fix(web): classic timer ran at 2x (idempotent startTimer) #96
@@ -270,6 +270,11 @@ function startGame(seed) {
|
||||
|
||||
// ── Timer ────────────────────────────────────────────────────────────────────
|
||||
function startTimer() {
|
||||
// Idempotent: never stack a second interval. The visibilitychange handler
|
||||
// and startGame can both call this, and a stray call (e.g. a load-time
|
||||
// visibilitychange while a timer is already running) would otherwise leak
|
||||
// the old interval and make elapsedSecs increment twice per second.
|
||||
if (timerInterval) return;
|
||||
timerInterval = setInterval(() => {
|
||||
elapsedSecs++;
|
||||
updateTimerDisplay();
|
||||
|
||||
Reference in New Issue
Block a user