{"version":3,"file":"Mouse_Parallax.BSa75dPi.mjs","names":["useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/9v3L4TcIO8eY5H9xyNQ4/eFqgrUaDyBnVzw2DDuLl/Mouse_Parallax.js"],"sourcesContent":["import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Mouse Parallax\n * By OneFramer.com\n *\n * @framerDisableUnlink\n */export default function Mouse_Parallax(props){const{parentId,children,movementAxis}=props;const[clientX,setClientX]=useState(null);const[clientY,setClientY]=useState(null);useEffect(()=>{const parent=document.getElementById(parentId);if(!parent)return;const handleMouseMove=e=>{setClientX(e.clientX);setClientY(e.clientY);};const handleMouseLeave=()=>{children.forEach(child=>{const childElement=document.getElementById(child.id);if(!childElement)return;childElement.style.transition=`transform ${child.transitionDuration}ms cubic-bezier(0, 0, 0.58, 1) `;childElement.style.transform=\"translate(0, 0)\";});};parent.addEventListener(\"mousemove\",handleMouseMove);parent.addEventListener(\"mouseleave\",handleMouseLeave);return()=>{parent.removeEventListener(\"mousemove\",handleMouseMove);parent.removeEventListener(\"mouseleave\",handleMouseLeave);};},[parentId,children]);useEffect(()=>{const parent=document.getElementById(parentId);if(!parent)return;children.forEach(child=>{const childElement=document.getElementById(child.id);if(!childElement)return;let moveX=0;let moveY=0;const speed=child.movementFactor/1e3;if(movementAxis===\"Both\"||movementAxis===\"Horizontal\"){if(clientX){moveX=(clientX-window.innerWidth/2)*child.sensitivityX*.01*speed;}}if(movementAxis===\"Both\"||movementAxis===\"Vertical\"){if(clientY){moveY=(clientY-window.innerHeight/2)*child.sensitivityY*.01*speed;}}if(child.reverseMovement){moveX*=-1;moveY*=-1;}if(child.lockReverse){console.log(child);if(moveX<0){childElement.style.transition=`transform ${child.transitionDuration}ms cubic-bezier(0, 0, 0.58, 1`;childElement.style.transform=`translate(${moveX}px, ${moveY}px)`;}return;}childElement.style.transition=`transform ${child.transitionDuration}ms cubic-bezier(0, 0, 0.58, 1)`;childElement.style.transform=`translate(${moveX}px, ${moveY}px)`;});},[clientX,clientY,parentId,children,movementAxis]);return /*#__PURE__*/_jsx(_Fragment,{});}addPropertyControls(Mouse_Parallax,{parentId:{type:ControlType.String,title:\"Parent ID\",defaultValue:\"container\"},movementAxis:{type:ControlType.Enum,title:\"Movement Axis\",options:[\"Both\",\"Horizontal\",\"Vertical\"],optionTitles:[\"Both\",\"Horizontal\",\"Vertical\"],defaultValue:\"Both\"},children:{type:ControlType.Array,title:\"Children\",propertyControl:{type:ControlType.Object,controls:{id:{type:ControlType.String,title:\"ID\",defaultValue:\"child\"},movementFactor:{type:ControlType.Number,title:\"Speed (ms)\",defaultValue:500,displayStepper:true,step:10},reverseMovement:{type:ControlType.Boolean,title:\"Reverse Movement\",defaultValue:false},sensitivityX:{type:ControlType.Number,title:\"Horizontal Sensitivity\",defaultValue:10,displayStepper:true,step:10},sensitivityY:{type:ControlType.Number,title:\"Vertical Sensitivity\",defaultValue:10,displayStepper:true,step:10},transitionDuration:{type:ControlType.Number,title:\"Transition Duration (ms)\",defaultValue:500,displayStepper:true,step:10},lockReverse:{type:ControlType.Boolean,title:\"Lock Reverse Movement (horizontal)\",defaultValue:false}}}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Mouse_Parallax\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Mouse_Parallax.map"],"mappings":"uMAKG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,WAAS,WAAS,gBAAc,EAAW,CAAC,EAAQ,GAAYA,EAAS,KAAK,CAAM,CAAC,EAAQ,GAAYA,EAAS,KAAK,CAAiqD,OAAhqD,MAAc,CAAC,IAAM,EAAO,SAAS,eAAe,EAAS,CAAC,GAAG,CAAC,EAAO,OAAO,IAAM,EAAgB,GAAG,CAA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