{"version":3,"file":"Animator_Basic_With_Scroll.Dhee-CKS.mjs","names":["useRef","gsap","ScrollTrigger","Children"],"sources":["https:/framerusercontent.com/modules/ajGLABYIBW2MU6z57vVr/8yTfUsDC9fUMHoS8oOys/Animator_Basic_With_Scroll.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useLayoutEffect,Children}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import gsap from\"gsap\";import{ScrollTrigger}from\"gsap/ScrollTrigger\";gsap.registerPlugin(ScrollTrigger);export default function Animator(props){const{animate,slots=[],start,end,scrub}=props;const pathRef=useRef(null);const triggerRef=useRef(null);useLayoutEffect(()=>{if(!animate)return;if(RenderTarget.current()===RenderTarget.canvas)return;const pathEl=pathRef.current;if(!pathEl)return;let length=0;try{length=pathEl.getTotalLength();}catch{return;}pathEl.style.strokeDasharray=String(length);pathEl.style.strokeDashoffset=String(length);const ctx=gsap.context(()=>{const tween=gsap.fromTo(pathEl,{strokeDashoffset:length},{strokeDashoffset:0,ease:\"none\",duration:1});const scrubValue=Number(scrub);triggerRef.current=ScrollTrigger.create({trigger:pathEl,start:start||\"top 50%\",end:end||\"bottom 50%\",scrub:scrubValue>0?scrubValue:false,animation:tween,toggleActions:\"play none none none\"});});return()=>{triggerRef.current?.kill();triggerRef.current=null;ctx.revert();};},[animate,start,end,scrub]);const hasChildren=Children.count(slots)>0;if(!hasChildren){return /*#__PURE__*/_jsxs(\"div\",{style:placeholderStyles,children:[/*#__PURE__*/_jsx(\"div\",{style:emojiStyles,children:\"✍️\"}),/*#__PURE__*/_jsx(\"p\",{style:titleStyles,children:\"Connect to Graphic\"}),/*#__PURE__*/_jsx(\"p\",{style:subtitleStyles,children:\"Animates single or joined paths on Web Pages only.\"})]});}const firstChild=getFirstChild(slots);const svgChild=getFirstChild(firstChild?.props?.svg);if(!svgChild||RenderTarget.current()===RenderTarget.canvas){return firstChild;}const attributes=svgChild.match(/[\\w-]+=\"[^\"]*\"/g)||[];let pathD,stroke,strokeWidth,strokeLinecap,strokeLinejoin;for(const attr of attributes){if(attr.includes(\"d=\"))pathD=splitAndReplace(attr);if(attr.includes(\"stroke=\"))stroke=splitAndReplace(attr);if(attr.includes(\"stroke-width=\"))strokeWidth=splitAndReplace(attr);if(attr.includes(\"stroke-linecap=\"))strokeLinecap=splitAndReplace(attr);if(attr.includes(\"stroke-linejoin=\"))strokeLinejoin=splitAndReplace(attr);}const viewBoxMatch=svgChild.match(/viewBox=\"([^\"]+)\"/);const svgViewbox=viewBoxMatch?.[1];const safeStroke=stroke||\"currentColor\";const safeStrokeWidth=strokeWidth||2;return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",display:\"flex\",placeContent:\"center\",placeItems:\"center\",backgroundColor:\"transparent\",overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",width:\"100%\",height:\"100%\",viewBox:svgViewbox,preserveAspectRatio:\"xMidYMid meet\",children:/*#__PURE__*/_jsx(\"path\",{ref:pathRef,d:pathD,stroke:safeStroke,strokeWidth:safeStrokeWidth,strokeLinejoin:strokeLinejoin,strokeLinecap:strokeLinecap,fill:\"transparent\"})})});}// Defaults\nAnimator.defaultProps={animate:true,start:\"top 50%\",end:\"bottom 50%\",scrub:.5};// Property Controls\naddPropertyControls(Animator,{slots:{type:ControlType.ComponentInstance,title:\"Children\"},animate:{title:\"Animate\",type:ControlType.Boolean,defaultValue:Animator.defaultProps.animate,enabledTitle:\"True\",disabledTitle:\"False\"},start:{title:\"Start\",type:ControlType.String,defaultValue:Animator.defaultProps.start,placeholder:\"e.g. top 60%\"},end:{title:\"End\",type:ControlType.String,defaultValue:Animator.defaultProps.end,placeholder:\"e.g. bottom 40%\"},scrub:{title:\"Scrub\",type:ControlType.Number,defaultValue:Animator.defaultProps.scrub,min:0,step:.1,displayStepper:true}});// Helpers\nconst splitAndReplace=str=>str.split(\"=\")[1].replace(/['\"]+/g,\"\");function getFirstChild(slots){let firstChild;Children.map(slots,child=>{if(firstChild===undefined)firstChild=child;});return firstChild;}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Animator\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Animator_Basic_With_Scroll.map"],"mappings":"6QAAqR,SAAwB,EAAS,EAAM,CAAC,GAAK,CAAC,UAAQ,QAAM,EAAE,CAAC,QAAM,MAAI,SAAO,EAAY,EAAQA,EAAO,KAAK,CAAO,EAAWA,EAAO,KAAK,CAA8xB,GAA7xB,MAAoB,CAAoB,GAAhB,CAAC,GAAkB,EAAa,SAAS,GAAG,EAAa,OAAO,OAAO,IAAM,EAAO,EAAQ,QAAQ,GAAG,CAAC,EAAO,OAAO,IAAI,EAAO,EAAE,GAAG,CAAC,EAAO,EAAO,gBAAgB,MAAO,CAAC,OAAQ,EAAO,MAAM,gBAAgB,OAAO,EAAO,CAAC,EAAO,MAAM,iBAAiB,OAAO,EAAO,CAAC,IAAM,EAAIC,EAAK,YAAY,CAAC,IAAM,EAAMA,EAAK,OAAO,EAAO,CAAC,iBAAiB,EAAO,CAAC,CAAC,iBAAiB,EAAE,KAAK,OAAO,SAAS,EAAE,CAAC,CAAO,EAAW,OAAO,EAAM,CAAC,EAAW,QAAQC,EAAc,OAAO,CAAC,QAAQ,EAAO,MAAM,GAAO,UAAU,IAAI,GAAK,aAAa,MAAM,EAAW,EAAE,EAAW,GAAM,UAAU,EAAM,cAAc,sBAAsB,CAAC,EAAG,CAAC,UAAU,CAAC,EAAW,SAAS,MAAM,CAAC,EAAW,QAAQ,KAAK,EAAI,QAAQ,GAAK,CAAC,EAAQ,EAAM,EAAI,EAAM,CAAC,CAA8C,EAA3BC,EAAS,MAAM,EAAM,CAAC,GAAmB,OAAoB,EAAM,MAAM,CAAC,MAAM,kBAAkB,SAAS,CAAc,EAAK,M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