{"version":3,"file":"WordMagnetCB.PQRFH-N2.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/w2MlGkDVFYUbA9iQWp2G/Dd7mw6242BBOSGIqFx6I/WordMagnetCB.js"],"sourcesContent":["// Word Magnet - Words repel from cursor slightly, then snap back with letters staying intact\n// Look: Words repel from the cursor slightly, then snap back—letters stay intact.\n// Use for: Playful landing pages.\n// Props: radius, force, damping, returnDelay\n// Perf/A11y: Pointer-event throttling; disable on mobile if jittery.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{motion,useSpring,useMotionValue}from\"framer-motion\";/**\n * Word Magnet\n *\n * @framerIntrinsicWidth 720\n * @framerIntrinsicHeight 245\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function WordMagnetCB(props){const{text=\"Hover over these words and watch them dance\",radius=120,force=.3,damping=15,returnDelay=200,textColor=\"#000000\",font,disableOnMobile=true,overflow=\"hidden\",style}=props;const containerRef=useRef(null);const[words,setWords]=useState([]);const[isMobile,setIsMobile]=useState(false);const isStatic=useIsStaticRenderer();const mouseX=useMotionValue(0);const mouseY=useMotionValue(0);const lastMoveTime=useRef(0);const throttleDelay=16// ~60fps\n;// Detect layout mode\nconst isFixedWidth=style?.width===\"100%\";const isFixedHeight=style?.height===\"100%\";useEffect(()=>{if(typeof window!==\"undefined\"){const checkMobile=()=>{startTransition(()=>{setIsMobile(window.innerWidth<768||\"ontouchstart\"in window);});};checkMobile();window.addEventListener(\"resize\",checkMobile);return()=>window.removeEventListener(\"resize\",checkMobile);}},[]);useEffect(()=>{startTransition(()=>{setWords(text.split(\" \").filter(word=>word.length>0));});},[text]);useEffect(()=>{if(isStatic||disableOnMobile&&isMobile)return;const handleMouseMove=e=>{const now=Date.now();if(now-lastMoveTime.current<throttleDelay)return;lastMoveTime.current=now;if(containerRef.current){const rect=containerRef.current.getBoundingClientRect();mouseX.set(e.clientX-rect.left);mouseY.set(e.clientY-rect.top);}};window.addEventListener(\"mousemove\",handleMouseMove);return()=>window.removeEventListener(\"mousemove\",handleMouseMove);},[mouseX,mouseY,isStatic,isMobile,disableOnMobile]);const isDisabled=isStatic||disableOnMobile&&isMobile;return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,position:\"relative\",width:isFixedWidth?\"100%\":\"max-content\",height:isFixedHeight?\"100%\":\"max-content\",display:\"flex\",flexWrap:\"wrap\",alignItems:\"center\",justifyContent:\"center\",gap:\"0.5em\",overflow,...font,color:textColor},children:words.map((word,index)=>/*#__PURE__*/_jsx(Word,{word:word,mouseX:mouseX,mouseY:mouseY,radius:radius,force:force,damping:damping,returnDelay:returnDelay,disabled:isDisabled},`${word}-${index}`))});}function Word({word,mouseX,mouseY,radius,force,damping,returnDelay,disabled}){const wordRef=useRef(null);const[position,setPosition]=useState({x:0,y:0});const returnTimeout=useRef(null);const x=useSpring(0,{damping,stiffness:200});const y=useSpring(0,{damping,stiffness:200});useEffect(()=>{if(disabled)return;const unsubscribeX=mouseX.on(\"change\",latest=>{if(!wordRef.current)return;const rect=wordRef.current.getBoundingClientRect();const wordCenterX=rect.left+rect.width/2-(wordRef.current.offsetParent?.getBoundingClientRect().left||0);const wordCenterY=rect.top+rect.height/2-(wordRef.current.offsetParent?.getBoundingClientRect().top||0);const currentMouseY=mouseY.get();const dx=wordCenterX-latest;const dy=wordCenterY-currentMouseY;const distance=Math.sqrt(dx*dx+dy*dy);if(distance<radius){const angle=Math.atan2(dy,dx);const repelForce=(radius-distance)/radius*force*100;const offsetX=Math.cos(angle)*repelForce;const offsetY=Math.sin(angle)*repelForce;x.set(offsetX);y.set(offsetY);if(returnTimeout.current!==null){clearTimeout(returnTimeout.current);}returnTimeout.current=window.setTimeout(()=>{x.set(0);y.set(0);},returnDelay);}});const unsubscribeY=mouseY.on(\"change\",()=>{mouseX.get()// Trigger the X listener\n;});return()=>{unsubscribeX();unsubscribeY();if(returnTimeout.current!==null){clearTimeout(returnTimeout.current);}};},[mouseX,mouseY,radius,force,x,y,returnDelay,disabled]);if(disabled){return /*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"nowrap\"},children:word});}return /*#__PURE__*/_jsx(motion.span,{ref:wordRef,style:{display:\"inline-block\",whiteSpace:\"nowrap\",x,y},children:word});}addPropertyControls(WordMagnetCB,{text:{type:ControlType.String,title:\"Text\",defaultValue:'Lorem Ipsum is a type of placeholder text commonly used in the design and publishing industries. It is derived from a work by the Roman statesman and philosopher Cicero, specifically from \"De finibus bonorum et malorum,\" and has been altered to create nonsensical Latin phrases.',displayTextArea:true},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:130,min:50,max:300,step:10,unit:\"px\"},force:{type:ControlType.Number,title:\"Force\",defaultValue:.45,min:.1,max:1,step:.05},damping:{type:ControlType.Number,title:\"Damping\",defaultValue:28,min:5,max:50,step:1},returnDelay:{type:ControlType.Number,title:\"Return Delay\",defaultValue:400,min:0,max:1e3,step:50,unit:\"ms\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.03em\",lineHeight:\"1.2em\"}},overflow:{type:ControlType.Enum,title:\"Overflow\",options:[\"visible\",\"hidden\",\"scroll\",\"auto\"],optionTitles:[\"Visible\",\"Hidden\",\"Scroll\",\"Auto\"],defaultValue:\"visible\",displaySegmentedControl:false},disableOnMobile:{type:ControlType.Boolean,title:\"Disable on Mobile\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"WordMagnetCB\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"720\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"245\",\"fram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