feat(settings): block interactions while animation is happening
This commit is contained in:
@@ -33,6 +33,8 @@ const achievements = useAchievementsStore();
|
|||||||
const achievementsScreen = useAchievementsScreen();
|
const achievementsScreen = useAchievementsScreen();
|
||||||
const confirmationModal = useConfirmationModal();
|
const confirmationModal = useConfirmationModal();
|
||||||
|
|
||||||
|
const isAnimating = ref(true);
|
||||||
|
|
||||||
const SLIDE_OFFSET = 96;
|
const SLIDE_OFFSET = 96;
|
||||||
const SLIDE_DURATION = 0.25;
|
const SLIDE_DURATION = 0.25;
|
||||||
const ARROW_SLIDE_DELAY = 0.15;
|
const ARROW_SLIDE_DELAY = 0.15;
|
||||||
@@ -50,6 +52,7 @@ const obtainedRef =
|
|||||||
const totalRef = useTemplateRef<InstanceType<typeof NumberInput>>("total");
|
const totalRef = useTemplateRef<InstanceType<typeof NumberInput>>("total");
|
||||||
|
|
||||||
const animateIntro = async () => {
|
const animateIntro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
obtainedRef.value?.animateIntro(),
|
obtainedRef.value?.animateIntro(),
|
||||||
totalRef.value?.animateIntro(),
|
totalRef.value?.animateIntro(),
|
||||||
@@ -63,9 +66,11 @@ const animateIntro = async () => {
|
|||||||
SLIDE_DURATION + ARROW_SLIDE_DELAY,
|
SLIDE_DURATION + ARROW_SLIDE_DELAY,
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
isAnimating.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const animateOutro = async () => {
|
const animateOutro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
obtainedRef.value?.animateOutro(),
|
obtainedRef.value?.animateOutro(),
|
||||||
totalRef.value?.animateOutro(),
|
totalRef.value?.animateOutro(),
|
||||||
@@ -94,11 +99,13 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleCancel = async () => {
|
const handleCancel = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
await animateOutro();
|
await animateOutro();
|
||||||
store.closeSubMenu();
|
store.closeSubMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleReset = () => {
|
const handleReset = () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
confirmationModal.open({
|
confirmationModal.open({
|
||||||
text: $t("settings.clock.achievements.resetConfirmation"),
|
text: $t("settings.clock.achievements.resetConfirmation"),
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
@@ -108,10 +115,12 @@ const handleReset = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleVisitAll = () => {
|
const handleVisitAll = () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
achievementsScreen.animateFadeToBlackIntro();
|
achievementsScreen.animateFadeToBlackIntro();
|
||||||
};
|
};
|
||||||
|
|
||||||
onClick((x, y) => {
|
onClick((x, y) => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
const viewAllRect = achievementAssets.viewAllButton.rect;
|
const viewAllRect = achievementAssets.viewAllButton.rect;
|
||||||
if (rectContains([127, 2, viewAllRect.width, viewAllRect.height], [x, y])) {
|
if (rectContains([127, 2, viewAllRect.width, viewAllRect.height], [x, y])) {
|
||||||
handleVisitAll();
|
handleVisitAll();
|
||||||
@@ -119,6 +128,7 @@ onClick((x, y) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useKeyDown((key) => {
|
useKeyDown((key) => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
if (key === "NDS_X") {
|
if (key === "NDS_X") {
|
||||||
handleVisitAll();
|
handleVisitAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,19 +12,24 @@ useIntervalFn(() => {
|
|||||||
now.value = new Date();
|
now.value = new Date();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
const isAnimating = ref(true);
|
||||||
|
|
||||||
const monthRef = useTemplateRef<InstanceType<typeof NumberInput>>("month");
|
const monthRef = useTemplateRef<InstanceType<typeof NumberInput>>("month");
|
||||||
const dayRef = useTemplateRef<InstanceType<typeof NumberInput>>("day");
|
const dayRef = useTemplateRef<InstanceType<typeof NumberInput>>("day");
|
||||||
const yearRef = useTemplateRef<InstanceType<typeof NumberInput>>("year");
|
const yearRef = useTemplateRef<InstanceType<typeof NumberInput>>("year");
|
||||||
|
|
||||||
const animateIntro = async () => {
|
const animateIntro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
monthRef.value?.animateIntro(),
|
monthRef.value?.animateIntro(),
|
||||||
dayRef.value?.animateIntro(),
|
dayRef.value?.animateIntro(),
|
||||||
yearRef.value?.animateIntro(),
|
yearRef.value?.animateIntro(),
|
||||||
]);
|
]);
|
||||||
|
isAnimating.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const animateOutro = async () => {
|
const animateOutro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
monthRef.value?.animateOutro(),
|
monthRef.value?.animateOutro(),
|
||||||
dayRef.value?.animateOutro(),
|
dayRef.value?.animateOutro(),
|
||||||
@@ -37,11 +42,13 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleCancel = async () => {
|
const handleCancel = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
await animateOutro();
|
await animateOutro();
|
||||||
store.closeSubMenu();
|
store.closeSubMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
await animateOutro();
|
await animateOutro();
|
||||||
store.closeSubMenu();
|
store.closeSubMenu();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,10 +21,13 @@ const animation = reactive({
|
|||||||
opacity: 0,
|
opacity: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isAnimating = ref(true);
|
||||||
|
|
||||||
const hourRef = useTemplateRef<InstanceType<typeof NumberInput>>("hour");
|
const hourRef = useTemplateRef<InstanceType<typeof NumberInput>>("hour");
|
||||||
const minuteRef = useTemplateRef<InstanceType<typeof NumberInput>>("minute");
|
const minuteRef = useTemplateRef<InstanceType<typeof NumberInput>>("minute");
|
||||||
|
|
||||||
const animateIntro = async () => {
|
const animateIntro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
hourRef.value?.animateIntro(),
|
hourRef.value?.animateIntro(),
|
||||||
minuteRef.value?.animateIntro(),
|
minuteRef.value?.animateIntro(),
|
||||||
@@ -33,9 +36,11 @@ const animateIntro = async () => {
|
|||||||
.to(animation, { offsetY: 0, duration: SLIDE_DURATION, ease: "none" }, 0)
|
.to(animation, { offsetY: 0, duration: SLIDE_DURATION, ease: "none" }, 0)
|
||||||
.to(animation, { opacity: 1, duration: SLIDE_DURATION, ease: "none" }, 0),
|
.to(animation, { opacity: 1, duration: SLIDE_DURATION, ease: "none" }, 0),
|
||||||
]);
|
]);
|
||||||
|
isAnimating.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const animateOutro = async () => {
|
const animateOutro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
hourRef.value?.animateOutro(),
|
hourRef.value?.animateOutro(),
|
||||||
minuteRef.value?.animateOutro(),
|
minuteRef.value?.animateOutro(),
|
||||||
@@ -55,11 +60,13 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleCancel = async () => {
|
const handleCancel = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
await animateOutro();
|
await animateOutro();
|
||||||
store.closeSubMenu();
|
store.closeSubMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
await animateOutro();
|
await animateOutro();
|
||||||
store.closeSubMenu();
|
store.closeSubMenu();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const { assets } = useAssets();
|
|||||||
const { onRender } = useScreen();
|
const { onRender } = useScreen();
|
||||||
|
|
||||||
const handleActivateB = () => {
|
const handleActivateB = () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
confirmationModal.open({
|
confirmationModal.open({
|
||||||
text: $t("settings.options.2048.quitConfirmation"),
|
text: $t("settings.options.2048.quitConfirmation"),
|
||||||
onConfirm: () => {},
|
onConfirm: () => {},
|
||||||
@@ -22,6 +23,7 @@ const handleActivateB = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleActivateA = () => {
|
const handleActivateA = () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
if (isDead()) {
|
if (isDead()) {
|
||||||
resetBoard();
|
resetBoard();
|
||||||
return;
|
return;
|
||||||
@@ -70,6 +72,8 @@ const SLIDE_DURATION = 0.25;
|
|||||||
const SCORE_OFFSET = -20;
|
const SCORE_OFFSET = -20;
|
||||||
const SCORE_DURATION = 0.15;
|
const SCORE_DURATION = 0.15;
|
||||||
|
|
||||||
|
const isAnimating = ref(true);
|
||||||
|
|
||||||
const intro = reactive({
|
const intro = reactive({
|
||||||
frameOffsetY: SLIDE_OFFSET,
|
frameOffsetY: SLIDE_OFFSET,
|
||||||
frameOpacity: 0,
|
frameOpacity: 0,
|
||||||
@@ -137,6 +141,7 @@ const animateSpawnAll = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const animateIntro = async () => {
|
const animateIntro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
buildTilesFromBoard();
|
buildTilesFromBoard();
|
||||||
|
|
||||||
await gsap
|
await gsap
|
||||||
@@ -156,9 +161,11 @@ const animateIntro = async () => {
|
|||||||
{ scoreOffsetY: 0, duration: SCORE_DURATION, ease: "none" },
|
{ scoreOffsetY: 0, duration: SCORE_DURATION, ease: "none" },
|
||||||
SLIDE_DURATION,
|
SLIDE_DURATION,
|
||||||
);
|
);
|
||||||
|
isAnimating.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const animateOutro = async () => {
|
const animateOutro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await gsap
|
await gsap
|
||||||
.timeline()
|
.timeline()
|
||||||
.to(
|
.to(
|
||||||
@@ -530,6 +537,7 @@ const slide = (rowDir: number, colDir: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useKeyDown((key) => {
|
useKeyDown((key) => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
// TODO: remove this, testing only
|
// TODO: remove this, testing only
|
||||||
case "n":
|
case "n":
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ const BUTTON_POSITIONS = [
|
|||||||
[143, 128],
|
[143, 128],
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
const isAnimating = ref(true);
|
||||||
|
|
||||||
const { selected, selectorPosition } = useButtonNavigation({
|
const { selected, selectorPosition } = useButtonNavigation({
|
||||||
buttons: {
|
buttons: {
|
||||||
english: [10, 27, 106, 41],
|
english: [10, 27, 106, 41],
|
||||||
@@ -66,6 +68,7 @@ const { selected, selectorPosition } = useButtonNavigation({
|
|||||||
left: "italian",
|
left: "italian",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
disabled: isAnimating,
|
||||||
selectorAnimation: {
|
selectorAnimation: {
|
||||||
duration: 0.1,
|
duration: 0.1,
|
||||||
ease: "power2.out",
|
ease: "power2.out",
|
||||||
@@ -90,6 +93,7 @@ const animation = reactive({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const animateIntro = async () => {
|
const animateIntro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
const timeline = gsap.timeline();
|
const timeline = gsap.timeline();
|
||||||
for (let i = 0; i < ROW_COUNT; i++) {
|
for (let i = 0; i < ROW_COUNT; i++) {
|
||||||
timeline
|
timeline
|
||||||
@@ -105,9 +109,11 @@ const animateIntro = async () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
await timeline;
|
await timeline;
|
||||||
|
isAnimating.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const animateOutro = async () => {
|
const animateOutro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
const timeline = gsap.timeline();
|
const timeline = gsap.timeline();
|
||||||
for (let i = 0; i < ROW_COUNT; i++) {
|
for (let i = 0; i < ROW_COUNT; i++) {
|
||||||
timeline
|
timeline
|
||||||
@@ -130,11 +136,13 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleCancel = async () => {
|
const handleCancel = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
await animateOutro();
|
await animateOutro();
|
||||||
store.closeSubMenu();
|
store.closeSubMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
const selectedLocale = locales.value[BUTTON_KEYS.indexOf(selected.value)]!;
|
const selectedLocale = locales.value[BUTTON_KEYS.indexOf(selected.value)]!;
|
||||||
|
|
||||||
setLocale(selectedLocale.code);
|
setLocale(selectedLocale.code);
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ const BUTTON_STAGGER = 0.3;
|
|||||||
const SLIDE_OFFSET = 96;
|
const SLIDE_OFFSET = 96;
|
||||||
const SLIDE_DURATION = 0.25;
|
const SLIDE_DURATION = 0.25;
|
||||||
|
|
||||||
|
const isAnimating = ref(true);
|
||||||
|
|
||||||
const animation = reactive({
|
const animation = reactive({
|
||||||
_3dMode: { headerOffsetY: HEADER_HEIGHT * 3, opacity: 0 },
|
_3dMode: { headerOffsetY: HEADER_HEIGHT * 3, opacity: 0 },
|
||||||
_2dMode: { headerOffsetY: HEADER_HEIGHT * 3, opacity: 0 },
|
_2dMode: { headerOffsetY: HEADER_HEIGHT * 3, opacity: 0 },
|
||||||
@@ -24,6 +26,7 @@ const animation = reactive({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const animateIntro = async () => {
|
const animateIntro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await gsap
|
await gsap
|
||||||
.timeline()
|
.timeline()
|
||||||
.to(
|
.to(
|
||||||
@@ -46,9 +49,11 @@ const animateIntro = async () => {
|
|||||||
},
|
},
|
||||||
BUTTON_STAGGER,
|
BUTTON_STAGGER,
|
||||||
);
|
);
|
||||||
|
isAnimating.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const animateOutro = async () => {
|
const animateOutro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await gsap
|
await gsap
|
||||||
.timeline()
|
.timeline()
|
||||||
.to(
|
.to(
|
||||||
@@ -77,6 +82,7 @@ const { selected, selectorPosition } = useButtonNavigation({
|
|||||||
_3dMode: { down: "_2dMode" },
|
_3dMode: { down: "_2dMode" },
|
||||||
_2dMode: { up: "_3dMode" },
|
_2dMode: { up: "_3dMode" },
|
||||||
},
|
},
|
||||||
|
disabled: isAnimating,
|
||||||
selectorAnimation: {
|
selectorAnimation: {
|
||||||
ease: "none",
|
ease: "none",
|
||||||
duration: 0.065,
|
duration: 0.065,
|
||||||
@@ -84,11 +90,13 @@ const { selected, selectorPosition } = useButtonNavigation({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleCancel = async () => {
|
const handleCancel = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
await animateOutro();
|
await animateOutro();
|
||||||
store.closeSubMenu();
|
store.closeSubMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
const mode = selected.value === "_3dMode" ? "3d" : "2d";
|
const mode = selected.value === "_3dMode" ? "3d" : "2d";
|
||||||
app.setRenderingMode(mode);
|
app.setRenderingMode(mode);
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ const highScore = useLocalStorage("taptap_high_score", 0);
|
|||||||
let score = 0;
|
let score = 0;
|
||||||
let isNewBest = false;
|
let isNewBest = false;
|
||||||
|
|
||||||
|
const isAnimating = ref(true);
|
||||||
|
|
||||||
const AREA_FADE_DURATION = 0.2;
|
const AREA_FADE_DURATION = 0.2;
|
||||||
const SCORE_OFFSET = -20;
|
const SCORE_OFFSET = -20;
|
||||||
const SCORE_DURATION = 0.15;
|
const SCORE_DURATION = 0.15;
|
||||||
@@ -77,6 +79,7 @@ const animation = reactive({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const animateIntro = async () => {
|
const animateIntro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await gsap
|
await gsap
|
||||||
.timeline()
|
.timeline()
|
||||||
.to(
|
.to(
|
||||||
@@ -89,9 +92,11 @@ const animateIntro = async () => {
|
|||||||
{ scoreOffsetY: 0, duration: SCORE_DURATION, ease: "none" },
|
{ scoreOffsetY: 0, duration: SCORE_DURATION, ease: "none" },
|
||||||
AREA_FADE_DURATION,
|
AREA_FADE_DURATION,
|
||||||
);
|
);
|
||||||
|
isAnimating.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const animateOutro = async () => {
|
const animateOutro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
targetX = 0;
|
targetX = 0;
|
||||||
targetY = LOGICAL_HEIGHT * 2 - 20;
|
targetY = LOGICAL_HEIGHT * 2 - 20;
|
||||||
|
|
||||||
@@ -119,6 +124,7 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleActivateB = () => {
|
const handleActivateB = () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
if (state.value === "playing") {
|
if (state.value === "playing") {
|
||||||
state.value = "paused";
|
state.value = "paused";
|
||||||
confirmationModal.open({
|
confirmationModal.open({
|
||||||
@@ -140,6 +146,7 @@ const handleActivateB = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleActivateA = async () => {
|
const handleActivateA = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
if (state.value === "playing") {
|
if (state.value === "playing") {
|
||||||
state.value = "paused";
|
state.value = "paused";
|
||||||
confirmationModal.open({
|
confirmationModal.open({
|
||||||
|
|||||||
@@ -8,19 +8,24 @@ const BIRTHDAY_DAY = 25;
|
|||||||
const BIRTHDAY_MONTH = 4;
|
const BIRTHDAY_MONTH = 4;
|
||||||
const BIRTHDAY_YEAR = 2002;
|
const BIRTHDAY_YEAR = 2002;
|
||||||
|
|
||||||
|
const isAnimating = ref(true);
|
||||||
|
|
||||||
const monthRef = useTemplateRef<InstanceType<typeof NumberInput>>("month");
|
const monthRef = useTemplateRef<InstanceType<typeof NumberInput>>("month");
|
||||||
const dayRef = useTemplateRef<InstanceType<typeof NumberInput>>("day");
|
const dayRef = useTemplateRef<InstanceType<typeof NumberInput>>("day");
|
||||||
const yearRef = useTemplateRef<InstanceType<typeof NumberInput>>("year");
|
const yearRef = useTemplateRef<InstanceType<typeof NumberInput>>("year");
|
||||||
|
|
||||||
const animateIntro = async () => {
|
const animateIntro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
monthRef.value?.animateIntro(),
|
monthRef.value?.animateIntro(),
|
||||||
dayRef.value?.animateIntro(),
|
dayRef.value?.animateIntro(),
|
||||||
yearRef.value?.animateIntro(),
|
yearRef.value?.animateIntro(),
|
||||||
]);
|
]);
|
||||||
|
isAnimating.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const animateOutro = async () => {
|
const animateOutro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
monthRef.value?.animateOutro(),
|
monthRef.value?.animateOutro(),
|
||||||
dayRef.value?.animateOutro(),
|
dayRef.value?.animateOutro(),
|
||||||
@@ -33,11 +38,13 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleActivateB = async () => {
|
const handleActivateB = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
await animateOutro();
|
await animateOutro();
|
||||||
store.closeSubMenu();
|
store.closeSubMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleActivateA = () => {
|
const handleActivateA = () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const currentYear = today.getFullYear();
|
const currentYear = today.getFullYear();
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ const TEXT_FADE_DURATION = 0.15;
|
|||||||
const SCORE_OFFSET = -20;
|
const SCORE_OFFSET = -20;
|
||||||
const SCORE_DURATION = 0.15;
|
const SCORE_DURATION = 0.15;
|
||||||
|
|
||||||
|
const isAnimating = ref(true);
|
||||||
|
|
||||||
const intro = reactive({
|
const intro = reactive({
|
||||||
boardOffsetY: BOARD_SLIDE_OFFSET,
|
boardOffsetY: BOARD_SLIDE_OFFSET,
|
||||||
boardOpacity: 0,
|
boardOpacity: 0,
|
||||||
@@ -27,6 +29,7 @@ const intro = reactive({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const animateIntro = async () => {
|
const animateIntro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await gsap
|
await gsap
|
||||||
.timeline()
|
.timeline()
|
||||||
.to(
|
.to(
|
||||||
@@ -49,9 +52,11 @@ const animateIntro = async () => {
|
|||||||
{ scoreOffsetY: 0, duration: SCORE_DURATION, ease: "none" },
|
{ scoreOffsetY: 0, duration: SCORE_DURATION, ease: "none" },
|
||||||
BOARD_SLIDE_DURATION + TEXT_FADE_DURATION,
|
BOARD_SLIDE_DURATION + TEXT_FADE_DURATION,
|
||||||
);
|
);
|
||||||
|
isAnimating.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const animateOutro = async () => {
|
const animateOutro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await gsap
|
await gsap
|
||||||
.timeline()
|
.timeline()
|
||||||
.to(
|
.to(
|
||||||
@@ -80,6 +85,7 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleCancel = async () => {
|
const handleCancel = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
switch (state.value) {
|
switch (state.value) {
|
||||||
case "alive": {
|
case "alive": {
|
||||||
state.value = "pause";
|
state.value = "pause";
|
||||||
@@ -109,6 +115,7 @@ const handleCancel = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
switch (state.value) {
|
switch (state.value) {
|
||||||
case "alive": {
|
case "alive": {
|
||||||
state.value = "pause";
|
state.value = "pause";
|
||||||
|
|||||||
@@ -17,12 +17,15 @@ const OUTRO_DURATION = 0.25;
|
|||||||
const ROW_STAGGER = SLIDE_DURATION + 0.075;
|
const ROW_STAGGER = SLIDE_DURATION + 0.075;
|
||||||
const ROW_COUNT = 2;
|
const ROW_COUNT = 2;
|
||||||
|
|
||||||
|
const isAnimating = ref(true);
|
||||||
|
|
||||||
const animation = reactive({
|
const animation = reactive({
|
||||||
rowOffsetY: new Array<number>(ROW_COUNT).fill(SLIDE_OFFSET),
|
rowOffsetY: new Array<number>(ROW_COUNT).fill(SLIDE_OFFSET),
|
||||||
rowOpacity: new Array<number>(ROW_COUNT).fill(0),
|
rowOpacity: new Array<number>(ROW_COUNT).fill(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
const animateIntro = async () => {
|
const animateIntro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
const timeline = gsap.timeline();
|
const timeline = gsap.timeline();
|
||||||
for (let i = 0; i < ROW_COUNT; i++) {
|
for (let i = 0; i < ROW_COUNT; i++) {
|
||||||
timeline
|
timeline
|
||||||
@@ -38,9 +41,11 @@ const animateIntro = async () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
await timeline;
|
await timeline;
|
||||||
|
isAnimating.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const animateOutro = async () => {
|
const animateOutro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
const timeline = gsap.timeline();
|
const timeline = gsap.timeline();
|
||||||
for (let i = 0; i < ROW_COUNT; i++) {
|
for (let i = 0; i < ROW_COUNT; i++) {
|
||||||
timeline
|
timeline
|
||||||
@@ -63,11 +68,13 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleCancel = async () => {
|
const handleCancel = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
await animateOutro();
|
await animateOutro();
|
||||||
store.closeSubMenu();
|
store.closeSubMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
|
if (isAnimating.value) return;
|
||||||
await animateOutro();
|
await animateOutro();
|
||||||
store.closeSubMenu();
|
store.closeSubMenu();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ const SLIDE_DURATION = 0.25;
|
|||||||
const ARROW_SLIDE_DELAY = 0.15;
|
const ARROW_SLIDE_DELAY = 0.15;
|
||||||
const ARROW_SLIDE_DURATION = 0.15;
|
const ARROW_SLIDE_DURATION = 0.15;
|
||||||
|
|
||||||
|
const isAnimating = ref(true);
|
||||||
|
|
||||||
const animation = reactive({
|
const animation = reactive({
|
||||||
offsetY: SLIDE_OFFSET,
|
offsetY: SLIDE_OFFSET,
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
@@ -93,6 +95,7 @@ const animation = reactive({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const animateIntro = async () => {
|
const animateIntro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await gsap
|
await gsap
|
||||||
.timeline()
|
.timeline()
|
||||||
.to(animation, { offsetY: 0, duration: SLIDE_DURATION, ease: "none" }, 0)
|
.to(animation, { offsetY: 0, duration: SLIDE_DURATION, ease: "none" }, 0)
|
||||||
@@ -107,9 +110,11 @@ const animateIntro = async () => {
|
|||||||
{ downArrowOffsetY: 0, duration: ARROW_SLIDE_DURATION, ease: "none" },
|
{ downArrowOffsetY: 0, duration: ARROW_SLIDE_DURATION, ease: "none" },
|
||||||
SLIDE_DURATION + ARROW_SLIDE_DELAY,
|
SLIDE_DURATION + ARROW_SLIDE_DELAY,
|
||||||
);
|
);
|
||||||
|
isAnimating.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const animateOutro = async () => {
|
const animateOutro = async () => {
|
||||||
|
isAnimating.value = true;
|
||||||
await gsap
|
await gsap
|
||||||
.timeline()
|
.timeline()
|
||||||
.to(
|
.to(
|
||||||
@@ -208,7 +213,7 @@ onRender((ctx) => {
|
|||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
useKeyDown((key) => {
|
useKeyDown((key) => {
|
||||||
if (!props.selected || props.disabled) return;
|
if (isAnimating.value || !props.selected || props.disabled) return;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "NDS_UP":
|
case "NDS_UP":
|
||||||
increase();
|
increase();
|
||||||
@@ -220,7 +225,7 @@ useKeyDown((key) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onClick((x, y) => {
|
onClick((x, y) => {
|
||||||
if (props.disabled) return;
|
if (isAnimating.value || props.disabled) return;
|
||||||
if (
|
if (
|
||||||
rectContains(
|
rectContains(
|
||||||
[props.x, Y, upImage.value.rect.width, ARROW_IMAGE_HEIGHT],
|
[props.x, Y, upImage.value.rect.width, ARROW_IMAGE_HEIGHT],
|
||||||
|
|||||||
Reference in New Issue
Block a user