2048
This commit is contained in:
parent
7676a07935
commit
35a97679c3
@ -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 />
|
||||
|
||||
@ -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,14 +40,18 @@ 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;
|
||||
|
||||
@ -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
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user