|
1300 | 1300 | requestAnimationFrame(animateLoop); |
1301 | 1301 | } |
1302 | 1302 |
|
1303 | | - // ---------- Reveal gate (home: hidden until “Alpha” is clicked) ---------- |
| 1303 | + // ---------- Reveal gate (home: hidden until “Beta” is clicked) ---------- |
| 1304 | + |
| 1305 | + var BETA_TEASER_INTERVAL_MS = 120000; /* 2 minutes between peeks */ |
| 1306 | + var BETA_TEASER_VISIBLE_MS = 1100; |
| 1307 | + var betaTeaserIntervalTimer = null; |
| 1308 | + var betaTeaserHideTimer = null; |
| 1309 | + |
| 1310 | + function getBetaRevealButton() { |
| 1311 | + return document.getElementById('ladybug-reveal-beta'); |
| 1312 | + } |
| 1313 | + |
| 1314 | + function positionBugForBetaTeaser(betaEl) { |
| 1315 | + var r = betaEl.getBoundingClientRect(); |
| 1316 | + if (r.width < 2 || r.height < 2) return false; |
| 1317 | + var tx = r.right - bugSize * 0.42; |
| 1318 | + var ty = r.top - bugSize * 0.12; |
| 1319 | + tx = clamp(tx, 4, window.innerWidth - bugSize - 4); |
| 1320 | + ty = clamp(ty, 4, window.innerHeight - bugSize - 4); |
| 1321 | + bug.style.setProperty('--ladybug-teaser-x', tx + 'px'); |
| 1322 | + bug.style.setProperty('--ladybug-teaser-y', ty + 'px'); |
| 1323 | + bug.style.transform = 'translate3d(' + tx + 'px, ' + ty + 'px, 0) rotate(180deg) scale(0.9)'; |
| 1324 | + x = tx; |
| 1325 | + y = ty; |
| 1326 | + return true; |
| 1327 | + } |
| 1328 | + |
| 1329 | + function stopBetaTeaserLoop() { |
| 1330 | + if (betaTeaserIntervalTimer) { |
| 1331 | + clearInterval(betaTeaserIntervalTimer); |
| 1332 | + betaTeaserIntervalTimer = null; |
| 1333 | + } |
| 1334 | + } |
| 1335 | + |
| 1336 | + function cancelBetaTeaser() { |
| 1337 | + stopBetaTeaserLoop(); |
| 1338 | + if (betaTeaserHideTimer) { |
| 1339 | + clearTimeout(betaTeaserHideTimer); |
| 1340 | + betaTeaserHideTimer = null; |
| 1341 | + } |
| 1342 | + bug.classList.remove('ladybug-gate-teaser', 'ladybug-beta-teaser-animate', 'ladybug-flying'); |
| 1343 | + bug.style.removeProperty('--ladybug-teaser-x'); |
| 1344 | + bug.style.removeProperty('--ladybug-teaser-y'); |
| 1345 | + var betaBtn = getBetaRevealButton(); |
| 1346 | + if (betaBtn) { |
| 1347 | + betaBtn.classList.remove('site-beta-tag--teaser-hint'); |
| 1348 | + } |
| 1349 | + } |
| 1350 | + |
| 1351 | + function endBetaTeaser() { |
| 1352 | + betaTeaserHideTimer = null; |
| 1353 | + if (!isLadybugGateHidden()) return; |
| 1354 | + bug.classList.remove('ladybug-gate-teaser', 'ladybug-beta-teaser-animate', 'ladybug-flying'); |
| 1355 | + var betaBtn = getBetaRevealButton(); |
| 1356 | + if (betaBtn) { |
| 1357 | + betaBtn.classList.remove('site-beta-tag--teaser-hint'); |
| 1358 | + } |
| 1359 | + } |
| 1360 | + |
| 1361 | + function runBetaTeaser() { |
| 1362 | + if (!isLadybugGateHidden()) return; |
| 1363 | + if (bug.classList.contains('ladybug-gate-teaser')) return; |
| 1364 | + var betaBtn = getBetaRevealButton(); |
| 1365 | + if (!betaBtn) return; |
| 1366 | + if (!positionBugForBetaTeaser(betaBtn)) return; |
| 1367 | + |
| 1368 | + bug.classList.add('ladybug-gate-teaser', 'ladybug-beta-teaser-animate', 'ladybug-flying'); |
| 1369 | + betaBtn.classList.add('site-beta-tag--teaser-hint'); |
| 1370 | + |
| 1371 | + betaTeaserHideTimer = setTimeout(endBetaTeaser, BETA_TEASER_VISIBLE_MS); |
| 1372 | + } |
| 1373 | + |
| 1374 | + function startBetaTeaserLoop() { |
| 1375 | + if (!getBetaRevealButton()) return; |
| 1376 | + if (window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches) return; |
| 1377 | + stopBetaTeaserLoop(); |
| 1378 | + |
| 1379 | + betaTeaserIntervalTimer = setInterval(function () { |
| 1380 | + if (!isLadybugGateHidden()) { |
| 1381 | + stopBetaTeaserLoop(); |
| 1382 | + return; |
| 1383 | + } |
| 1384 | + runBetaTeaser(); |
| 1385 | + }, BETA_TEASER_INTERVAL_MS); |
| 1386 | + } |
1304 | 1387 |
|
1305 | 1388 | function revealLadybugEasterEgg() { |
| 1389 | + cancelBetaTeaser(); |
1306 | 1390 | if (!bug.classList.contains('ladybug-gate-hidden')) return; |
1307 | 1391 | if (particlesHost) particlesHost.classList.remove('ladybug-gate-hidden'); |
1308 | 1392 | if (pill) pill.classList.remove('ladybug-gate-hidden'); |
|
1337 | 1421 | lastScrollY = window.scrollY || window.pageYOffset || 0; |
1338 | 1422 | initH1BiteTarget(); |
1339 | 1423 | bindLadybugRevealControl(); |
| 1424 | + startBetaTeaserLoop(); |
1340 | 1425 | requestAnimationFrame(animateLoop); |
1341 | 1426 | setTimeout(function () { |
1342 | 1427 | if (!isLadybugGateHidden() && isDarkTheme()) { |
|
0 commit comments