Fix easter egg trigger: use touchstart on mobile, 5 taps in 3s

click events are unreliable on mobile due to scroll handling. Use
touchstart (fires immediately) for mobile and click for desktop with
deduplication. Lower threshold to 5 taps, widen window to 3 seconds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
chris 2026-06-06 21:23:05 -04:00
parent 066364d2b7
commit 181195dbbc

View File

@ -39,20 +39,31 @@
var active = false; var active = false;
var tapCount = 0; var tapCount = 0;
var tapTimer = null; var tapTimer = null;
var lastTouch = 0;
// 7 quick taps on any non-interactive part of the page triggers it function registerTap() {
document.addEventListener('click', function (e) {
if (active) return; if (active) return;
if (e.target.closest('a, button, input, select, textarea, label')) return;
tapCount++; tapCount++;
clearTimeout(tapTimer); clearTimeout(tapTimer);
tapTimer = setTimeout(function () { tapCount = 0; }, 2000); tapTimer = setTimeout(function () { tapCount = 0; }, 3000);
if (tapCount >= 5) {
if (tapCount >= 7) {
tapCount = 0; tapCount = 0;
launch(); 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() { function launch() {