{"version":3,"file":"ParallaxImage_prod.Ddz1g4mL.mjs","names":["useRef","image"],"sources":["https:/framerusercontent.com/modules/zxcGfQb3lPhoJOWc1HTU/UHrEi0qhIpd3yrAh6Rk2/ParallaxImage_prod.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useRef,useLayoutEffect}from\"react\";import{ComponentMessage}from\"https://framer.com/m/Utils-FINc.js\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 400\n * @framerDisableUnlink\n */export default function ImageParallax(props){const{verticalParallaxAmount=50,horizontalParallaxAmount=0,image,style,borderRadius=0,border,boxShadow}=props;// Reference to the container and image elements\nconst containerRef=useRef(null);const imageRef=useRef(null);// Check if we're in canvas mode - if so, skip parallax and just show the image\nconst isCanvas=RenderTarget.current()===RenderTarget.canvas;// Simple, performant parallax using requestAnimationFrame (like many CodePen examples)\n// Only run parallax logic in preview/live mode, not in canvas\nuseLayoutEffect(()=>{// Skip parallax in canvas mode\nif(isCanvas)return;if(!containerRef.current||!imageRef.current)return;const container=containerRef.current;const image=imageRef.current;// Enable hardware acceleration via CSS\nimage.style.transform=\"translate3d(0, 0, 0)\";image.style.willChange=\"transform\";let rafId=null;let ticking=false;let animationFrameId=null;const updateParallax=()=>{if(!container||!image)return;const rect=container.getBoundingClientRect();const containerHeight=container.offsetHeight;const containerWidth=container.offsetWidth;// Skip if container has no dimensions\nif(containerHeight===0||containerWidth===0)return;// Calculate vertical parallax based on scroll position\n// Progress goes from 0 (top hits bottom of viewport) to 1 (bottom hits top of viewport)\n// When element is vertically centered (progress = 0.5), image should be centered\nconst viewportHeight=window.innerHeight;const scrollProgress=Math.max(0,Math.min(1,(viewportHeight-rect.top)/(viewportHeight+containerHeight)));// Vertical parallax: center around midpoint (0.5)\n// When scrollProgress = 0.5 (centered), yOffset = 0\n// When scrollProgress = 0 (top), yOffset = -parallaxAmount/2\n// When scrollProgress = 1 (bottom), yOffset = +parallaxAmount/2\nconst yOffset=(scrollProgress-.5)*(verticalParallaxAmount/100)*containerHeight;// Horizontal parallax: based purely on element's horizontal position in viewport\n// Works independently of scroll - responds to horizontal movement/looping\n// When element is centered, image should be centered (no offset)\nlet xOffset=0;if(horizontalParallaxAmount!==0){const viewportWidth=window.innerWidth;const viewportCenter=viewportWidth/2;const elementCenter=rect.left+rect.width/2;// Calculate progress from -1 (left) to +1 (right), 0 when centered\n// Normalize based on viewport width so it works regardless of element position\nconst horizontalProgress=(elementCenter-viewportCenter)/viewportWidth;// Apply parallax movement based on element position relative to viewport center\n// horizontalProgress: negative when element is left of center, positive when right of center\n// When element is left of center, image shifts left (negative offset)\n// When element is right of center, image shifts right (positive offset)\n// When element is centered (horizontalProgress = 0), xOffset = 0 (image centered)\nxOffset=horizontalProgress*(horizontalParallaxAmount/100)*containerWidth;}// Apply transforms using translate3d for GPU acceleration\nimage.style.transform=`translate3d(${xOffset}px, ${yOffset}px, 0)`;ticking=false;};const requestTick=()=>{if(!ticking){rafId=requestAnimationFrame(updateParallax);ticking=true;}};// Continuous animation loop for horizontal parallax (works with looping elements)\nconst startAnimationLoop=()=>{if(horizontalParallaxAmount!==0){const animate=()=>{updateParallax();animationFrameId=requestAnimationFrame(animate);};animationFrameId=requestAnimationFrame(animate);}};const stopAnimationLoop=()=>{if(animationFrameId!==null){cancelAnimationFrame(animationFrameId);animationFrameId=null;}};// Use passive scroll listener for vertical parallax\nconst handleScroll=()=>{requestTick();};const handleResize=()=>{// Debounce resize\nif(rafId!==null){cancelAnimationFrame(rafId);}rafId=requestAnimationFrame(updateParallax);};// Initial update\nupdateParallax();// Start continuous loop for horizontal parallax if enabled\nstartAnimationLoop();// Add event listeners for vertical parallax\nwindow.addEventListener(\"scroll\",handleScroll,{passive:true});window.addEventListener(\"resize\",handleResize,{passive:true});// Cleanup\nreturn()=>{stopAnimationLoop();if(rafId!==null){cancelAnimationFrame(rafId);}window.removeEventListener(\"scroll\",handleScroll);window.removeEventListener(\"resize\",handleResize);};},[verticalParallaxAmount,horizontalParallaxAmount,isCanvas]);// Check if image is provided\nconst imageSrc=image?.src||(typeof image===\"string\"?image:null);const hasImage=!!imageSrc;return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{...style,position:\"relative\",overflow:\"hidden\",width:\"100%\",height:\"100%\",borderRadius:borderRadius,boxShadow:boxShadow||undefined},children:[hasImage&&/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",zIndex:1e3,height:\"100%\",borderRadius:borderRadius,position:\"absolute\",top:0,left:0,right:0,bottom:0,...border||{}}}),!hasImage?/*#__PURE__*/_jsx(ComponentMessage,{style:{position:\"relative\",width:\"100%\",height:\"100%\",minWidth:0,minHeight:0},title:\"Image Parallax\",subtitle:\"Add an image to create a parallax effect that moves as you scroll\"}):isCanvas?// Canvas mode: simple responsive image, no parallax\n/*#__PURE__*/_jsx(\"img\",{src:imageSrc,alt:\"\",style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",borderRadius:borderRadius,userSelect:\"none\",pointerEvents:\"none\"}}):// Preview/Live mode: render parallax effect\n// Extend beyond boundaries to allow room for parallax movement\n/*#__PURE__*/_jsx(\"div\",{ref:imageRef,style:{position:\"absolute\",// ALWAYS center the image by extending equally on both sides\n// This ensures the image is centered when element is centered, regardless of parallax direction\n// The sign of parallax only affects the direction of movement, not the centering\ntop:`-${Math.abs(verticalParallaxAmount)/2}%`,left:`-${Math.abs(horizontalParallaxAmount)/2}%`,right:`-${Math.abs(horizontalParallaxAmount)/2}%`,bottom:`-${Math.abs(verticalParallaxAmount)/2}%`,// Always use Math.abs so the image is larger than container regardless of direction\nwidth:`calc(100% + ${Math.abs(horizontalParallaxAmount)}%)`,height:`calc(100% + ${Math.abs(verticalParallaxAmount)}%)`,backgroundImage:imageSrc?`url(${imageSrc})`:undefined,backgroundSize:\"cover\",backgroundPosition:image?.positionX&&image?.positionY?`${image.positionX} ${image.positionY}`:\"center\",borderRadius:borderRadius,willChange:\"transform\",backfaceVisibility:\"hidden\",userSelect:\"none\",pointerEvents:\"none\"}})]});}// Default props with descriptive values\nImageParallax.defaultProps={verticalParallaxAmount:50,horizontalParallaxAmount:0};// Property controls with descriptive tooltips and appropriate ranges\naddPropertyControls(ImageParallax,{image:{type:ControlType.ResponsiveImage,title:\"Image\"},// Vertical parallax controls (in percentage)\nverticalParallaxAmount:{type:ControlType.Number,title:\"Parallax Y\",defaultValue:30,step:5,max:100,min:-100,unit:\"%\"},horizontalParallaxAmount:{type:ControlType.Number,title:\"Parallax X\",defaultValue:0,step:5,max:100,min:-100,unit:\"%\",description:\"Only seen if image moves horizontally.\"},border:{// @ts-ignore - ControlType.Border exists but may not be in types\ntype:ControlType.Border,title:\"Border\",optional:true},borderRadius:{// @ts-ignore - ControlType.BorderRadius exists but may not be in types\ntype:ControlType.BorderRadius,title:\"Radius\",defaultValue:0,min:0,max:100,step:1,unit:\"px\"},boxShadow:{// @ts-ignore - ControlType.BoxShadow exists but may not be in types\ntype:ControlType.BoxShadow,title:\"Shadow\"}});ImageParallax.displayName=\"Image Parallax\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ImageParallax\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"400\",\"framerIntrinsicWidth\":\"300\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ParallaxImage_prod.map"],"mappings":"8PAMG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,yBAAuB,GAAG,2BAAyB,EAAE,QAAM,QAAM,eAAa,EAAE,SAAO,aAAW,EAClJ,EAAaA,EAAO,KAAK,CAAO,EAASA,EAAO,KAAK,CACrD,E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