{"version":3,"file":"Lottie_Animation_Trigger.B9JTltvt.mjs","names":["useRef","useState"],"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\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Lottie_Animation_Trigger.map"],"mappings":"6MAAyJ,SAAwB,EAAoB,CAAC,aAAW,QAAM,EAAE,OAAK,GAAM,QAAM,EAAE,YAAU,GAAG,mBAAiB,KAAK,mBAAiB,GAAM,SAAO,CAAC,IAAM,EAAaA,EAAO,IAAI,EAAQ,EAAQA,EAAO,IAA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