Skip to content

Commit f2f38e0

Browse files
Bikram GoleBikram Gole
authored andcommitted
Lock matrix mode after pulse milestone
1 parent 50844fc commit f2f38e0

1 file changed

Lines changed: 35 additions & 6 deletions

File tree

script.js

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,12 +2222,15 @@ let matrixScrollHandler = null;
22222222
let matrixSize = { width: 0, height: 0, pixelRatio: 1 };
22232223
let matrixVisibilityHandler = null;
22242224
let matrixDraw = null;
2225+
let matrixLocked = false;
22252226

2226-
function startMatrixRain() {
2227+
function startMatrixRain(lock = false) {
22272228
if (matrixCanvas) {
22282229
document.body.classList.add("matrix-mode");
2230+
if (lock) matrixLocked = true;
22292231
return;
22302232
}
2233+
if (lock) matrixLocked = true;
22312234

22322235
matrixCanvas = document.createElement("canvas");
22332236
matrixCanvas.className = "matrix-layer";
@@ -2236,13 +2239,26 @@ function startMatrixRain() {
22362239

22372240
matrixResizeHandler = () => {
22382241
if (!matrixCanvas || !matrixContext) return;
2242+
const vv = window.visualViewport;
22392243
const viewportWidth = Math.max(
22402244
1,
2241-
Math.floor(Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0))
2245+
Math.floor(
2246+
Math.max(
2247+
document.documentElement.clientWidth || 0,
2248+
window.innerWidth || 0,
2249+
vv?.width || 0
2250+
)
2251+
)
22422252
);
22432253
const viewportHeight = Math.max(
22442254
1,
2245-
Math.floor(Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0))
2255+
Math.floor(
2256+
Math.max(
2257+
document.documentElement.clientHeight || 0,
2258+
window.innerHeight || 0,
2259+
vv?.height || 0
2260+
)
2261+
)
22462262
);
22472263
const pixelRatio = Math.max(1, window.devicePixelRatio || 1);
22482264

@@ -2323,7 +2339,12 @@ function startMatrixRain() {
23232339
document.addEventListener("visibilitychange", matrixVisibilityHandler);
23242340
}
23252341

2326-
function stopMatrixRain() {
2342+
function stopMatrixRain(force = false) {
2343+
if (matrixLocked && !force) {
2344+
showToast("Matrix locked. Drop Insight to reset.");
2345+
return;
2346+
}
2347+
matrixLocked = false;
23272348
document.body.classList.remove("matrix-mode");
23282349
if (matrixAnimation) cancelAnimationFrame(matrixAnimation);
23292350
matrixAnimation = null;
@@ -2513,6 +2534,13 @@ function toggleElonMode() {
25132534
}
25142535

25152536
function toggleMatrixMode() {
2537+
if (matrixLocked) {
2538+
if (!document.body.classList.contains("matrix-mode")) {
2539+
startMatrixRain(true);
2540+
}
2541+
showToast("Matrix locked. Drop Insight to reset.");
2542+
return;
2543+
}
25162544
if (document.body.classList.contains("matrix-mode")) {
25172545
stopMatrixRain();
25182546
showToast("Matrix rain disabled.");
@@ -2533,7 +2561,7 @@ function applyPulseMilestone(count) {
25332561
if (!document.body.classList.contains("istj-mode")) toggleISTJMode();
25342562
showToast("15 pulses: ISTJ Grid.");
25352563
} else if (count === 20) {
2536-
if (!document.body.classList.contains("matrix-mode")) startMatrixRain();
2564+
if (!document.body.classList.contains("matrix-mode")) startMatrixRain(true);
25372565
showToast("20 pulses: Matrix Rain.");
25382566
}
25392567
}
@@ -2549,8 +2577,9 @@ function resetPulseChain() {
25492577
document.body.classList.remove("istj-mode");
25502578
}
25512579
if (document.body.classList.contains("matrix-mode")) {
2552-
stopMatrixRain();
2580+
stopMatrixRain(true);
25532581
}
2582+
matrixLocked = false;
25542583
if (funkTimer) {
25552584
stopFunkAudio();
25562585
}

0 commit comments

Comments
 (0)