import { splitProps, mergeProps, onMount, onCleanup, type Component } from 'solid-js'; import clsx from 'clsx'; interface DotGridProps { visible?: boolean; class?: string; } /** * Hexagonal dot-grid SVG overlay with dampened mouse parallax (WIN-04). * Z-index 0: behind panels and content. * pointer-events: none so it doesn't block interaction. * The grid "lags behind" the mouse with smooth dampened motion. */ export const DotGrid: Component = (rawProps) => { const props = mergeProps({ visible: true }, rawProps); const [local] = splitProps(props, ['visible', 'class']); let svgRef: SVGSVGElement | undefined; let targetX = 0; let targetY = 0; let currentX = 0; let currentY = 0; let rafId: number; const SENSITIVITY = 0.04; // 2x original for more movement const DAMPING = 0.06; // Lower = more lag behind mouse const handleMouseMove = (e: MouseEvent) => { const centerX = window.innerWidth / 2; const centerY = window.innerHeight / 2; targetX = (e.clientX - centerX) * SENSITIVITY; targetY = (e.clientY - centerY) * SENSITIVITY; }; const animate = () => { currentX += (targetX - currentX) * DAMPING; currentY += (targetY - currentY) * DAMPING; if (svgRef) { svgRef.style.transform = `translate(${currentX}px, ${currentY}px)`; } rafId = requestAnimationFrame(animate); }; onMount(() => { window.addEventListener('mousemove', handleMouseMove); rafId = requestAnimationFrame(animate); }); onCleanup(() => { window.removeEventListener('mousemove', handleMouseMove); cancelAnimationFrame(rafId); }); return ( {/* Row 1 — wider spacing, larger dots */} {/* Row 2 (offset for hexagonal) */} ); };