diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index 3cbe607..5b6a7cc 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -18,6 +18,7 @@ const Index = () => { const [lines, setLines] = useState<{ x1: number; y1: number; x2: number; y2: number }[]>([]); const [mousePos, setMousePos] = useState({ x: 0, y: 0 }); const [mounted, setMounted] = useState(false); + const [dims, setDims] = useState({ w: 0, h: 0 }); const updateLines = useCallback(() => { if (!containerRef.current || !avatarRef.current) return; @@ -25,13 +26,17 @@ const Index = () => { const avatarRect = avatarRef.current.getBoundingClientRect(); const cx = avatarRect.left + avatarRect.width / 2 - containerRect.left; const cy = avatarRect.top + avatarRect.height / 2 - containerRect.top; + setDims({ w: containerRect.width, h: containerRect.height }); const newLines = cardRefs.current.map((card) => { if (!card) return { x1: cx, y1: cy, x2: cx, y2: cy }; const cardRect = card.getBoundingClientRect(); - const cardCx = cardRect.left + cardRect.width / 2 - containerRect.left; - const cardCy = cardRect.top + cardRect.height / 2 - containerRect.top; - return { x1: cx, y1: cy, x2: cardCx, y2: cardCy }; + return { + x1: cx, + y1: cy, + x2: cardRect.left + cardRect.width / 2 - containerRect.left, + y2: cardRect.top + cardRect.height / 2 - containerRect.top, + }; }); setLines(newLines); }, []); @@ -40,29 +45,30 @@ const Index = () => { updateLines(); const timer = setTimeout(() => setMounted(true), 100); window.addEventListener('resize', updateLines); - return () => { - window.removeEventListener('resize', updateLines); - clearTimeout(timer); - }; + return () => { window.removeEventListener('resize', updateLines); clearTimeout(timer); }; }, [updateLines]); useEffect(() => { - // Re-calc after fonts/images load - const timer = setTimeout(updateLines, 500); - return () => clearTimeout(timer); + const t = setTimeout(updateLines, 500); + return () => clearTimeout(t); }, [updateLines]); const handleMouseMove = useCallback((e: React.MouseEvent) => { - if (!containerRef.current) return; - const rect = containerRef.current.getBoundingClientRect(); - setMousePos({ x: e.clientX - rect.left, y: e.clientY - rect.top }); + setMousePos({ x: e.clientX, y: e.clientY }); }, []); + // On mobile, use a smaller radius + const isMobile = dims.w < 640; + const radius = isMobile ? 140 : 220; + const count = items.length; + // Start from top (-90deg) and spread evenly + const angleOffset = -90; + return (
+ I'm Mohamad +
+- I'm Mohamad — welcome to my space. -
-{item.label}
-{item.desc}
+{item.label}
+{item.desc}
{item.label}
-{item.desc}
-+
damaj.tech