{"version":3,"file":"Mouse_Parallax.ZZ2sO2wM.mjs","names":["useState","_Fragment","__esmMin","init_npm_react_18_3_1","window","init_ssg_sandbox_shims","ce","init_jsx_runtime","_e","addPropertyControls","init_framer_DKWANagr","ControlType","Mouse_Parallax","props","clientX","setClientX","clientY","setClientY","parent","parentId","handleMouseMove","handleMouseLeave","children","childElement","child","moveX","moveY","speed","movementAxis","l","init_Mouse_Parallax"],"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":"A,iMAKG,SAAwBY,EAAe,EAAM,CAAC,GAAK,CAA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