{"version":3,"file":"GradientTextReveal.DASxPyvb.mjs","names":["useRef","Tag","useState"],"sources":["https:/framerusercontent.com/modules/RxrkhLr7FIWoWgMNuhDe/icpXeFLmUXlnH8kszUWk/GradientTextReveal.js"],"sourcesContent":["// GradientTextReveal.tsx\n// Text that starts blurred and unblurs on scroll, glowing briefly before fading to the final text color.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{motion,useScroll,useTransform,useInView}from\"framer-motion\";import{useRef,useState,useEffect}from\"react\";const EachLetter=({letter,starting,ending,progress,startingBlur,endingBlur,revealColor,textColor,startingColor,fadeAfter=.5,startingOpacity=1,animationMode=\"scroll\",staggerDelay=0,replay=true,isStatic=false})=>{const letterRef=useRef(null);const isInView=useInView(letterRef,{once:!replay,amount:.5});const[hasBeenRevealed,setHasBeenRevealed]=useState(false);const[fadeOut,setFadeOut]=useState(false);// Blur & opacity tied to the letter's scroll window\nconst blurVal=useTransform(progress,[starting,ending],[startingBlur,endingBlur]);const opacityVal=useTransform(progress,[starting,ending],[startingOpacity,1]);const filterVal=useTransform(blurVal,v=>`blur(${v}px)`);// In-view mode: trigger based on viewport visibility\nuseEffect(()=>{if(animationMode!==\"inView\"||isStatic)return;if(isInView){const timer=window.setTimeout(()=>{setHasBeenRevealed(true);},staggerDelay*1e3);return()=>window.clearTimeout(timer);}else{setHasBeenRevealed(false);setFadeOut(false);}},[isInView,animationMode,staggerDelay,isStatic]);// Scroll mode: drive state from scroll\nuseEffect(()=>{if(animationMode!==\"scroll\"||isStatic)return;const EPS=1e-4;const tipEnd=ending;const unsub=progress.onChange(p=>{if(p<=starting+EPS){setHasBeenRevealed(false);setFadeOut(false);return;}if(!hasBeenRevealed&&p>=tipEnd){setHasBeenRevealed(true);}});if(progress.get()<=starting+EPS){setHasBeenRevealed(false);setFadeOut(false);}return()=>unsub();// IMPORTANT: do NOT depend on hasBeenRevealed here\n// eslint-disable-next-line react-hooks/exhaustive-deps\n},[progress,starting,ending,fadeAfter,animationMode,isStatic]);// Fade timer\nuseEffect(()=>{if(!hasBeenRevealed||isStatic)return;setFadeOut(false);const id=window.setTimeout(()=>setFadeOut(true),fadeAfter*1e3);return()=>window.clearTimeout(id);},[hasBeenRevealed,fadeAfter,isStatic]);// Static preview: show final state\nif(isStatic){return /*#__PURE__*/_jsx(motion.span,{style:{filter:`blur(${endingBlur}px)`,opacity:1,color:textColor},children:letter});}const colorVal=!hasBeenRevealed?startingColor:!fadeOut?revealColor:textColor;const colorTransition=hasBeenRevealed&&!fadeOut?\"color 0s linear\":\"color 0.3s linear\";// In-view mode uses CSS transitions\nif(animationMode===\"inView\"){return /*#__PURE__*/_jsx(motion.span,{ref:letterRef,style:{filter:`blur(${hasBeenRevealed?endingBlur:startingBlur}px)`,opacity:hasBeenRevealed?1:startingOpacity,color:colorVal,transition:`${colorTransition}, filter 0.6s ease-out, opacity 0.6s ease-out`,willChange:\"filter, opacity, color\"},children:letter});}// Scroll mode\nreturn /*#__PURE__*/_jsx(motion.span,{style:{filter:filterVal,opacity:opacityVal,color:colorVal,transition:colorTransition,willChange:\"filter, opacity, color\"},children:letter});};/**\n * @framerDisableUnlink\n */export default function GradientTextReveal(props){const{text,font,textColor,startingBlur,endingBlur,scrollSpeed,revealColor=\"#B6FF3B\",startingColor=\"#D9D9D9\",fadeAfter=.5,startingOpacity=1,textTransform=\"inherit\",animationMode=\"scroll\",staggerSpeed=.03,replay=true,textBalance=false,tagType=\"div\"}=props;const isStatic=useIsStaticRenderer();const ref=useRef(null);const startOffset=Math.min(1,Math.max(.5,.9+scrollSpeed*.05));const endOffset=Math.min(.9,Math.max(.1,.6+scrollSpeed*.1));const{scrollYProgress}=useScroll({target:ref,offset:[`start ${startOffset}`,`end ${endOffset}`]});// Prepare a flat list of letters with global indices\nconst allLetters=[];let globalLetterIndex=0;const lines=text.split(\"\\n\").filter(line=>line.trim()!==\"\");lines.forEach((line,lineIdx)=>{const chars=Array.from(line);chars.forEach((char,charIdx)=>{allLetters.push({text:String(char),lineIdx,charIdx,globalIdx:globalLetterIndex});globalLetterIndex++;});});const totalLetters=Math.max(allLetters.length,1);const Tag=tagType;return /*#__PURE__*/_jsx(Tag,{ref:ref,style:{...font,color:textColor,textTransform,textWrap:textBalance?\"balance\":\"wrap\",margin:0},children:lines.map((line,lineIdx)=>{const chars=Array.from(line);return /*#__PURE__*/_jsx(\"div\",{style:{display:\"inline-block\",width:\"100%\"},children:chars.map((char,charIdx)=>{const letterData=allLetters.find(l=>l.lineIdx===lineIdx&&l.charIdx===charIdx);const starting=letterData.globalIdx/totalLetters;const ending=(letterData.globalIdx+1)/totalLetters;return /*#__PURE__*/_jsx(\"span\",{children:/*#__PURE__*/_jsx(EachLetter,{letter:char,starting:starting,ending:ending,progress:scrollYProgress,startingBlur:startingBlur,endingBlur:endingBlur,revealColor:revealColor,textColor:textColor,startingColor:startingColor,fadeAfter:fadeAfter,startingOpacity:startingOpacity,animationMode:animationMode,staggerDelay:letterData.globalIdx*staggerSpeed,replay:replay,isStatic:isStatic})},charIdx);})},lineIdx);})});}addPropertyControls(GradientTextReveal,{font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"128px\",variant:\"Semibold\",letterSpacing:\"-0.03em\",lineHeight:\"1.1em\"}},tagType:{type:ControlType.Enum,title:\"HTML Tag\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\",\"div\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"H4\",\"H5\",\"H6\",\"P\",\"Span\",\"Div\"],defaultValue:\"div\",displaySegmentedControl:false},textTransform:{type:ControlType.Enum,title:\"Text Transform\",options:[\"inherit\",\"uppercase\",\"lowercase\",\"capitalize\"],optionTitles:[\"Inherit\",\"Uppercase\",\"Lowercase\",\"Capitalize\"],defaultValue:\"inherit\",displaySegmentedControl:false},textBalance:{type:ControlType.Boolean,title:\"Text Balance\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},text:{type:ControlType.String,title:\"Text\",defaultValue:\"Animated on scroll\\ntext reveal with\\nhighlight\",displayTextArea:true},startingColor:{type:ControlType.Color,title:\"Start Color\",defaultValue:\"#D9D9D9\"},revealColor:{type:ControlType.Color,title:\"Reveal Color\",defaultValue:\"#B6FF3B\"},textColor:{type:ControlType.Color,title:\"End Colour\",defaultValue:\"#000000\"},animationMode:{type:ControlType.Enum,title:\"Animation Mode\",options:[\"scroll\",\"inView\"],optionTitles:[\"Scroll Speed\",\"In View\"],defaultValue:\"scroll\",displaySegmentedControl:true},scrollSpeed:{type:ControlType.Number,title:\"Scroll Speed\",defaultValue:0,min:-3,max:5,step:.1,displayStepper:true,hidden:({animationMode})=>animationMode!==\"scroll\"},fadeAfter:{type:ControlType.Number,title:\"Fade Delay\",defaultValue:.5,min:.1,max:2,step:.01,unit:\"s\"},staggerSpeed:{type:ControlType.Number,title:\"Stagger Speed\",defaultValue:.03,min:0,max:.2,step:.01,unit:\"s\",hidden:({animationMode})=>animationMode!==\"inView\"},replay:{type:ControlType.Boolean,title:\"Replay\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\",hidden:({animationMode})=>animationMode!==\"inView\"},startingOpacity:{type:ControlType.Number,title:\"Start Opacity\",defaultValue:1,min:0,max:1,step:.01},startingBlur:{type:ControlType.Number,title:\"Starting Blur\",defaultValue:8,min:0,max:20,step:.5,unit:\"px\"},endingBlur:{type:ControlType.Number,title:\"Ending Blur\",defaultValue:0,min:0,max:10,step:.5,unit:\"px\",description:\"Component from [LaunchNow Design](https://launchnow.design/?utm_source=codecomponent)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GradientTextReveal\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GradientTextReveal.map"],"mappings":"sRAaG,SAAwB,EA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