fix(settings): synchronize button animation with arrows of number input
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { SettingsBottomScreenNumberInput as NumberInput } from "#components";
|
||||
import gsap from "gsap";
|
||||
|
||||
const store = useSettingsStore();
|
||||
const confirmationModal = useConfirmationModal();
|
||||
@@ -10,6 +11,9 @@ const BIRTHDAY_YEAR = 2002;
|
||||
|
||||
const isAnimating = ref(true);
|
||||
|
||||
const bLabel = ref($t("common.goBack"));
|
||||
const aLabel = ref($t("common.select"));
|
||||
|
||||
const monthRef = useTemplateRef<InstanceType<typeof NumberInput>>("month");
|
||||
const dayRef = useTemplateRef<InstanceType<typeof NumberInput>>("day");
|
||||
const yearRef = useTemplateRef<InstanceType<typeof NumberInput>>("year");
|
||||
@@ -20,6 +24,14 @@ const animateIntro = async () => {
|
||||
monthRef.value?.animateIntro(),
|
||||
dayRef.value?.animateIntro(),
|
||||
yearRef.value?.animateIntro(),
|
||||
gsap.timeline().call(
|
||||
() => {
|
||||
bLabel.value = $t("common.cancel");
|
||||
aLabel.value = $t("common.confirm");
|
||||
},
|
||||
[],
|
||||
SUBMENU_LABEL_CHANGE_DELAY,
|
||||
),
|
||||
]);
|
||||
isAnimating.value = false;
|
||||
};
|
||||
@@ -113,8 +125,8 @@ defineOptions({ render: () => null });
|
||||
|
||||
<CommonButtons
|
||||
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.cancel')"
|
||||
:a-label="$t('common.confirm')"
|
||||
:b-label="bLabel"
|
||||
:a-label="aLabel"
|
||||
@activate-b="handleActivateB"
|
||||
@activate-a="handleActivateA"
|
||||
/>
|
||||
|
||||
@@ -23,6 +23,9 @@ const CELL_ANIMATION_STAGGER = 0.02;
|
||||
|
||||
const SNAIL_ORDER = [0, 1, 2, 3, 7, 11, 15, 14, 13, 12, 8, 4, 5, 6, 10, 9];
|
||||
|
||||
const bLabel = ref($t("common.goBack"));
|
||||
const aLabel = ref($t("common.select"));
|
||||
|
||||
// animation state
|
||||
const animation = reactive({
|
||||
cellVisibility: Array(16).fill(0) as number[],
|
||||
@@ -74,6 +77,15 @@ const animateIntro = (): gsap.core.Timeline => {
|
||||
);
|
||||
}
|
||||
|
||||
timeline.call(
|
||||
() => {
|
||||
bLabel.value = $t("common.cancel");
|
||||
aLabel.value = $t("common.confirm");
|
||||
},
|
||||
[],
|
||||
SUBMENU_LABEL_CHANGE_DELAY,
|
||||
);
|
||||
|
||||
return timeline;
|
||||
};
|
||||
|
||||
@@ -287,8 +299,8 @@ const handleActivateA = () => {
|
||||
<template>
|
||||
<CommonButtons
|
||||
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.cancel')"
|
||||
:a-label="$t('common.confirm')"
|
||||
:b-label="bLabel"
|
||||
:a-label="aLabel"
|
||||
@activate-b="handleActivateB"
|
||||
@activate-a="handleActivateA"
|
||||
/>
|
||||
|
||||
@@ -20,6 +20,16 @@ const SCORE_OFFSET = -20;
|
||||
const SCORE_DURATION = 0.167;
|
||||
|
||||
const isAnimating = ref(true);
|
||||
const state = ref<"waiting" | "alive" | "pause" | "dead">("waiting");
|
||||
|
||||
const labelsReady = ref(false);
|
||||
const bLabel = computed(() =>
|
||||
labelsReady.value ? $t("common.quit") : $t("common.goBack"),
|
||||
);
|
||||
const aLabel = computed(() => {
|
||||
if (!labelsReady.value) return $t("common.select");
|
||||
return state.value === "waiting" ? $t("common.start") : $t("common.restart");
|
||||
});
|
||||
|
||||
const intro = reactive({
|
||||
boardOffsetY: BOARD_SLIDE_OFFSET,
|
||||
@@ -31,7 +41,11 @@ const intro = reactive({
|
||||
const animateIntro = async () => {
|
||||
isAnimating.value = true;
|
||||
await gsap
|
||||
.timeline()
|
||||
.timeline({
|
||||
onComplete: () => {
|
||||
isAnimating.value = false;
|
||||
},
|
||||
})
|
||||
.to(
|
||||
intro,
|
||||
{ boardOffsetY: 0, duration: BOARD_SLIDE_DURATION, ease: "none" },
|
||||
@@ -51,14 +65,24 @@ const animateIntro = async () => {
|
||||
intro,
|
||||
{ scoreOffsetY: 0, duration: SCORE_DURATION, ease: "none" },
|
||||
BOARD_SLIDE_DURATION + TEXT_FADE_DURATION,
|
||||
)
|
||||
.call(
|
||||
() => {
|
||||
labelsReady.value = true;
|
||||
},
|
||||
[],
|
||||
SUBMENU_LABEL_CHANGE_DELAY,
|
||||
);
|
||||
isAnimating.value = false;
|
||||
};
|
||||
|
||||
const animateOutro = async () => {
|
||||
isAnimating.value = true;
|
||||
await gsap
|
||||
.timeline()
|
||||
.timeline({
|
||||
onComplete: () => {
|
||||
isAnimating.value = false;
|
||||
},
|
||||
})
|
||||
.to(
|
||||
intro,
|
||||
{
|
||||
@@ -160,7 +184,6 @@ const tail: THREE.Vector2[] = [];
|
||||
const food = new THREE.Vector2();
|
||||
|
||||
let score = 0;
|
||||
const state = ref<"waiting" | "alive" | "pause" | "dead">("waiting");
|
||||
|
||||
const randomFoodPos = (): THREE.Vector2 => {
|
||||
// can't spawn on the head or tail
|
||||
@@ -337,8 +360,8 @@ defineOptions({ render: () => null });
|
||||
<template>
|
||||
<CommonButtons
|
||||
:y-offset="confirmationModal.buttonsYOffset + store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.quit')"
|
||||
:a-label="state === 'waiting' ? $t('common.start') : $t('common.restart')"
|
||||
:b-label="bLabel"
|
||||
:a-label="aLabel"
|
||||
@activate-b="handleActivateB"
|
||||
@activate-a="handleActivateA"
|
||||
/>
|
||||
|
||||
@@ -19,6 +19,9 @@ const ROW_COUNT = 2;
|
||||
|
||||
const isAnimating = ref(true);
|
||||
|
||||
const bLabel = ref($t("common.goBack"));
|
||||
const aLabel = ref($t("common.select"));
|
||||
|
||||
const animation = reactive({
|
||||
rowOffsetY: new Array<number>(ROW_COUNT).fill(SLIDE_OFFSET),
|
||||
rowOpacity: new Array<number>(ROW_COUNT).fill(0),
|
||||
@@ -26,7 +29,11 @@ const animation = reactive({
|
||||
|
||||
const animateIntro = async () => {
|
||||
isAnimating.value = true;
|
||||
const timeline = gsap.timeline();
|
||||
const timeline = gsap.timeline({
|
||||
onComplete: () => {
|
||||
isAnimating.value = false;
|
||||
},
|
||||
});
|
||||
for (let i = 0; i < ROW_COUNT; i++) {
|
||||
timeline
|
||||
.to(
|
||||
@@ -40,13 +47,24 @@ const animateIntro = async () => {
|
||||
i * ROW_STAGGER,
|
||||
);
|
||||
}
|
||||
timeline.call(
|
||||
() => {
|
||||
bLabel.value = $t("common.cancel");
|
||||
aLabel.value = $t("common.confirm");
|
||||
},
|
||||
[],
|
||||
SUBMENU_LABEL_CHANGE_DELAY,
|
||||
);
|
||||
await timeline;
|
||||
isAnimating.value = false;
|
||||
};
|
||||
|
||||
const animateOutro = async () => {
|
||||
isAnimating.value = true;
|
||||
const timeline = gsap.timeline();
|
||||
const timeline = gsap.timeline({
|
||||
onComplete: () => {
|
||||
isAnimating.value = false;
|
||||
},
|
||||
});
|
||||
for (let i = 0; i < ROW_COUNT; i++) {
|
||||
timeline
|
||||
.to(
|
||||
@@ -128,8 +146,8 @@ defineOptions({ render: () => null });
|
||||
<template>
|
||||
<CommonButtons
|
||||
:y-offset="store.submenuButtonsOffsetY"
|
||||
:b-label="$t('common.cancel')"
|
||||
:a-label="$t('common.confirm')"
|
||||
:b-label="bLabel"
|
||||
:a-label="aLabel"
|
||||
@activate-b="handleActivateB"
|
||||
@activate-a="handleActivateA"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user