feat(buttonNavigation): customize selector animation

This commit is contained in:
2026-01-19 00:21:04 +01:00
parent a16f112f7b
commit 29e26f7f4e
5 changed files with 22 additions and 4 deletions

View File

@@ -47,6 +47,10 @@ const { selected, selectorPosition } = useButtonNavigation({
actionateButton(button); actionateButton(button);
}, },
disabled: computed(() => store.isIntro || store.isOutro), disabled: computed(() => store.isIntro || store.isOutro),
selectorAnimation: {
duration: 0.25,
ease: "power2.out",
},
}); });
const actionateButton = async (button: (typeof selected)["value"]) => { const actionateButton = async (button: (typeof selected)["value"]) => {

View File

@@ -54,6 +54,10 @@ const { selected, selectorPosition } = useButtonNavigation({
}, },
}, },
disabled: computed(() => store.isIntro || store.isOutro), disabled: computed(() => store.isIntro || store.isOutro),
selectorAnimation: {
duration: 0.3,
ease: "power2.out",
},
}); });
const getButtonOffset = (button: (typeof selected)["value"]) => { const getButtonOffset = (button: (typeof selected)["value"]) => {

View File

@@ -134,6 +134,10 @@ const { select, selected, selectorPosition } = useButtonNavigation({
}, },
}, },
disabled: computed(() => settingsStore.currentSubMenu !== null), disabled: computed(() => settingsStore.currentSubMenu !== null),
selectorAnimation: {
duration: 0.11,
ease: "none",
},
}); });
const isSubmenuSelected = computed(() => isSubMenu(selected.value)); const isSubmenuSelected = computed(() => isSubMenu(selected.value));

View File

@@ -64,6 +64,10 @@ const { selected, selectorPosition } = useButtonNavigation({
left: "italian", left: "italian",
}, },
}, },
selectorAnimation: {
duration: 0.1,
ease: "power2.out",
},
}); });
const handleCancel = () => { const handleCancel = () => {

View File

@@ -1,13 +1,12 @@
import gsap from "gsap"; import gsap from "gsap";
const DURATION = 0.11;
export const useButtonNavigation = <T extends Record<string, Rect>>({ export const useButtonNavigation = <T extends Record<string, Rect>>({
buttons, buttons,
initialButton, initialButton,
onButtonClick, onButtonClick,
navigation, navigation,
disabled, disabled,
selectorAnimation,
}: { }: {
buttons: T; buttons: T;
initialButton: keyof T; initialButton: keyof T;
@@ -23,6 +22,10 @@ export const useButtonNavigation = <T extends Record<string, Rect>>({
} }
>; >;
disabled?: Ref<boolean>; disabled?: Ref<boolean>;
selectorAnimation: {
duration: number;
ease: gsap.EaseString;
};
}) => { }) => {
type Entry = keyof T; type Entry = keyof T;
@@ -165,8 +168,7 @@ export const useButtonNavigation = <T extends Record<string, Rect>>({
[1]: buttonRect[1], [1]: buttonRect[1],
[2]: buttonRect[2], [2]: buttonRect[2],
[3]: buttonRect[3], [3]: buttonRect[3],
duration: DURATION, ...selectorAnimation,
ease: "none",
}, },
"+=0", "+=0",
); );