{"version":3,"file":"Lottie_Animation_Trigger.BtS93HnQ.mjs","names":["useRef","useState","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","window","_e","c","init_jsx_runtime","ce","de","addPropertyControls","init_framer_BWFVvmND","RenderTarget","ControlType","LottieScrollTrigger","containerRef","animRef","hasPlayed","lottieLib","setLottieLib","script","lib","lottieFile","anim","speed","reverseDirection","observer","entry","playAnim","delay","rootMarginBottom","loop","threshold","style","init_Lottie_Animation_Trigger"],"sources":["https:/framerusercontent.com/modules/2sSBrsAm7gKVd980cKyg/G0eLEYLi3hq42LZM2r5S/Lottie_Animation_Trigger.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useState,useEffect}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";export default function LottieScrollTrigger({lottieFile,speed=1,loop=false,delay=0,threshold=.3,rootMarginBottom=-150,reverseDirection=false,style}){const containerRef=useRef(null);const animRef=useRef(null);const hasPlayed=useRef(false);const[lottieLib,setLottieLib]=useState(null);useEffect(()=>{if(window.__lottie_web){setLottieLib(window.__lottie_web);return;}const script=document.createElement(\"script\");script.src=\"https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.12.2/lottie.min.js\";script.onload=()=>{const lib=window.lottie;window.__lottie_web=lib;setLottieLib(lib);};document.head.appendChild(script);},[]);useEffect(()=>{if(!lottieLib||!lottieFile||!containerRef.current)return;if(animRef.current){animRef.current.destroy();animRef.current=null;}hasPlayed.current=false;const anim=lottieLib.loadAnimation({container:containerRef.current,renderer:\"svg\",loop,autoplay:false,path:lottieFile});anim.setSpeed(speed);if(reverseDirection){anim.setDirection(-1);anim.goToAndStop(anim.totalFrames-1,true);}else{anim.goToAndStop(0,true);}animRef.current=anim;const isCanvas=RenderTarget.current()===RenderTarget.canvas;if(isCanvas){anim.play();return()=>{anim.destroy();animRef.current=null;};}const observer=new IntersectionObserver(([entry])=>{if(entry.isIntersecting&&!hasPlayed.current&&animRef.current){hasPlayed.current=true;const playAnim=()=>{if(animRef.current){if(reverseDirection){animRef.current.setDirection(-1);animRef.current.goToAndPlay(animRef.current.totalFrames-1,true);}else{animRef.current.goToAndPlay(0,true);}}};if(delay>0){setTimeout(playAnim,delay*1e3);}else{playAnim();}}},{threshold,rootMargin:`0px 0px ${rootMarginBottom}px 0px`});observer.observe(containerRef.current);return()=>{observer.disconnect();anim.destroy();animRef.current=null;};},[lottieLib,lottieFile,loop,speed,delay,threshold,rootMarginBottom,reverseDirection]);if(!lottieFile){return /*#__PURE__*/_jsx(\"div\",{style:{...style,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"#999\",fontSize:14,fontFamily:\"Inter, sans-serif\",background:\"rgba(255,255,255,0.05)\",borderRadius:8,border:\"1px dashed #555\",width:\"100%\",height:\"100%\",minHeight:100},children:\"Upload a Lottie JSON file\"});}return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,width:\"100%\",height:\"100%\"}});}addPropertyControls(LottieScrollTrigger,{lottieFile:{type:ControlType.File,title:\"Lottie File\",allowedFileTypes:[\"json\"]},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:1,min:.1,max:5,step:.1},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:3,step:.1,description:\"Delay in seconds before playing.\"},threshold:{type:ControlType.Number,title:\"Trigger Point\",defaultValue:.3,min:0,max:1,step:.1,description:\"How much needs to be visible before playing (0–1).\"},rootMarginBottom:{type:ControlType.Number,title:\"Trigger Offset\",defaultValue:-150,min:-500,max:0,step:10,unit:\"px\",description:\"How far inside the viewport before triggering. More negative = later trigger.\"},reverseDirection:{type:ControlType.Boolean,title:\"Reverse Direction\",defaultValue:false,description:\"Play the animation in reverse.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LottieScrollTrigger\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetad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