font: tweak duration of some animations
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import gsap from "gsap";
|
||||
|
||||
const SELECTOR_SPEED = 500;
|
||||
const DURATION = 0.11;
|
||||
|
||||
export const useButtonNavigation = <T extends Record<string, Rect>>({
|
||||
buttons,
|
||||
@@ -143,18 +143,6 @@ export const useButtonNavigation = <T extends Record<string, Rect>>({
|
||||
|
||||
const graph = buildNavigationGraph(navigation);
|
||||
|
||||
const calculateDistance = (
|
||||
[x1, y1, w1, h1]: Rect,
|
||||
[x2, y2, w2, h2]: Rect,
|
||||
): number => {
|
||||
const cx1 = x1 + w1 / 2;
|
||||
const cy1 = y1 + h1 / 2;
|
||||
const cx2 = x2 + w2 / 2;
|
||||
const cy2 = y2 + h2 / 2;
|
||||
|
||||
return Math.sqrt((cx2 - cx1) ** 2 + (cy2 - cy1) ** 2);
|
||||
};
|
||||
|
||||
const animateToButton = (targetButton: Entry, path?: Array<Entry> | null) => {
|
||||
const pathButtons = path && path.length > 0 ? path : [targetButton];
|
||||
|
||||
@@ -164,14 +152,11 @@ export const useButtonNavigation = <T extends Record<string, Rect>>({
|
||||
isAnimating.value = false;
|
||||
},
|
||||
});
|
||||
let prevRect = selectorPosition.value;
|
||||
|
||||
selectorPosition.value = [...selectorPosition.value];
|
||||
|
||||
for (const button of pathButtons) {
|
||||
const buttonRect = buttons[button]!;
|
||||
const distance = calculateDistance(prevRect, buttonRect);
|
||||
const duration = distance / SELECTOR_SPEED;
|
||||
|
||||
timeline.to(
|
||||
selectorPosition.value,
|
||||
@@ -180,13 +165,11 @@ export const useButtonNavigation = <T extends Record<string, Rect>>({
|
||||
[1]: buttonRect[1],
|
||||
[2]: buttonRect[2],
|
||||
[3]: buttonRect[3],
|
||||
duration,
|
||||
duration: DURATION,
|
||||
ease: "none",
|
||||
},
|
||||
"+=0",
|
||||
);
|
||||
|
||||
prevRect = buttonRect;
|
||||
}
|
||||
|
||||
selectedButton.value = targetButton;
|
||||
|
||||
Reference in New Issue
Block a user