diff --git a/main-site/easter-egg.js b/main-site/easter-egg.js index 2db1bc9..3693d5e 100644 --- a/main-site/easter-egg.js +++ b/main-site/easter-egg.js @@ -39,20 +39,31 @@ var active = false; var tapCount = 0; var tapTimer = null; + var lastTouch = 0; - // 7 quick taps on any non-interactive part of the page triggers it - document.addEventListener('click', function (e) { + function registerTap() { if (active) return; - if (e.target.closest('a, button, input, select, textarea, label')) return; - tapCount++; clearTimeout(tapTimer); - tapTimer = setTimeout(function () { tapCount = 0; }, 2000); - - if (tapCount >= 7) { + tapTimer = setTimeout(function () { tapCount = 0; }, 3000); + if (tapCount >= 5) { tapCount = 0; launch(); } + } + + // touchstart for mobile (fires immediately, not affected by scroll) + document.addEventListener('touchstart', function (e) { + if (e.target.closest('input, select, textarea')) return; + lastTouch = Date.now(); + registerTap(); + }, { passive: true }); + + // click for desktop (deduplicated from touch events) + document.addEventListener('click', function (e) { + if (Date.now() - lastTouch < 500) return; // already counted via touchstart + if (e.target.closest('input, select, textarea')) return; + registerTap(); }); function launch() {