{"version":3,"file":"GridPattern.B2yGABcF.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/ZPaD7xt6K4D8ifXSSHNb/yn9SQpha36QR8nv35zwx/GridPattern.js"],"sourcesContent":["// Square grid pattern with hover movement effect\n// Component size: 2000x1200px\n// Controls: square size, grid line color, movement intensity\n// On hover: pattern moves in the direction of mouse movement\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerIntrinsicWidth 2000\n * @framerIntrinsicHeight 1200\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function GridPattern(props){const{gridColor=\"#CCCCCC\",lineWidth=1,movementIntensity=20,highlightColor=\"#0099FF\",easing=\"ease-out\",horizontalSpacing=50,verticalSpacing=50,highlightDuration=1e3}=props;const containerRef=useRef(null);const[offset,setOffset]=useState({x:0,y:0});const[hoveredSquares,setHoveredSquares]=useState([]);const timeoutsRef=useRef(new Map);useEffect(()=>{const container=containerRef.current;if(!container)return;const handleMouseMove=e=>{const rect=container.getBoundingClientRect();const centerX=rect.left+rect.width/2;const centerY=rect.top+rect.height/2;const mouseX=e.clientX;const mouseY=e.clientY;const deltaX=(mouseX-centerX)/rect.width;const deltaY=(mouseY-centerY)/rect.height;const offsetX=deltaX*movementIntensity;const offsetY=deltaY*movementIntensity;// Calculate which square is being hovered\nconst relativeX=mouseX-rect.left;const relativeY=mouseY-rect.top;const col=Math.floor(relativeX/horizontalSpacing);const row=Math.floor(relativeY/verticalSpacing);startTransition(()=>{setOffset({x:offsetX,y:offsetY});setHoveredSquares(prev=>{// Remove all squares that are not this one and are not fading\nconst filteredPrev=prev.filter(sq=>sq.col!==col||sq.row!==row||sq.isFading);// Check if this square is already in the array (not fading)\nconst existsIndex=filteredPrev.findIndex(sq=>sq.col===col&&sq.row===row&&!sq.isFading);if(existsIndex!==-1){// If exists, restart fade timeout for this square\nconst existingSquare=filteredPrev[existsIndex];const oldKey=`${existingSquare.col}-${existingSquare.row}-${existingSquare.timestamp}`;// clear timeouts for previous\nif(timeoutsRef.current.has(oldKey)){clearTimeout(timeoutsRef.current.get(oldKey));timeoutsRef.current.delete(oldKey);}const updatedTimestamp=Date.now();const squareKey=`${col}-${row}-${updatedTimestamp}`;const newSquare={...existingSquare,timestamp:updatedTimestamp,isFading:false};const updated=[...filteredPrev];updated[existsIndex]=newSquare;// Set timeout to start fading\nconst fadeTimeout=setTimeout(()=>{startTransition(()=>{setHoveredSquares(current=>current.map(sq=>sq.col===col&&sq.row===row&&sq.timestamp===updatedTimestamp?{...sq,isFading:true}:sq));});const removeTimeout=setTimeout(()=>{startTransition(()=>{setHoveredSquares(current=>current.filter(sq=>!(sq.col===col&&sq.row===row&&sq.timestamp===updatedTimestamp)));});timeoutsRef.current.delete(squareKey);},300);timeoutsRef.current.set(squareKey,removeTimeout);},highlightDuration);timeoutsRef.current.set(squareKey,fadeTimeout);return updated;}const newSquare={col,row,timestamp:Date.now(),isFading:false};const squareKey=`${col}-${row}-${newSquare.timestamp}`;// Set timeout to start fading\nconst fadeTimeout=setTimeout(()=>{startTransition(()=>{setHoveredSquares(current=>current.map(sq=>sq.col===col&&sq.row===row&&sq.timestamp===newSquare.timestamp?{...sq,isFading:true}:sq));});// Set timeout to remove the square after fade animation\nconst removeTimeout=setTimeout(()=>{startTransition(()=>{setHoveredSquares(current=>current.filter(sq=>!(sq.col===col&&sq.row===row&&sq.timestamp===newSquare.timestamp)));});timeoutsRef.current.delete(squareKey);},300);timeoutsRef.current.set(squareKey,removeTimeout);},highlightDuration);timeoutsRef.current.set(squareKey,fadeTimeout);return[...filteredPrev,newSquare];});});};const handleMouseLeave=()=>{startTransition(()=>{setOffset({x:0,y:0});});};container.addEventListener(\"mousemove\",handleMouseMove);container.addEventListener(\"mouseleave\",handleMouseLeave);return()=>{container.removeEventListener(\"mousemove\",handleMouseMove);container.removeEventListener(\"mouseleave\",handleMouseLeave);// Clear all timeouts\ntimeoutsRef.current.forEach(timeout=>clearTimeout(timeout));timeoutsRef.current.clear();};},[movementIntensity,horizontalSpacing,verticalSpacing,highlightDuration]);const width=props.style?.width===\"100%\"?2e3:Number(props.style?.width)||2e3;const height=props.style?.height===\"100%\"?1200:Number(props.style?.height)||1200;const cols=Math.ceil(width/horizontalSpacing)+2;const rows=Math.ceil(height/verticalSpacing)+2;return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",position:\"relative\",overflow:\"hidden\"},children:/*#__PURE__*/_jsxs(\"svg\",{width:width,height:height,style:{position:\"absolute\",top:0,left:0,transform:`translate(${offset.x}px, ${offset.y}px)`,transition:`transform 0.3s ${easing}`},children:[/*#__PURE__*/_jsx(\"defs\",{children:/*#__PURE__*/_jsx(\"pattern\",{id:\"grid\",width:horizontalSpacing,height:verticalSpacing,patternUnits:\"userSpaceOnUse\",children:/*#__PURE__*/_jsx(\"rect\",{width:horizontalSpacing,height:verticalSpacing,fill:\"none\",stroke:gridColor,strokeWidth:lineWidth})})}),/*#__PURE__*/_jsx(\"rect\",{width:width+horizontalSpacing*2,height:height+verticalSpacing*2,x:-horizontalSpacing,y:-verticalSpacing,fill:\"url(#grid)\"}),hoveredSquares.map((square,index)=>/*#__PURE__*/_jsx(\"rect\",{x:square.col*horizontalSpacing,y:square.row*verticalSpacing,width:horizontalSpacing,height:verticalSpacing,fill:highlightColor,fillOpacity:square.isFading?0:.3,stroke:highlightColor,strokeWidth:lineWidth,strokeOpacity:square.isFading?0:1,style:{transition:square.isFading?\"fill-opacity 0.3s ease-out, stroke-opacity 0.3s ease-out\":\"fill-opacity 0.3s ease-in, stroke-opacity 0.3s ease-in\"}},`${square.col}-${square.row}-${square.timestamp}`))]})});}addPropertyControls(GridPattern,{horizontalSpacing:{type:ControlType.Number,title:\"Horizontal Spacing\",defaultValue:50,min:10,max:200,step:5,unit:\"px\"},verticalSpacing:{type:ControlType.Number,title:\"Vertical Spacing\",defaultValue:50,min:10,max:200,step:5,unit:\"px\"},gridColor:{type:ControlType.Color,title:\"Grid Color\",defaultValue:\"#CCCCCC\"},lineWidth:{type:ControlType.Number,title:\"Line Width\",defaultValue:1,min:.5,max:10,step:.5,unit:\"px\"},movementIntensity:{type:ControlType.Number,title:\"Movement Intensity\",defaultValue:20,min:0,max:100,step:5,unit:\"px\"},highlightColor:{type:ControlType.Color,title:\"Highlight Color\",defaultValue:\"#0099FF\"},highlightDuration:{type:ControlType.Number,title:\"Highlight Duration\",defaultValue:1e3,min:100,max:5e3,step:100,unit:\"ms\"},easing:{type:ControlType.Enum,title:\"Easing\",defaultValue:\"ease-out\",options:[\"linear\",\"ease\",\"ease-in\",\"ease-out\",\"ease-in-out\",\"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"],optionTitles:[\"Linear\",\"Ease\",\"Ease In\",\"Ease Out\",\"Ease In-Out\",\"Bounce\"]}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GridPattern\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicHeight\":\"1200\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"2000\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GridPattern.map"],"mappings":"uMAUG,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,YAAU,UAAU,YAAU,EAAE,oBAAkB,GAAG,iBAAe,UAAU,SAAO,WAAW,oBAAkB,GAAG,kBAAgB,GAAG,oBAAkB,KAAK,EAAY,EAAaA,EAAO,IAAI,EAAO,CAAC,EAAO,GAAWC,EAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAO,CAAC,EAAe,GAAmBA,EAAS,CAAC,CAAC,EAAQ,EAAYD,EAAO,IAAI,GAAG,EAAE,MAAc,CAAC,IAAM,EAAU,EAAa,QAAQ,GAAG,C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