{"version":3,"file":"Text_Color_Animation_2.CD28SZXD.mjs","names":["useRef","__esmMin","init_npm_react_18_3_1","de","init_jsx_runtime","c","p","ce","useAnimation","useReducedMotion","init_framer_motion_DhsWWWsN","motion","init_framer_D1IzEvwH","addPropertyControls","ControlType","TextColorAnimation","controls","reducedMotion","textRef","observer","entry","resolve","delay","replays","Duration","color01","fontSize","color02","text","init_Text_Color_Animation_2"],"sources":["https:/framerusercontent.com/modules/zInbedI3XuWzn1PJZSlf/6BWThpXBy9vu7rYOMdY6/Text_Color_Animation_2.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{motion,useAnimation,useReducedMotion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";export default function TextColorAnimation({text,fontSize,fontFamily,fontWeight,textAlign,color01,color02,Duration,delay,replays}){const controls=useAnimation();const reducedMotion=useReducedMotion();const textRef=useRef();useEffect(()=>{if(reducedMotion){controls.set(\"visible\");return;}const observer=new IntersectionObserver(async([entry])=>{if(entry.isIntersecting){await new Promise(resolve=>setTimeout(resolve,delay*800))// delay before animation starts\n;controls.start(\"visible\");}else if(!entry.isIntersecting&&replays){controls.start(\"hidden\");}});observer.observe(textRef.current);return()=>observer.disconnect();},[Duration,controls,color01,delay,replays,reducedMotion]);return /*#__PURE__*/_jsx(\"div\",{style:{fontSize:`${fontSize}px`,fontFamily:fontFamily,fontWeight:fontWeight,width:\"100%\",whiteSpace:\"nowrap\",color:reducedMotion?color02:color01,textAlign:textAlign},ref:textRef,children:/*#__PURE__*/_jsxs(\"span\",{style:{position:\"relative\",display:\"inline-block\"},children:[text,/*#__PURE__*/_jsx(motion.span,{style:{position:\"absolute\",overflow:\"hidden\",whiteSpace:\"nowrap\",color:color02,top:0,left:0,width:\"0%\"},animate:controls,initial:{width:reducedMotion?\"100%\":\"0%\"},variants:{visible:{width:\"100%\"},hidden:{width:\"0%\"}},transition:{duration:Duration},children:text})]})});}addPropertyControls(TextColorAnimation,{text:{type:ControlType.String,defaultValue:\"Hello, World!\"},fontSize:{type:ControlType.Number,defaultValue:16,min:1,max:200,unit:\"px\"},fontFamily:{type:ControlType.String,defaultValue:\"Arial\"},fontWeight:{type:ControlType.Enum,defaultValue:\"400\",options:[\"100\",\"200\",\"300\",\"400\",\"500\",\"600\",\"700\",\"800\",\"900\"]},textAlign:{title:\"Text Align\",type:ControlType.Enum,displaySegmentedControl:true,optionTitles:[\"Left\",\"Center\",\"Right\"],options:[\"left\",\"center\",\"right\"]},color01:{title:\"Color 01\",type:ControlType.Color,defaultValue:\"#333\"},color02:{title:\"Color 02\",type:ControlType.Color,defaultValue:\"#fff\"},Duration:{type:ControlType.Number,defaultValue:1,min:.1,max:10,step:.1},delay:{title:\"Delay\",type:ControlType.Number,defaultValue:0,min:0,max:10,step:.1},replays:{title:\"Replays\",type:ControlType.Boolean,defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextColorAnimation\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Text_Color_Animation_2.map"],"mappings":"A,uPAAiN,SAAwBe,EAAmB,CAAC,OAAK,WAAS,aAAW,aAAW,YAAU,UAAQ,UAAQ,WAAS,QAAM,WAAS,CAAC,IAAMC,EAASR,EAAa,EAAQS,EAAcR,EAAiB,EAAQS,EAAQlB,EAAO,EAChN,OADkNO,MAAc,CAAC,GAAGU,EAAc,CAACD,EAAS,IAAI,SAAS,EAAE,MAAO,CAAC,IAAMG,EAAS,IAAI,qBAAqB,MAAM,CAACC,KAAS,CAAIA,EAAM,gBAAgB,MAAM,IAAI,QAAQ,GAAS,WAAWC,EAAQC,EAAM,GAAG,CAAC,EAC1nBN,EAAS,MAAM,SAAS,GAAW,CAACI,EAAM,gBAAgBG,GAASP,EAAS,MAAM,QAAQ,CAAG,CAAC,EAAoC,OAAlCG,EAAS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