{"version":3,"file":"ImageParallaxVertical.IfCuRNqJ.mjs","names":["React.useRef","React.useState","React.useCallback","React.useMemo"],"sources":["https:/framerusercontent.com/modules/tKiwIcg9lyNzGIYNAsFl/4m9QifEsRXnd9HB6I2el/ImageParallaxVertical.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 300\n */export default function ImageParallaxVertical(props){const{image,parallax=200,...rest}=props;const containerRef=React.useRef(null);const frameRef=React.useRef(null);const translateYRef=React.useRef(0);const[translateY,setTranslateY]=React.useState(0);const[ready,setReady]=React.useState(false);const calculateParallax=React.useCallback(()=>{const el=containerRef.current;if(!el)return;const rect=el.getBoundingClientRect();const windowHeight=window.innerHeight;const elementHeight=rect.height;const totalTravel=windowHeight+elementHeight;// raw progress based on element position\nconst rawProgress=(windowHeight-rect.top)/totalTravel;// clamp between 0 and 1\nconst progress=Math.min(1,Math.max(0,rawProgress));const newTranslateY=parallax-progress*parallax;// Only update if there's a meaningful change (prevents unnecessary re-renders)\nif(Math.abs(newTranslateY-translateYRef.current)>.1){translateYRef.current=newTranslateY;setTranslateY(newTranslateY);}},[parallax]);React.useEffect(()=>{if(typeof window===\"undefined\")return;const onScroll=()=>{if(frameRef.current!=null)return;frameRef.current=window.requestAnimationFrame(()=>{frameRef.current=null;calculateParallax();});};window.addEventListener(\"scroll\",onScroll,{passive:true});// initial calculation\ncalculateParallax();setReady(true);return()=>{window.removeEventListener(\"scroll\",onScroll);if(frameRef.current!=null){window.cancelAnimationFrame(frameRef.current);}};},[calculateParallax]);const imageStyle=React.useMemo(()=>({width:\"100%\",height:`calc(100% + ${parallax}px)`,objectFit:\"cover\",transform:`translateY(${-translateY}px)`,willChange:\"transform\"}),[parallax,translateY]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{overflow:\"hidden\",position:\"relative\",backgroundColor:\"#ffffff\",...rest.style},children:image&&ready&&/*#__PURE__*/_jsx(\"img\",{src:image,alt:\"Parallax Image\",style:imageStyle})});}addPropertyControls(ImageParallaxVertical,{image:{type:ControlType.Image,title:\"Image\"},parallax:{type:ControlType.Number,title:\"Parallax\",defaultValue:200,min:0,max:500,step:10,description:\"Component made by Anton Drukarov\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ImageParallaxVertical\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"300\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicHeight\":\"300\",\"framerDisableUnlink\":\"* @framerSupportedLayoutWidth fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ImageParallaxVertical.map"],"mappings":"2MAMG,SAAwB,EAAsB,EAAM,CAAC,GAAK,CAAC,QAAM,WAAS,IAAI,GAAG,GAAM,EAAY,EAAaA,EAAa,IAAI,EAAQ,EAASA,EAAa,IAAI,EAAQ,EAAcA,EAAa,CAAC,EAAO,CAAC,EAAW,GAAeC,EAAe,CAAC,EAAO,CAAC,EAAM,GAAUA,EAAe,EAAK,EAAQ,EAAkBC,MAAsB,CAAC,IAAM,EAAG,EAAa,QAAQ,GAAG,CAAC,EAAG,OAAO,IAAM,EAAK,EAAG,sBAAsB,EAAQ,EAAa,EAAO,YAAkD,EAAY,EAA9B,EAAK,OACpe,GAAa,EAAa,EAAK,KAAK,EACe,EAAc,EAAxD,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,CAAW,CAAuC,EAAE,EACtF,KAAK,IAAI,EAAc,EAAc,OAAO,EAAE,KAAI,EAAc,QAAQ,EAAc,EAAc,CAAa,EAAG,EAAE,CAAC,CAAQ,CAAC,EAAE,MAAoB,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,MAAa,CAAI,AAA8B,E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