fix: 2048 modal bug

This commit is contained in:
2026-10-07 13:31:33 +02:00
parent 1dc342d5c1
commit 06b96fe5ba

View File

@@ -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":