feat(settings): block interactions while animation is happening

This commit is contained in:
2026-02-08 20:19:40 +01:00
parent 4de10dd309
commit cfaf8c8d29
11 changed files with 83 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ const { assets } = useAssets();
const { onRender } = useScreen();
const handleActivateB = () => {
if (isAnimating.value) return;
confirmationModal.open({
text: $t("settings.options.2048.quitConfirmation"),
onConfirm: () => {},
@@ -22,6 +23,7 @@ const handleActivateB = () => {
};
const handleActivateA = () => {
if (isAnimating.value) return;
if (isDead()) {
resetBoard();
return;
@@ -70,6 +72,8 @@ const SLIDE_DURATION = 0.25;
const SCORE_OFFSET = -20;
const SCORE_DURATION = 0.15;
const isAnimating = ref(true);
const intro = reactive({
frameOffsetY: SLIDE_OFFSET,
frameOpacity: 0,
@@ -137,6 +141,7 @@ const animateSpawnAll = () => {
};
const animateIntro = async () => {
isAnimating.value = true;
buildTilesFromBoard();
await gsap
@@ -156,9 +161,11 @@ const animateIntro = async () => {
{ scoreOffsetY: 0, duration: SCORE_DURATION, ease: "none" },
SLIDE_DURATION,
);
isAnimating.value = false;
};
const animateOutro = async () => {
isAnimating.value = true;
await gsap
.timeline()
.to(
@@ -530,6 +537,7 @@ const slide = (rowDir: number, colDir: number) => {
};
useKeyDown((key) => {
if (isAnimating.value) return;
switch (key) {
// TODO: remove this, testing only
case "n":