{"version":3,"file":"ParallaxFloating_Prod.C7Y-mpJ7.mjs","names":["useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/FJ6Tdhm43j9BNWb0QHUP/HROIR0neEhhanzpkDWlQ/ParallaxFloating_Prod.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect,useRef,useMemo}from\"react\";import{useMotionValue,useSpring}from\"framer-motion\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n *\n * @framerDisableUnlink\n */export default function ParallaxFloating(props){const{distance,direction,smoothing,enabled}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const id=generateInstanceId();const transition={damping:100,stiffness:mapRange(smoothing,0,100,2e3,50)};const offset=distance*(direction===\"away\"?-1:1);const mouseX=useMotionValue(0);const mouseY=useMotionValue(0);const x=useMotionValue(0);const y=useMotionValue(0);const springX=useSpring(x,transition);const springY=useSpring(y,transition);const ref=useRef(null);const parentRef=useRef(null);const transformRef=useRef(null);const styleRef=useRef(null);const hasSpringRef=useRef(smoothing!==0);const previousXRef=useRef(null);const previousYRef=useRef(null);useEffect(()=>{const unsubscribeX=mouseX.onChange(v=>x.set(enabled?v:0));const unsubscribeY=mouseY.onChange(v=>y.set(enabled?v:0));return()=>{unsubscribeX();unsubscribeY();};},[enabled,mouseX,mouseY,x,y]);useEffect(()=>{x.set(enabled?mouseX.get():0);y.set(enabled?mouseY.get():0);},[enabled]);useEffect(()=>{hasSpringRef.current=smoothing!==0;},[smoothing]);useEffect(()=>{let animationFrameId;const updateTransform=()=>{if(isCanvas){return;}animationFrameId=requestAnimationFrame(updateTransform);if(!parentRef.current||!styleRef.current){return;}const xValue=hasSpringRef.current?springX.get():x.get();const yValue=hasSpringRef.current?springY.get():y.get();// Get computed styles to capture all existing transforms\nconst computedStyle=window.getComputedStyle(parentRef.current);const existingTransform=computedStyle.transform;// Subtract previous values from current values for a single transform\nconst finalX=xValue-(previousXRef.current||0);const finalY=yValue-(previousYRef.current||0);const translateTransform=`translate(${finalX.toFixed(3)}px, ${finalY.toFixed(3)}px)`;// Combine with existing transforms\nconst newTransform=existingTransform&&existingTransform!==\"none\"?`${translateTransform} ${existingTransform}`:translateTransform;transformRef.current=newTransform;styleRef.current.textContent=`\n\t\t\t\tdiv[data-parallaxfloating=\"${id}\"] { transform: ${newTransform} !important }\n\t\t\t`;previousXRef.current=xValue;previousYRef.current=yValue;};if(ref.current){const container=ref.current.parentElement;if(container){const parent=container.parentElement;if(parent){parentRef.current=parent;parent.setAttribute(\"data-parallaxfloating\",id);}}}// Start the animation loop\nupdateTransform();// Cleanup function\nreturn()=>{if(animationFrameId){cancelAnimationFrame(animationFrameId);}};},[]);useEffect(()=>{const handleMouseMove=event=>{const mouseXPos=event.clientX;const mouseYPos=event.clientY;const centerX=window.innerWidth/2;const centerY=window.innerHeight/2;const normalizedX=(mouseXPos-centerX)/centerX*offset;const normalizedY=(mouseYPos-centerY)/centerY*offset;mouseX.set(normalizedX);mouseY.set(normalizedY);};window.addEventListener(\"mousemove\",handleMouseMove);return()=>window.removeEventListener(\"mousemove\",handleMouseMove);},[offset,smoothing,enabled]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...props.style},children:/*#__PURE__*/_jsx(\"style\",{ref:styleRef})});}ParallaxFloating.displayName=\"Parallax Floating\";addPropertyControls(ParallaxFloating,{enabled:{type:ControlType.Boolean,defaultValue:true},direction:{type:ControlType.Enum,defaultValue:\"away\",options:[\"toward\",\"away\"],optionTitles:[\"Toward\",\"Away\"],displaySegmentedControl:true},distance:{type:ControlType.Number,title:\"Speed\",defaultValue:25,min:0,step:1,hidden:props=>!props.enabled},smoothing:{type:ControlType.Number,defaultValue:50,min:0,max:100,step:1,description:\"More components at [Framer University](https://frameruni.link/cc).\"}});const CHARACTERS=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";const generateInstanceId=()=>{const id=useMemo(()=>{let result=\"\";for(let i=0;i<13;i++){result+=CHARACTERS.charAt(Math.floor(Math.random()*CHARACTERS.length));}return result;},[]);return id;};function mapRange(value,fromLow,fromHigh,toLow,toHigh){if(fromLow===fromHigh){return toLow;}const percentage=(value-fromLow)/(fromHigh-fromLow);return toLow+percentage*(toHigh-toLow);}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ParallaxFloating\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ParallaxFloating_Prod.map"],"mappings":"qQAKG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,WAAS,YAAU,YAAU,WAAS,EAAY,EAAS,EAAa,SAAS,GAAG,EAAa,OAAa,EAAG,GAAoB,CAAO,EAAW,CAAC,QAAQ,IAAI,UAAU,EAAS,EAAU,EAAE,IAAI,IAAI,GAAG,CAAC,CAAO,EAAO,GAAU,IAAY,OAAO,GAAG,GAAS,EAAO,EAAe,EAAE,CAAO,EAAO,EAAe,EAAE,CAAO,EAAE,EAAe,EAAE,CAAO,EAAE,EAAe,EAAE,CAAO,EAAQ,EAAU,EAAE,EAAW,CAAO,EAAQ,EAAU,EAAE,EAAW,CAAO,EAAIA,EAAO,KAAK,CAAO,EAAUA,EAAO,KAAK,CAAO,EAAaA,EAAO,KAAK,CAAO,EAASA,EAAO,KAAK,CAAO,EAAaA,EAAO,IAAY,EAAE,CAAO,EAAaA,EAAO,KAAK,CAAO,EAAaA,EAAO,KAAK,CAOhK,OAPiK,MAAc,CAAC,IAAM,EAAa,EAAO,SAAS,GAAG,EAAE,IAAI,EAAQ,EAAE,EAAE,CAAC,CAAO,EAAa,EAAO,SAAS,GAAG,EAAE,IAAI,EAAQ,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAc,CA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