{"version":3,"file":"ParallaxImage.B7ELCBpd.mjs","names":["useRef","useState","useCallback","__esmMin","init_ssg_sandbox_shims","te","init_npm_react_18_3_1","_e","de","ne","c","init_jsx_runtime","ce","window","init_framer_B6PCHH0A","addPropertyControls","useIsStaticRenderer","ControlType","ParallaxImage","props","containerRef","imageRef","videoRef","hasTriggeredPosterFallbackRef","isMountedRef","isStatic","showPosterFallback","setShowPosterFallback","posterSrc","posterImage","posterIsAvailable","mediaType","triggerPosterFallback","video","handleScroll","rect","windowHeight","parallaxOffset","speed","finalOffset","direction","scale","image","videoElement","playPromise","init_ParallaxImage"],"sources":["https:/framerusercontent.com/modules/gRhAfrk6pPODYgDFRXz2/JaDxsmn5piiOba28zcjG/ParallaxImage.js"],"sourcesContent":["// Update Workshop/ParallaxImage.tsx to add a video poster image control and fallback behavior while preserving existing API/parallax behavior.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useCallback,useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function ParallaxImage(props){const{mediaType=\"image\",image={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Gradient 1 - Blue\"},video=\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",posterImage,speed,scale,direction}=props;const containerRef=useRef(null);const imageRef=useRef(null);const videoRef=useRef(null);const hasTriggeredPosterFallbackRef=useRef(false);const isMountedRef=useRef(true);const isStatic=useIsStaticRenderer();const[showPosterFallback,setShowPosterFallback]=useState(false);const posterSrc=posterImage?.src||\"\";const posterIsAvailable=mediaType===\"video\"&&posterSrc.length>0;const triggerPosterFallback=useCallback(()=>{if(!posterIsAvailable||hasTriggeredPosterFallbackRef.current)return;hasTriggeredPosterFallbackRef.current=true;startTransition(()=>{if(isMountedRef.current)setShowPosterFallback(true);});},[posterIsAvailable]);useEffect(()=>{isMountedRef.current=true;return()=>{isMountedRef.current=false;};},[]);useEffect(()=>{hasTriggeredPosterFallbackRef.current=false;startTransition(()=>{if(isMountedRef.current)setShowPosterFallback(false);});},[mediaType,video,posterSrc]);useEffect(()=>{if(isStatic)return;const handleScroll=()=>{if(!containerRef.current||!imageRef.current)return;const rect=containerRef.current.getBoundingClientRect();const windowHeight=window.innerHeight;// Only animate if in view\nif(rect.bottom<0||rect.top>windowHeight)return;const scrollProgress=(windowHeight-rect.top)/(windowHeight+rect.height);// Center the progress around 0.5 so the image is centered when the container is centered\nconst parallaxOffset=(scrollProgress-.5)*speed*100;const finalOffset=direction===\"down\"?parallaxOffset:-parallaxOffset;imageRef.current.style.transform=`translateY(${finalOffset}px) scale(${scale})`;};if(typeof window!==\"undefined\"){window.addEventListener(\"scroll\",handleScroll,{passive:true});// Initial calculation\nrequestAnimationFrame(handleScroll);}return()=>{if(typeof window!==\"undefined\"){window.removeEventListener(\"scroll\",handleScroll);}};},[speed,scale,direction,isStatic]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",overflow:\"hidden\",position:\"relative\"},children:/*#__PURE__*/_jsx(\"div\",{ref:imageRef,style:{width:\"100%\",height:\"100%\",transform:`scale(${scale})`,willChange:\"transform\"},children:mediaType===\"image\"?/*#__PURE__*/_jsx(\"img\",{src:image.src,alt:image.alt||\"Parallax image\",style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\"}}):showPosterFallback&&posterIsAvailable?/*#__PURE__*/_jsx(\"img\",{src:posterImage?.src,srcSet:posterImage?.srcSet,alt:posterImage?.alt||\"Video poster\",style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\"}}):/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:video,poster:posterIsAvailable?posterSrc:undefined,autoPlay:true,loop:true,muted:true,playsInline:true,onError:triggerPosterFallback,onLoadedData:()=>{const videoElement=videoRef.current;if(!videoElement)return;const playPromise=videoElement.play();if(playPromise&&typeof playPromise.catch===\"function\"){playPromise.catch(()=>{triggerPosterFallback();});}},style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\"}})})});}addPropertyControls(ParallaxImage,{mediaType:{type:ControlType.Enum,title:\"Media Type\",options:[\"image\",\"video\"],optionTitles:[\"Image\",\"Video\"],defaultValue:\"image\",displaySegmentedControl:true},image:{type:ControlType.ResponsiveImage,title:\"Image\",hidden:({mediaType})=>mediaType!==\"image\"},video:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"webm\",\"mov\"],hidden:({mediaType})=>mediaType!==\"video\"},posterImage:{type:ControlType.ResponsiveImage,title:\"Poster Image\",hidden:({mediaType})=>mediaType!==\"video\"},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"up\",\"down\"],optionTitles:[\"↑ Up\",\"↓ Down\"],defaultValue:\"down\",displaySegmentedControl:true},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:.5,min:-2,max:2,step:.01,displayStepper:true},scale:{type:ControlType.Number,title:\"Scale\",defaultValue:1.2,min:1,max:2,step:.1,displayStepper:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ParallaxImage\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ParallaxImage.map"],"mappings":"A,4NAIG,SAAwBkB,EAAc,EAAM,CAAC,GAAK,CAAC,YAAU,QAAQ,QAAM,CAAC,IAAI,sEAAsE,IAAI,mBAAmB,EAAE,QAAM,uEAAuE,cAAY,QAAM,QAAM,aAAWC,EAAYC,EAAapB,EAAO,IAAI,EAAQqB,EAASrB,EAAO,IAAI,EAAQsB,EAAStB,EAAO,IAAI,EAAQuB,EAA8BvB,EAAO,EAAK,EAAQwB,EAAaxB,EAAO,EAAI,EAAQyB,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