{"version":3,"file":"ScrollFadeText.B5mEqFix.mjs","names":["useRef","useMemo","p"],"sources":["https:/framerusercontent.com/modules/NYhKHL1ELOqonBtjNN6r/2qfZXHJgTk6AUBWZV8Mh/ScrollFadeText.js"],"sourcesContent":["// React component that reveals text word-by-word as user scrolls\n// Uses framer-motion's useScroll and useTransform for smooth scroll-based fade effect\n// Each word starts at configurable opacity and fades to full visibility progressively\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useMemo}from\"react\";import{motion,useScroll,useTransform}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function ScrollFadeText(props){const{text=\"Create beautiful scroll-based animations with smooth word-by-word reveal effects that respond to user interaction.\",initialOpacity=.2,fadeDistance=.3,font,textColor=\"#000000\",backgroundColor=\"transparent\",padding=\"40px\",maxWidth=800,borderRadius=\"0px\",boxShadow=\"none\",animationEndPoint=50,semiboldWords=\"\",regularWords=\"\",mediumWords=\"\"}=props;const containerRef=useRef(null);const{scrollYProgress}=useScroll({target:containerRef,offset:[\"start end\",\"end start\"]});const paragraphs=useMemo(()=>{// Split by line breaks to preserve paragraphs\nconst lines=text.split(/\\n/);let wordIndex=0;return lines.map(line=>{const words=line.split(/\\s+/).filter(word=>word.length>0);const paragraph={words,startIndex:wordIndex};wordIndex+=words.length;return paragraph;});},[text]);const totalWords=useMemo(()=>{return paragraphs.reduce((sum,p)=>sum+p.words.length,0);},[paragraphs]);const semiboldIndices=useMemo(()=>{if(!semiboldWords.trim())return new Set;return new Set(semiboldWords.split(\",\").map(s=>parseInt(s.trim())-1).filter(n=>!isNaN(n)&&n>=0));},[semiboldWords]);const regularIndices=useMemo(()=>{if(!regularWords.trim())return new Set;return new Set(regularWords.split(\",\").map(s=>parseInt(s.trim())-1).filter(n=>!isNaN(n)&&n>=0));},[regularWords]);const mediumIndices=useMemo(()=>{if(!mediumWords.trim())return new Set;return new Set(mediumWords.split(\",\").map(s=>parseInt(s.trim())-1).filter(n=>!isNaN(n)&&n>=0));},[mediumWords]);const isFixedHeight=props?.style&&props.style.height===\"100%\";return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...props.style,position:\"relative\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:padding,backgroundColor:backgroundColor,borderRadius:borderRadius,boxShadow:boxShadow},children:/*#__PURE__*/_jsx(\"div\",{style:{margin:0,maxWidth:`${maxWidth}px`,width:\"100%\",textAlign:font?.textAlign||\"left\"},children:paragraphs.map((paragraph,pIndex)=>{if(paragraph.words.length===0){// Empty line - render as spacing\nreturn null;}return /*#__PURE__*/_jsx(\"p\",{style:{margin:0,...font,color:textColor,textAlign:font?.textAlign||\"left\"},children:paragraph.words.map((word,wIndex)=>{const globalIndex=paragraph.startIndex+wIndex;const wordProgress=globalIndex/totalWords;// Scale the progress based on animationEndPoint (0-100%)\nconst animationRange=animationEndPoint/100;const startFade=Math.max(0,(wordProgress-fadeDistance/4)*animationRange);const endFade=Math.min(animationRange,(wordProgress+fadeDistance/4)*animationRange);const opacity=useTransform(scrollYProgress,[startFade,endFade],[initialOpacity,1]);const isSemibold=semiboldIndices.has(globalIndex);const isRegular=regularIndices.has(globalIndex);const isMedium=mediumIndices.has(globalIndex);return /*#__PURE__*/_jsx(motion.span,{style:{opacity,display:\"inline-block\",marginRight:\"0.3em\",fontWeight:isSemibold?600:isMedium?500:isRegular?400:undefined},children:word},`${word}-${globalIndex}`);})},`p-${pIndex}`);})})});}addPropertyControls(ScrollFadeText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Create beautiful scroll-based animations with smooth word-by-word reveal effects that respond to user interaction.\",displayTextArea:true},semiboldWords:{type:ControlType.String,title:\"Semibold Words\",defaultValue:\"\",placeholder:\"1,3,5\",description:\"Word numbers (comma-separated)\"},regularWords:{type:ControlType.String,title:\"Regular Words\",defaultValue:\"\",placeholder:\"2,4,6\",description:\"Word numbers (comma-separated)\"},mediumWords:{type:ControlType.String,title:\"Medium Words\",defaultValue:\"\",placeholder:\"1,3,5\",description:\"Word numbers (comma-separated)\"},initialOpacity:{type:ControlType.Number,title:\"Initial Opacity\",defaultValue:.2,min:0,max:1,step:.05},fadeDistance:{type:ControlType.Number,title:\"Fade Distance\",defaultValue:.3,min:.1,max:1,step:.05},animationEndPoint:{type:ControlType.Number,title:\"Animation End Point\",defaultValue:50,min:0,max:100,step:5,unit:\"%\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",displayTextAlignment:true,defaultValue:{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.03em\",lineHeight:\"1.2em\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"rgba(0, 0, 0, 0)\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"40px\"},borderRadius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"0px\"},boxShadow:{type:ControlType.BoxShadow,title:\"Shadow\"},maxWidth:{type:ControlType.Number,title:\"Max Width\",defaultValue:800,min:200,max:2e3,step:50,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollFadeText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollFadeText.map"],"mappings":"gPAMG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,OAAK,qHAAqH,iBAAe,GAAG,eAAa,GAAG,OAAK,YAAU,UAAU,kBAAgB,cAAc,UAAQ,OAAO,WAAS,IAAI,eAAa,MAAM,YAAU,OAAO,oBAAkB,GAAG,gBAAc,GAAG,eAAa,GAAG,cAAY,IAAI,EAAY,EAAaA,E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