File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44import { CSSProperties } from "react" ;
55import { XmbItem } from "@models/menu" ;
66import { useSearchParams , usePathname , useRouter } from "next/navigation" ;
7+ import { useWindowSize } from "@uidotdev/usehooks" ;
8+ import useMobileDetect from "@/hooks/useMobileDetect" ;
79import "./xmb.css" ;
810import Link from "next/link" ;
911
@@ -16,25 +18,48 @@ interface MenuItemProps {
1618export 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
You can’t perform that action at this time.
0 commit comments