This commit is contained in:
Jevinca Marvella 2025-12-02 21:45:58 +07:00
parent 7676a07935
commit 35a97679c3
3 changed files with 23 additions and 11 deletions

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>2048 - Neon Edition</title>
<title>2048</title>
<link rel="stylesheet" href="2048.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

View File

@ -1,8 +1,13 @@
/* ------------------------
6. INPUT HANDLER
------------------------ */
------------------------
*/
let inputLocked = false;
function handleKey(e) {
if (isMoving) return;
if (isMoving || inputLocked) return; // ⛔ BLOK kalau sedang buka sound panel
let moved = false;
const k = e.key;
@ -35,19 +40,23 @@ function handleKey(e) {
let touchStartX = 0;
let touchStartY = 0;
document.addEventListener("touchstart", function (e) {
if (inputLocked) return; // ⛔ jangan catat swipe
const t = e.touches[0];
touchStartX = t.clientX;
touchStartY = t.clientY;
}, { passive: true });
document.addEventListener("touchend", function (e) {
if (isMoving) return;
if (isMoving || inputLocked) return; // ⛔ swipe diblok saat sound panel aktif
const t = e.changedTouches[0];
const dx = t.clientX - touchStartX;
const dy = t.clientY - touchStartY;
let moved = false;
if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > 30) {

View File

@ -120,20 +120,22 @@ function setupVolumePanelEvents() {
if (isActive) {
volumePanel.classList.remove('active');
if (volumeBackdrop) volumeBackdrop.classList.remove('active');
if (volumeBackdrop) volumeBackdrop.classList.remove('active');
inputLocked = false; // 🔓 buka panel -> input kembali
} else {
volumePanel.classList.add('active');
if (volumeBackdrop) volumeBackdrop.classList.add('active');
inputLocked = true; // 🔒 panel sound aktif -> swipe & keyboard mati
}
});
// Close when clicking backdrop
if (volumeBackdrop) {
volumeBackdrop.addEventListener('click', () => {
volumePanel.classList.remove('active');
volumeBackdrop.classList.remove('active');
volumeBackdrop.addEventListener('click', () => {
volumePanel.classList.remove('active');
volumeBackdrop.classList.remove('active');
inputLocked = false; // 🔓 unlock
});
}
// Close when clicking outside (desktop)
document.addEventListener('click', (e) => {
@ -142,6 +144,7 @@ function setupVolumePanelEvents() {
(!volumeBackdrop || !volumeBackdrop.contains(e.target))) {
volumePanel.classList.remove('active');
if (volumeBackdrop) volumeBackdrop.classList.remove('active');
inputLocked = false; // 🔓 unlock input
}
});