Skip to content

Commit 39ed934

Browse files
committed
Fixed mobile layout issue
1 parent cef76ef commit 39ed934

1 file changed

Lines changed: 37 additions & 12 deletions

File tree

‎src/components/xmb-menu/xmb-menu-item.tsx‎

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import { CSSProperties } from "react";
55
import { XmbItem } from "@models/menu";
66
import { useSearchParams, usePathname, useRouter } from "next/navigation";
7+
import { useWindowSize } from "@uidotdev/usehooks";
8+
import useMobileDetect from "@/hooks/useMobileDetect";
79
import "./xmb.css";
810
import Link from "next/link";
911

@@ -16,25 +18,48 @@ interface MenuItemProps {
1618
export const MenuItem = ({ index, item, y }: MenuItemProps) => {
1719
const active = index === y;
1820
const router = useRouter();
21+
const size = useWindowSize();
22+
const platform = useMobileDetect();
1923

2024
let top = 0;
2125
let bottom = 0;
2226

23-
if (index === 0) {
24-
if (active) {
25-
top = 50;
26-
bottom = 30;
27+
if (platform.isMobile()) {
28+
if (index === 0) {
29+
if (active) {
30+
top = 30;
31+
bottom = 40;
32+
} else {
33+
top = -300 + -110 * y;
34+
bottom = 0;
35+
}
2736
} else {
28-
top = -190 + -120 * y;
29-
bottom = 20;
37+
if (active) {
38+
top = 350;
39+
bottom = 30;
40+
} else {
41+
top = 30;
42+
bottom = 30;
43+
}
3044
}
31-
} else {
32-
if (active) {
33-
top = 250 - 5 * y;
34-
bottom = 20;
45+
}
46+
else {
47+
if (index === 0) {
48+
if (active) {
49+
top = 50;
50+
bottom = 30;
51+
} else {
52+
top = -190 + -120 * y;
53+
bottom = 20;
54+
}
3555
} else {
36-
top = 15;
37-
bottom = 30;
56+
if (active) {
57+
top = 250 - 5 * y;
58+
bottom = 20;
59+
} else {
60+
top = 15;
61+
bottom = 30;
62+
}
3863
}
3964
}
4065

0 commit comments

Comments
 (0)