{"version":3,"file":"ImageParallaxHorizontal.D4atwDbF.mjs","names":["React.useRef","React.useState"],"sources":["https:/framerusercontent.com/modules/feXRJ0itnCTO7c2NoCYF/WMqCIxfvOFU74t1bxtyS/ImageParallaxHorizontal.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n *\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 300\n */export default function ImageParallaxHorizontal(props){const{image,parallax=100,...rest}=props;const containerRef=React.useRef(null);const[translateX,setTranslateX]=React.useState(0);const[ready,setReady]=React.useState(false);React.useEffect(()=>{if(typeof window===\"undefined\")return;const calculateParallax=()=>{if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();const windowWidth=window.innerWidth;const elementWidth=rect.width;const startPosition=windowWidth-rect.left;const endPosition=-rect.right;const totalTravel=windowWidth+elementWidth;let progress=0;if(startPosition>=0&&endPosition<=0){progress=startPosition/totalTravel;}else if(startPosition<0){progress=0;}else if(endPosition>0){progress=1;}setTranslateX(parallax-progress*parallax);setReady(true);};window.addEventListener(\"scroll\",calculateParallax);calculateParallax();return()=>window.removeEventListener(\"scroll\",calculateParallax);},[parallax]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{overflow:\"hidden\",position:\"relative\",backgroundColor:\"#ffffff\",...rest.style},children:image&&ready&&/*#__PURE__*/_jsx(\"img\",{src:image,style:{width:`calc(100% + ${parallax}px)`,height:\"100%\",objectFit:\"cover\",transform:`translateX(${-translateX}px)`},alt:\"Parallax Image\"})});}addPropertyControls(ImageParallaxHorizontal,{image:{type:ControlType.Image,title:\"Image\"},parallax:{type:ControlType.Number,title:\"Parallax\",defaultValue:100,min:0,max:300,step:10,description:\"Component made by Anton Drukarov\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ImageParallaxHorizontal\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicWidth\":\"300\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicHeight\":\"300\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ImageParallaxHorizontal.map"],"mappings":"sMAQG,SAAwB,EAAwB,EAAM,CAAC,GAAK,CAAC,QAAM,WAAS,IAAI,GAAG,GAAM,EAAY,EAAaA,EAAa,KAAK,CAAM,CAAC,EAAW,GAAeC,EAAe,EAAE,CAAM,CAAC,EAAM,GAAUA,EAAe,GAAM,CAAwtB,OAAvtB,MAAoB,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,MAAsB,CAAC,GAAG,CAAC,EAAa,QAAQ,OAAO,IAAM,EAAK,EAAa,QAAQ,uBAAuB,CAAO,EAAY,EAAO,WAAiB,EAAa,EAAK,MAAY,EAAc,EAAY,EAAK,KAAW,EAAY,CAAC,EAAK,MAAY,EAAY,EAAY,EAAiB,EAAS,EAAK,GAAe,GAAG,GAAa,EAAG,EAAS,EAAc,EAAqB,EAAc,EAAG,EAAS,EAAW,EAAY,IAAG,EAAS,GAAG,EAAc,EAAS,EAAS,EAAS,CAAC,EAAS,GAAK,EAA2E,OAAxE,EAAO,iBAAiB,SAAS,EAAkB,CAAC,GAAmB,KAAW,EAAO,oBAAoB,SAAS,EAAkB,EAAG,CAAC,EAAS,CAAC,CAAqB,EAAK,MAAM,CAAC,IAAI,EAAa,MAAM,CAAC,SAAS,SAAS,SAAS,WAAW,gBAAgB,UAAU,GAAG,EAAK,MAAM,CAAC,SAAS,GAAO,GAAoB,EAAK,MAAM,CAAC,IAAI,EAAM,MAAM,CAAC,MAAM,eAAe,EAAS,KAAK,OAAO,OAAO,UAAU,QAAQ,UAAU,cAAc,CAAC,EAAW,KAAK,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,sBAR/tC,IAA4B,IAAoD,CAQipC,EAAoB,EAAwB,CAAC,MAAM,CAAC,KAAK,EAAY,MAAM,MAAM,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAY,OAAO,MAAM,WAAW,aAAa,IAAI,IAAI,EAAE,IAAI,IAAI,KAAK,GAAG,YAAY,mCAAmC,CAAC,CAAC"}