From 06b96fe5ba60a378ce0b585bec28f01f10f11739 Mon Sep 17 00:00:00 2001 From: Pihkaal Date: Wed, 7 Oct 2026 13:31:33 +0200 Subject: [PATCH] fix: 2048 modal bug --- .../Settings/BottomScreen/Menus/Options/2048.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/components/Settings/BottomScreen/Menus/Options/2048.vue b/app/components/Settings/BottomScreen/Menus/Options/2048.vue index 2899cb6..f7787a3 100644 --- a/app/components/Settings/BottomScreen/Menus/Options/2048.vue +++ b/app/components/Settings/BottomScreen/Menus/Options/2048.vue @@ -141,7 +141,7 @@ const cellX = (col: number) => BORDER_SIZE + col * (TILE_SIZE + BORDER_SIZE); const cellY = (row: number) => BORDER_SIZE + row * (TILE_SIZE + BORDER_SIZE); let tiles: VisualTile[] = []; -let animating = false; +let moveTimeline: gsap.core.Timeline | null = null; const showRestartModal = () => { confirmationModal.open({ @@ -415,14 +415,14 @@ if (board.every((r) => r.every((c) => c === 0))) { } const slide = (rowDir: number, colDir: number) => { - if (isDead() && !confirmationModal.isOpen) { + if (isDead()) { showRestartModal(); return; } - if (animating) { - gsap.globalTimeline.clear(); - animating = false; + if (moveTimeline) { + moveTimeline.kill(); + moveTimeline = null; buildTilesFromBoard(); } @@ -553,14 +553,14 @@ const slide = (rowDir: number, colDir: number) => { } tiles = animTiles; - animating = true; const tl = gsap.timeline({ onComplete: () => { - animating = false; + moveTimeline = null; buildTilesFromBoard(); }, }); + moveTimeline = tl; for (const { tile, toX, toY } of tweens) { tl.to(tile, { x: toX, y: toY, duration: ANIM_DURATION, ease: "none" }, 0); @@ -601,7 +601,7 @@ const slide = (rowDir: number, colDir: number) => { }; useKeyDown(({ key }) => { - if (isAnimating.value) return; + if (isAnimating.value || confirmationModal.isOpen) return; switch (key) { case "NDS_UP": case "NDS_SWIPE_UP":