feat(settings): animate buttons
This commit is contained in:
@@ -192,7 +192,7 @@ onRender((ctx) => {
|
||||
/>
|
||||
|
||||
<CommonButtons
|
||||
:y-offset="confirmationModal.buttonsYOffset"
|
||||
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.cancel')"
|
||||
:a-label="$t('common.reset')"
|
||||
@activate-b="handleCancel()"
|
||||
|
||||
@@ -79,7 +79,7 @@ defineOptions({ render: () => null });
|
||||
/>
|
||||
|
||||
<CommonButtons
|
||||
:y-offset="0"
|
||||
:y-offset="store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.cancel')"
|
||||
:a-label="$t('common.confirm')"
|
||||
@activate-b="handleCancel"
|
||||
|
||||
@@ -97,7 +97,7 @@ defineOptions({ render: () => null });
|
||||
/>
|
||||
|
||||
<CommonButtons
|
||||
:y-offset="0"
|
||||
:y-offset="store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.cancel')"
|
||||
:a-label="$t('common.confirm')"
|
||||
@activate-b="handleCancel"
|
||||
|
||||
@@ -331,7 +331,7 @@ const handleActivateB = () => {
|
||||
/>
|
||||
|
||||
<CommonButtons
|
||||
:y-offset="settingsStore.barOffsetY"
|
||||
:y-offset="settingsStore.barOffsetY + settingsStore.submenuButtonsOffsetY"
|
||||
:b-label="isSubmenuSelected ? $t('common.goBack') : $t('common.quit')"
|
||||
:a-label="$t('common.select')"
|
||||
@activate-b="handleActivateB()"
|
||||
|
||||
@@ -19,6 +19,7 @@ const handleActivateB = () => {
|
||||
store.closeSubMenu();
|
||||
}
|
||||
},
|
||||
keepButtonsDown: (choice) => choice === "confirm",
|
||||
});
|
||||
};
|
||||
|
||||
@@ -565,7 +566,7 @@ useKeyDown((key) => {
|
||||
|
||||
<template>
|
||||
<CommonButtons
|
||||
:y-offset="confirmationModal.buttonsYOffset"
|
||||
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.quit')"
|
||||
:a-label="$t('common.restart')"
|
||||
@activate-b="handleActivateB()"
|
||||
|
||||
@@ -164,6 +164,7 @@ const handleConfirm = () => {
|
||||
await animateOutro();
|
||||
store.closeSubMenu();
|
||||
},
|
||||
keepButtonsDown: true,
|
||||
timeout: 2000,
|
||||
});
|
||||
};
|
||||
@@ -202,7 +203,7 @@ defineOptions({
|
||||
|
||||
<template>
|
||||
<CommonButtons
|
||||
:y-offset="confirmationModal.buttonsYOffset"
|
||||
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.cancel')"
|
||||
:a-label="$t('common.confirm')"
|
||||
@activate-b="handleCancel"
|
||||
|
||||
@@ -110,6 +110,7 @@ const handleConfirm = () => {
|
||||
await animateOutro();
|
||||
store.closeSubMenu();
|
||||
},
|
||||
keepButtonsDown: true,
|
||||
timeout: 2000,
|
||||
});
|
||||
};
|
||||
@@ -179,7 +180,7 @@ onRender((ctx) => {
|
||||
|
||||
<template>
|
||||
<CommonButtons
|
||||
:y-offset="confirmationModal.buttonsYOffset"
|
||||
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.cancel')"
|
||||
:a-label="$t('common.confirm')"
|
||||
@activate-b="handleCancel"
|
||||
|
||||
@@ -138,6 +138,7 @@ const handleActivateB = () => {
|
||||
state.value = "playing";
|
||||
}
|
||||
},
|
||||
keepButtonsDown: (choice) => choice === "confirm",
|
||||
});
|
||||
} else {
|
||||
animateOutro().then(() => store.closeSubMenu());
|
||||
@@ -238,6 +239,7 @@ const showDeathScreen = () => {
|
||||
store.closeSubMenu();
|
||||
}
|
||||
},
|
||||
keepButtonsDown: (choice) => choice === "cancel",
|
||||
});
|
||||
};
|
||||
|
||||
@@ -412,7 +414,7 @@ defineOptions({ render: () => null });
|
||||
|
||||
<template>
|
||||
<CommonButtons
|
||||
:y-offset="confirmationModal.buttonsYOffset"
|
||||
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.quit')"
|
||||
:a-label="state === 'waiting' ? $t('common.start') : $t('common.restart')"
|
||||
@activate-b="handleActivateB"
|
||||
|
||||
@@ -78,6 +78,7 @@ const handleActivateA = () => {
|
||||
await animateOutro();
|
||||
store.closeSubMenu();
|
||||
},
|
||||
keepButtonsDown: true,
|
||||
timeout: 2000,
|
||||
});
|
||||
};
|
||||
@@ -111,7 +112,7 @@ defineOptions({ render: () => null });
|
||||
/>
|
||||
|
||||
<CommonButtons
|
||||
:y-offset="confirmationModal.buttonsYOffset"
|
||||
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.cancel')"
|
||||
:a-label="$t('common.confirm')"
|
||||
@activate-b="handleActivateB"
|
||||
|
||||
@@ -278,6 +278,7 @@ const handleActivateA = () => {
|
||||
await animateOutro();
|
||||
store.closeSubMenu();
|
||||
},
|
||||
keepButtonsDown: true,
|
||||
timeout: 2000,
|
||||
});
|
||||
};
|
||||
@@ -285,7 +286,7 @@ const handleActivateA = () => {
|
||||
|
||||
<template>
|
||||
<CommonButtons
|
||||
:y-offset="confirmationModal.buttonsYOffset"
|
||||
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.cancel')"
|
||||
:a-label="$t('common.confirm')"
|
||||
@activate-b="handleActivateB"
|
||||
|
||||
@@ -101,6 +101,7 @@ const handleCancel = async () => {
|
||||
onCancel: () => {
|
||||
state.value = "alive";
|
||||
},
|
||||
keepButtonsDown: (choice) => choice === "confirm",
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -327,7 +328,7 @@ defineOptions({ render: () => null });
|
||||
|
||||
<template>
|
||||
<CommonButtons
|
||||
:y-offset="confirmationModal.buttonsYOffset"
|
||||
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.quit')"
|
||||
:a-label="state === 'waiting' ? $t('common.start') : $t('common.restart')"
|
||||
@activate-b="handleCancel"
|
||||
|
||||
@@ -127,7 +127,7 @@ defineOptions({ render: () => null });
|
||||
|
||||
<template>
|
||||
<CommonButtons
|
||||
:y-offset="0"
|
||||
:y-offset="store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.cancel')"
|
||||
:a-label="$t('common.confirm')"
|
||||
@activate-b="handleCancel"
|
||||
|
||||
@@ -14,6 +14,10 @@ export const useConfirmationModal = defineStore("confirmationModal", {
|
||||
onConfirm: null as (() => void) | null,
|
||||
onCancel: null as (() => void) | null,
|
||||
onClosed: null as ((choice: "confirm" | "cancel") => void) | null,
|
||||
keepButtonsDown: null as
|
||||
| boolean
|
||||
| ((choice: "confirm" | "cancel") => boolean)
|
||||
| null,
|
||||
offsetY: MODAL_MAX_Y_OFFSET,
|
||||
buttonsYOffset: 0,
|
||||
modalButtonsYOffset: BUTTONS_MAX_Y_OFFSET,
|
||||
@@ -29,6 +33,7 @@ export const useConfirmationModal = defineStore("confirmationModal", {
|
||||
onCancel?: () => void;
|
||||
onConfirm?: () => void;
|
||||
onClosed?: (choice: "confirm" | "cancel") => void;
|
||||
keepButtonsDown?: boolean | ((choice: "confirm" | "cancel") => boolean);
|
||||
timeout?: number;
|
||||
}) {
|
||||
gsap.killTweensOf(this);
|
||||
@@ -38,6 +43,7 @@ export const useConfirmationModal = defineStore("confirmationModal", {
|
||||
this.onConfirm = options.onConfirm ?? null;
|
||||
this.onCancel = options.onCancel ?? null;
|
||||
this.onClosed = options.onClosed ?? null;
|
||||
this.keepButtonsDown = options.keepButtonsDown ?? null;
|
||||
this.isVisible = true;
|
||||
this.isClosing = false;
|
||||
this.isOpen = true;
|
||||
@@ -80,7 +86,12 @@ export const useConfirmationModal = defineStore("confirmationModal", {
|
||||
|
||||
this.isClosing = true;
|
||||
|
||||
gsap
|
||||
const keepButtonsDown =
|
||||
typeof this.keepButtonsDown === "function"
|
||||
? this.keepButtonsDown(choice)
|
||||
: !!this.keepButtonsDown;
|
||||
|
||||
const tl = gsap
|
||||
.timeline()
|
||||
// modal buttons down
|
||||
.to(this, {
|
||||
@@ -93,16 +104,23 @@ export const useConfirmationModal = defineStore("confirmationModal", {
|
||||
offsetY: MODAL_MAX_Y_OFFSET,
|
||||
duration: MODAL_TIME,
|
||||
ease: "none",
|
||||
})
|
||||
});
|
||||
|
||||
if (!keepButtonsDown) {
|
||||
// standard buttons up
|
||||
.to(this, {
|
||||
tl.to(this, {
|
||||
buttonsYOffset: 0,
|
||||
duration: BUTTONS_TIME,
|
||||
ease: "none",
|
||||
})
|
||||
.call(() => {
|
||||
});
|
||||
}
|
||||
|
||||
tl.call(() => {
|
||||
const closedCallback = this.onClosed;
|
||||
this.$reset();
|
||||
if (keepButtonsDown) {
|
||||
this.buttonsYOffset = BUTTONS_MAX_Y_OFFSET;
|
||||
}
|
||||
closedCallback?.(choice);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -49,6 +49,8 @@ export const useSettingsStore = defineStore("settings", {
|
||||
opacity: 0,
|
||||
},
|
||||
|
||||
submenuButtonsOffsetY: 0,
|
||||
|
||||
animatingNotification: false,
|
||||
|
||||
isIntro: true,
|
||||
@@ -77,9 +79,24 @@ export const useSettingsStore = defineStore("settings", {
|
||||
{ offsetY: 16, opacity: 0 },
|
||||
{ offsetY: 0, opacity: 1, duration: 0.25, ease: "none" },
|
||||
"+=0.05",
|
||||
);
|
||||
|
||||
)
|
||||
.to(this, {
|
||||
submenuButtonsOffsetY: 24,
|
||||
duration: 0.167,
|
||||
ease: "none",
|
||||
})
|
||||
.call(() => {
|
||||
this.currentSubMenu = submenu;
|
||||
})
|
||||
.to(
|
||||
this,
|
||||
{
|
||||
submenuButtonsOffsetY: 0,
|
||||
duration: 0.167,
|
||||
ease: "none",
|
||||
},
|
||||
"+=0.05",
|
||||
);
|
||||
|
||||
const achievements = useAchievementsStore();
|
||||
if (!achievements.advancement.visitedSettings.includes(submenu)) {
|
||||
@@ -94,14 +111,33 @@ export const useSettingsStore = defineStore("settings", {
|
||||
},
|
||||
|
||||
async closeSubMenu() {
|
||||
this.currentSubMenu = null;
|
||||
const confirmationModal = useConfirmationModal();
|
||||
confirmationModal.buttonsYOffset = 0;
|
||||
|
||||
await gsap
|
||||
.timeline()
|
||||
.to(this, {
|
||||
submenuButtonsOffsetY: 24,
|
||||
duration: 0.167,
|
||||
ease: "none",
|
||||
})
|
||||
.call(() => {
|
||||
this.currentSubMenu = null;
|
||||
})
|
||||
.fromTo(
|
||||
this.submenuBackground,
|
||||
{ offsetY: 0, opacity: 1 },
|
||||
{ offsetY: 16, opacity: 0, duration: 0.25, ease: "none" },
|
||||
0.167,
|
||||
)
|
||||
.to(
|
||||
this,
|
||||
{
|
||||
submenuButtonsOffsetY: 0,
|
||||
duration: 0.167,
|
||||
ease: "none",
|
||||
},
|
||||
0.217,
|
||||
)
|
||||
.fromTo(
|
||||
this.submenuTransition,
|
||||
|
||||
Reference in New Issue
Block a user