{"version":3,"file":"InteractiveFlowLines.DBK8s8fP.mjs","names":["React.useRef"],"sources":["https:/framerusercontent.com/modules/l7VYo97xOXVM6z6NsQX8/LgUfIkez8nDkCpy0dIQu/InteractiveFlowLines.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 200\n */export default function InteractiveFlowLines(props){const canvasRef=React.useRef(null);const containerRef=React.useRef(null);// Store raw screen coordinates\nconst globalRawX=React.useRef(-1e3);const globalRawY=React.useRef(-1e3);// Relative coordinates for calculation\nconst mousePos=React.useRef(-1e3)// Represents X or Y depending on orientation\n;const isHovering=React.useRef(false);const scrollOffset=React.useRef(0)// Represents globalX or globalY\n;const masterIntensity=React.useRef(0);const animationRef=React.useRef(null);const colorStartRef=React.useRef([0,0,0,1]);const colorEndRef=React.useRef([0,0,0,1]);const parseColor=colorStr=>{const div=document.createElement(\"div\");div.style.color=colorStr;document.body.appendChild(div);const style=window.getComputedStyle(div).color;document.body.removeChild(div);const match=style.match(/[\\d\\.]+/g);if(!match)return[0,0,0,1];const values=match.map(Number);return values.length===3?[...values,1]:values;};const lerp=(start,end,t)=>start*(1-t)+end*t;React.useEffect(()=>{colorStartRef.current=parseColor(props.defaultColor);colorEndRef.current=parseColor(props.hoverColor);},[props.defaultColor,props.hoverColor]);// --- Scroll Animation Logic ---\nReact.useEffect(()=>{if(!props.enableScroll||props.speed===0){scrollOffset.current=0;return;}let lastTime=performance.now();const totalSize=props.lineWidth+props.gap;const updateScroll=time=>{const delta=time-lastTime;lastTime=time;const safeDelta=Math.min(delta,100);const timeScale=safeDelta/16.67;// Direction Logic\nif(props.direction===\"forward\"){scrollOffset.current-=props.speed*timeScale;}else{scrollOffset.current+=props.speed*timeScale;}// Keep offset within bounds to prevent float overflow over long periods\nif(scrollOffset.current<0){scrollOffset.current=scrollOffset.current%totalSize+totalSize;}else{scrollOffset.current=scrollOffset.current%totalSize;}animationRef.current=requestAnimationFrame(updateScroll);};animationRef.current=requestAnimationFrame(updateScroll);return()=>{if(animationRef.current)cancelAnimationFrame(animationRef.current);};},[props.enableScroll,props.speed,props.lineWidth,props.gap,props.direction]);// --- Global Mouse Listener ---\nReact.useEffect(()=>{const handleWindowMove=e=>{globalRawX.current=e.clientX;globalRawY.current=e.clientY;if(props.interactionMode===\"global\"){isHovering.current=true;}};const handleWindowLeave=()=>{if(props.interactionMode===\"global\"){isHovering.current=false;}};if(props.interactionMode===\"global\"){window.addEventListener(\"mousemove\",handleWindowMove);document.addEventListener(\"mouseleave\",handleWindowLeave);}return()=>{window.removeEventListener(\"mousemove\",handleWindowMove);document.removeEventListener(\"mouseleave\",handleWindowLeave);};},[props.interactionMode]);// --- Render Loop ---\nReact.useEffect(()=>{const canvas=canvasRef.current;const ctx=canvas.getContext(\"2d\");let renderLoopId;const render=()=>{if(!canvas||!containerRef.current)return;const width=containerRef.current.offsetWidth;const height=containerRef.current.offsetHeight;const dpr=window.devicePixelRatio||1;// 1. Resize Canvas\nif(canvas.width!==width*dpr||canvas.height!==height*dpr){canvas.width=width*dpr;canvas.height=height*dpr;canvas.style.width=`${width}px`;canvas.style.height=`${height}px`;ctx.scale(dpr,dpr);}// 2. Calculate Mouse Position based on Orientation\nconst rect=containerRef.current.getBoundingClientRect();const isVertical=props.orientation===\"vertical\";if(props.interactionMode===\"global\"){if(isVertical){mousePos.current=globalRawX.current-rect.left;}else{mousePos.current=globalRawY.current-rect.top;}}// Local mode is handled by onMouseMove\nctx.clearRect(0,0,width,height);const targetIntensity=isHovering.current?1:0;masterIntensity.current=lerp(masterIntensity.current,targetIntensity,.1);const totalItemSize=props.lineWidth+props.gap;const currentScroll=props.enableScroll?scrollOffset.current:0;// Determine primary dimension (width for vertical lines, height for horizontal lines)\nconst primaryDim=isVertical?width:height;const secondaryDim=isVertical?height:width;const lineCount=Math.ceil(primaryDim/totalItemSize)+2;const idealIndex=Math.round((mousePos.current-props.lineWidth/2-currentScroll)/totalItemSize);for(let i=-1;i<lineCount;i++){const linePos=i*totalItemSize+props.lineWidth/2+currentScroll;// Check bounds relative to the primary dimension\n// We add a buffer to ensure lines don't pop out of existence\nif(linePos<-props.lineWidth-totalItemSize||linePos>primaryDim+props.lineWidth+totalItemSize)continue;const dist=Math.abs(mousePos.current-linePos);const sigma=props.influenceSize/5;let shapeIntensity=Math.exp(-Math.pow(dist,2)/(2*Math.pow(sigma,2)));if(props.useSteps&&props.stepCount>0){if(i===idealIndex){shapeIntensity=1;}else{shapeIntensity=Math.floor(shapeIntensity*props.stepCount)/props.stepCount;}}const finalIntensity=shapeIntensity*masterIntensity.current;// Calculate dynamic size (height for vertical, width for horizontal)\nconst currentSizePct=props.baseHeight+(props.maxHeight-props.baseHeight)*finalIntensity;const currentSize=currentSizePct/100*secondaryDim;// Color Interpolation\nconst r=Math.round(lerp(colorStartRef.current[0],colorEndRef.current[0],finalIntensity));const g=Math.round(lerp(colorStartRef.current[1],colorEndRef.current[1],finalIntensity));const b=Math.round(lerp(colorStartRef.current[2],colorEndRef.current[2],finalIntensity));const a=lerp(colorStartRef.current[3],colorEndRef.current[3],finalIntensity);ctx.fillStyle=`rgba(${r},${g},${b},${a})`;// Draw Logic\nlet x,y,w,h;if(isVertical){// Vertical Lines\nx=linePos-props.lineWidth/2;w=props.lineWidth;h=currentSize;if(props.alignment===\"top\")y=0;else if(props.alignment===\"bottom\")y=height-currentSize;else y=(height-currentSize)/2// Center\n;}else{// Horizontal Lines\ny=linePos-props.lineWidth/2;h=props.lineWidth;w=currentSize;if(props.alignment===\"top\")x=0// Actually \"Left\" visually\n;else if(props.alignment===\"bottom\")x=width-currentSize// Actually \"Right\" visually\n;else x=(width-currentSize)/2// Center\n;}// Drawing Shapes\nif(props.capStyle===\"round\"){ctx.beginPath();ctx.roundRect(x,y,w,h,999);ctx.fill();}else if(props.capStyle===\"soft\"){ctx.beginPath();ctx.roundRect(x,y,w,h,4);ctx.fill();}else{ctx.fillRect(x,y,w,h);}}renderLoopId=requestAnimationFrame(render);};render();return()=>cancelAnimationFrame(renderLoopId);},[props]);// --- Local Event Handling ---\nconst handleLocalMouseMove=e=>{if(props.interactionMode===\"local\"){const rect=containerRef.current.getBoundingClientRect();if(props.orientation===\"vertical\"){mousePos.current=e.clientX-rect.left;}else{mousePos.current=e.clientY-rect.top;}isHovering.current=true;}};const handleLocalMouseLeave=()=>{if(props.interactionMode===\"local\"){isHovering.current=false;}};return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",background:\"transparent\"},onMouseMove:handleLocalMouseMove,onMouseLeave:handleLocalMouseLeave,onMouseEnter:()=>{if(props.interactionMode===\"local\")isHovering.current=true;},children:/*#__PURE__*/_jsx(\"canvas\",{ref:canvasRef,style:{display:\"block\"}})});}addPropertyControls(InteractiveFlowLines,{orientation:{type:ControlType.Enum,title:\"Direction\",defaultValue:\"vertical\",options:[\"vertical\",\"horizontal\"],optionTitles:[\"Vertical\",\"Horizontal\"]},interactionMode:{type:ControlType.Enum,title:\"Interaction\",defaultValue:\"global\",options:[\"local\",\"global\"],optionTitles:[\"Component Only\",\"Entire Screen\"]},enableScroll:{type:ControlType.Boolean,title:\"Enable Scroll\",defaultValue:true},direction:{type:ControlType.Enum,title:\"Flow\",defaultValue:\"forward\",options:[\"forward\",\"backward\"],optionTitles:[\"Forward\",\"Backward\"],hidden:props=>!props.enableScroll},alignment:{type:ControlType.Enum,title:\"Anchor\",defaultValue:\"center\",options:[\"top\",\"center\",\"bottom\"],optionTitles:[\"Top/Left\",\"Center\",\"Bottom/Right\"]},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:1,min:.1,max:5,step:.1,displayStepper:true,hidden:props=>!props.enableScroll},useSteps:{type:ControlType.Boolean,title:\"Stepped\",defaultValue:true},stepCount:{type:ControlType.Number,title:\"Steps\",defaultValue:5,min:2,max:20,step:1,hidden:props=>!props.useSteps},baseHeight:{type:ControlType.Number,title:\"Base Length\",defaultValue:30,min:1,max:100,unit:\"%\",step:1},maxHeight:{type:ControlType.Number,title:\"Max Length\",defaultValue:80,min:1,max:100,unit:\"%\",step:1},lineWidth:{type:ControlType.Number,title:\"Thickness\",defaultValue:6,min:1,max:50},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:8,min:0,max:50},influenceSize:{type:ControlType.Number,title:\"Range\",defaultValue:150,min:50,max:800,step:10},capStyle:{type:ControlType.Enum,title:\"Cap\",defaultValue:\"round\",options:[\"round\",\"square\",\"soft\"]},defaultColor:{type:ControlType.Color,title:\"Default\",defaultValue:\"rgba(224, 224, 224, 1)\"},hoverColor:{type:ControlType.Color,title:\"Hover\",defaultValue:\"rgba(255, 85, 0, 1)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"InteractiveFlowLines\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"200\",\"framerIntrinsicWidth\":\"400\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./InteractiveFlowLines.map"],"mappings":"0LAGG,SAAwB,EAAqB,EAAM,CAAC,IAAM,EAAUA,EAAa,KAAK,CAAO,EAAaA,EAAa,KAAK,CACzH,EAAWA,EAAa,KAAK,CAAO,EAAWA,EAAa,KAAK,CACjE,EAASA,EAAa,KAAK,CAC1B,EAAWA,EAAa,GAAM,CAAO,EAAaA,EAAa,EAAE,CACjE,EAAgBA,EAAa,EAAE,CAAO,EAAaA,EAAa,KAAK,CAAO,EAAcA,EAAa,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAO,EAAYA,EAAa,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAO,EAAW,GAAU,CAAC,IAAM,EAAI,SAAS,cAAc,MAAM,CAAC,EAAI,MAAM,MAAM,EAAS,SAAS,KAAK,YAAY,EAAI,CAAC,IAAM,EAAM,EAAO,iBAAiB,EAAI,CAAC,MAAM,SAAS,KAAK,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