{"version":3,"file":"Magnet.oMG2PM3h.mjs","names":["Children","useRef"],"sources":["https:/framerusercontent.com/modules/rGhBB70PTMGfpQtkjJfz/3brPVRMZwORtupktYg4i/Magnet.js"],"sourcesContent":["// Get Started: https://www.framer.com/developers\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,Children}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion,animate,useMotionValue,useAnimationFrame}from\"framer-motion\";/**\n * @framerDisableUnlink\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function Magnet({transition,children,intensity}){const hasChild=Children.count(children)>0;const isHoveringRef=useRef(false);const lastEvent=useRef(null);const x=useMotionValue(0);const y=useMotionValue(0);useAnimationFrame(()=>{const e=lastEvent.current;if(isHoveringRef.current&&e){const rect=e.target.getBoundingClientRect();const _x=(e.clientX-rect.left-rect.width/2)*intensity;const _y=(e.clientY-rect.top-rect.height/2)*intensity;animate(x,_x,transition.frame);animate(y,_y,transition.frame);}});return /*#__PURE__*/_jsx(motion.div,{style:{x,y},onHoverStart:()=>{isHoveringRef.current=true;},onHoverEnd:()=>{isHoveringRef.current=false;lastEvent.current=null;animate(x,0,transition.end);animate(y,0,transition.end);},onPointerMove:e=>{lastEvent.current=e;},children:hasChild?children:/*#__PURE__*/_jsx(Placeholder,{})});}function Placeholder(){return /*#__PURE__*/_jsx(\"div\",{style:{backgroundColor:\"rgba(0,0,0,0.9)\",width:320,height:120,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"white\",lineHeight:1,textAlign:\"center\",fontSize:12},children:/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"p\",{children:\"🧲\"}),/*#__PURE__*/_jsx(\"strong\",{children:\"Connect to Content\"}),/*#__PURE__*/_jsx(\"p\",{children:\"Add children to use the Magnet effect\"})]})});}addPropertyControls(Magnet,{children:{title:\"Content\",type:ControlType.ComponentInstance},transition:{type:ControlType.Object,controls:{frame:{type:ControlType.Transition,defaultValue:{type:\"tween\",duration:.4,ease:[0,0,1,1]}},end:{type:ControlType.Transition,defaultValue:{type:\"spring\",stiffness:400,damping:20,mass:3}}}},intensity:{type:ControlType.Number,defaultValue:1,min:0,max:2,step:.01}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Magnet\",\"slots\":[\"children\"],\"annotations\":{\"framerDisableUnlink\":\"* @framerSupportedLayoutWidth any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Magnet.map"],"mappings":"8PAKG,SAAwB,EAAO,CAAC,aAAW,WAAS,aAAW,CAAC,IAAM,EAASA,EAAS,MAAM,EAAS,CAAC,EAAQ,EAAcC,EAAO,GAAM,CAAO,EAAUA,EAAO,KAAK,CAAO,EAAE,EAAe,EAAE,CAAO,EAAE,EAAe,EAAE,CAAyS,OAAxS,MAAsB,CAAC,IAAM,EAAE,EAAU,QAAQ,GAAG,EAAc,SAAS,EAAE,CAAC,IAAM,EAAK,EAAE,OAAO,uBAAuB,CAAO,GAAI,EAAE,QAAQ,EAAK,KAAK,EAAK,MAAM,GAAG,EAAgB,GAAI,EAAE,QAAQ,EAAK,IAAI,EAAK,OAAO,GAAG,EAAU,EAAQ,EAAE,EAAG,EAAW,MAAM,CAAC,EAAQ,EAAE,EAAG,EAAW,MAAM,GAAI,CAAqB,EAAK,EAAO,IAAI,CAAC,MAAM,CAAC,IAAE,IAAE,CAAC,iBAAiB,CAAC,EAAc,QAAQ,IAAO,eAAe,CAAC,EAAc,QAAQ,GAAM,EAAU,QAAQ,KAAK,EAAQ,EAAE,EAAE,EAAW,IAAI,CAAC,EAAQ,EAAE,EAAE,EAAW,IAAI,EAAG,cAAc,GAAG,CAAC,EAAU,QAAQ,GAAI,SAAS,EAAS,EAAsB,EAAK,EAAY,EAAE,CAAC,CAAC,CAAC,CAAE,SAAS,GAAa,CAAC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