{"version":3,"file":"LineOnScroll.CBhsva5c.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/AqQNOoedaFc1mhXeWpma/iCpdIgzfzew2xQJ3LxDQ/LineOnScroll.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useRef,useEffect}from\"react\";import{motion,useInView}from\"framer-motion\";export default function SVGPathAnimator(props){const ref=useRef(null);const isInView=useInView(ref,{once:props.triggerOnce,margin:props.margin});const[isHovered,setIsHovered]=useState(false);const[isClicked,setIsClicked]=useState(false);const[scrollProgress,setScrollProgress]=useState(0);const[parentAbsoluteTop,setParentAbsoluteTop]=useState(null);useEffect(()=>{if(ref.current&&parentAbsoluteTop===null){let targetParent=ref.current;let largestParent=targetParent;let largestHeight=0;if(props.parentLevelsUp&&props.parentLevelsUp>0){for(let i=0;i<props.parentLevelsUp;i++){if(targetParent.parentElement){targetParent=targetParent.parentElement;}}largestParent=targetParent;}else{for(let i=0;i<10;i++){if(targetParent.parentElement){targetParent=targetParent.parentElement;if(targetParent.offsetHeight>largestHeight){largestHeight=targetParent.offsetHeight;largestParent=targetParent;}console.log(`Level ${i+1}: ${targetParent.className||\"no-class\"} - height: ${targetParent.offsetHeight}px`);}else{break;}}}console.log(\"Selected parent:\",largestParent);console.log(\"Parent height:\",largestParent.offsetHeight);console.log(\"Parent className:\",largestParent.className);const rect=largestParent.getBoundingClientRect();const absoluteTop=window.scrollY+rect.top;setParentAbsoluteTop(absoluteTop);}},[parentAbsoluteTop,props.parentLevelsUp]);useEffect(()=>{if(props.trigger!==\"scroll-progress\")return;const handleScroll=()=>{if(!ref.current)return;if(props.scrollReference===\"viewport\"){if(parentAbsoluteTop===null)return;let targetParent=ref.current;let largestParent=targetParent;let largestHeight=0;if(props.parentLevelsUp&&props.parentLevelsUp>0){for(let i=0;i<props.parentLevelsUp;i++){if(targetParent.parentElement){targetParent=targetParent.parentElement;}}largestParent=targetParent;}else{for(let i=0;i<10;i++){if(targetParent.parentElement){targetParent=targetParent.parentElement;if(targetParent.offsetHeight>largestHeight){largestHeight=targetParent.offsetHeight;largestParent=targetParent;}}else{break;}}}const parentElement=largestParent;const currentScrollY=window.scrollY;const viewportHeight=window.innerHeight;const parentHeight=parentElement.offsetHeight;const animationStart=parentAbsoluteTop-viewportHeight;const animationEnd=parentAbsoluteTop+parentHeight;const totalDistance=animationEnd-animationStart;let progress=0;if(currentScrollY<=animationStart){progress=0;}else if(currentScrollY>=animationEnd){progress=1;}else{const scrolledDistance=currentScrollY-animationStart;progress=scrolledDistance/totalDistance;}progress*=props.scrollSpeed||1;progress=Math.min(Math.max(progress,0),1);setScrollProgress(progress);}else{const scrollTop=window.scrollY;const docHeight=document.body.scrollHeight-window.innerHeight;const progress=Math.min(Math.max(scrollTop/docHeight,0),1);setScrollProgress(progress);}};handleScroll();window.addEventListener(\"scroll\",handleScroll);return()=>window.removeEventListener(\"scroll\",handleScroll);},[props.trigger,props.scrollReference,props.scrollSpeed,props.parentLevelsUp,parentAbsoluteTop]);const viewBoxValues=props.viewBox.split(\" \");const width=parseFloat(viewBoxValues[2])*props.scale;const height=parseFloat(viewBoxValues[3])*props.scale;const shouldAnimate=props.trigger===\"scroll\"&&isInView||props.trigger===\"hover\"&&isHovered||props.trigger===\"click\"&&isClicked||props.trigger===\"loop\";return /*#__PURE__*/_jsx(motion.svg,{ref:ref,width:width,height:height,viewBox:props.viewBox,fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",onMouseEnter:()=>setIsHovered(true),onMouseLeave:()=>setIsHovered(false),onClick:()=>setIsClicked(!isClicked),style:{cursor:props.trigger===\"click\"?\"pointer\":\"default\",transform:`scale(${props.scale})`,transformOrigin:\"center\"},children:/*#__PURE__*/_jsx(motion.path,{d:props.path,stroke:props.strokeColor,strokeWidth:props.strokeWidth,strokeLinecap:\"round\",strokeLinejoin:\"round\",fill:\"none\",initial:{pathLength:0},animate:{pathLength:props.trigger===\"scroll-progress\"?scrollProgress:shouldAnimate?1:0},transition:{duration:props.trigger===\"scroll-progress\"?0:props.duration,delay:props.delay,ease:props.ease,repeat:props.trigger===\"loop\"?Infinity:0}})});}addPropertyControls(SVGPathAnimator,{path:{type:ControlType.String,defaultValue:\"M10 80 C40 10, 65 10, 95 80 S150 150, 180 80\",title:\"SVG Path\"},strokeColor:{type:ControlType.Color,defaultValue:\"#000\",title:\"Stroke Color\"},strokeWidth:{type:ControlType.Number,defaultValue:2,title:\"Stroke Width\"},viewBox:{type:ControlType.String,defaultValue:\"0 0 200 200\",title:\"ViewBox\"},scale:{type:ControlType.Number,defaultValue:1,min:.1,max:5,step:.1,title:\"Scale Factor\"},duration:{type:ControlType.Number,defaultValue:2,title:\"Duration\"},delay:{type:ControlType.Number,defaultValue:0,title:\"Delay\"},ease:{type:ControlType.Enum,options:[\"linear\",\"easeIn\",\"easeOut\",\"easeInOut\",\"anticipate\",\"backIn\",\"backOut\"],defaultValue:\"easeOut\",title:\"Easing\"},trigger:{type:ControlType.Enum,options:[\"scroll\",\"hover\",\"click\",\"loop\",\"mouse\",\"scroll-progress\"],defaultValue:\"scroll\",title:\"Trigger Type\"},scrollReference:{type:ControlType.Enum,options:[\"page\",\"viewport\"],defaultValue:\"page\",title:\"Scroll Reference\",hidden(props){return props.trigger!==\"scroll-progress\";}},scrollSpeed:{type:ControlType.Number,defaultValue:1,min:.1,max:5,step:.1,title:\"Scroll Speed\",hidden(props){return props.trigger!==\"scroll-progress\"||props.scrollReference!==\"viewport\";}},triggerOnce:{type:ControlType.Boolean,defaultValue:true,title:\"Trigger Once (For Scroll)\"},margin:{type:ControlType.String,defaultValue:\"0px\",title:\"Scroll Trigger Margin\"},parentLevelsUp:{type:ControlType.Number,defaultValue:0,min:0,max:10,step:1,title:\"Parent Levels Up (0 = auto-find largest)\",hidden(props){return props.trigger!==\"scroll-progress\"||props.scrollReference!==\"viewport\";}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"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