{"version":3,"file":"ScrollRevealText.CcXCJi-e.mjs","names":["useRef","_jsx","React"],"sources":["https:/framerusercontent.com/modules/6okMC5CekN9cj5UPfUn1/TspgXcjg1FOakKt1IAVw/ScrollRevealText.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import React,{useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useScroll,useTransform}from\"framer-motion\";/**\n * Text reveal on scroll component\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function ScrollRevealText(props){const{text,font,color,lineHeight,style,scrollOffsetStart,scrollOffsetEnd,slot1,slot2,slot3,slot1WordIndex,slot2WordIndex,slot3WordIndex}=props;const ref=useRef(null);const{scrollYProgress}=useScroll({target:ref,offset:[`start ${scrollOffsetStart}%`,`end ${scrollOffsetEnd}%`]});// Split text into words and line breaks, preserving spaces and line endings\nconst lines=text.split(\"\\n\");const words=lines.reduce((acc,line,lineIndex)=>{// Add line break between lines\nif(lineIndex>0){acc.push({word:\"\",isLineBreak:true});}// Split line into words, preserving spaces\nconst lineWords=line.split(/\\s+/).filter(word=>word.length>0).map(word=>({word:word,isLineBreak:false,isSpace:false}));// Add an empty word at the end of each line\nlineWords.push({word:\"\",isLineBreak:false,isSpace:false});return[...acc,...lineWords];},[]);// Remove the last empty word if it's not needed\nif(words.length>0&&words[words.length-1].word===\"\"){words.pop();}const opacities=words.map((_,i)=>{const start=i/words.length;const end=start+1/words.length;return useTransform(scrollYProgress,[start,end],[.2,1]);});const slotOpacities=[useTransform(scrollYProgress,[slot1WordIndex/words.length,(slot1WordIndex+1)/words.length],[.2,1]),useTransform(scrollYProgress,[slot2WordIndex/words.length,(slot2WordIndex+1)/words.length],[.2,1]),useTransform(scrollYProgress,[slot3WordIndex/words.length,(slot3WordIndex+1)/words.length],[.2,1])];const isFixedWidth=style?.width===\"100%\";const getSlotAtIndex=index=>{const slots=[];if(slot1&&slot1WordIndex===index)slots.push(/*#__PURE__*/_jsx(motion.span,{style:{display:\"inline-flex\",alignItems:\"center\",margin:\"0 4px\",opacity:slotOpacities[0]},children:slot1},\"slot1\"));if(slot2&&slot2WordIndex===index)slots.push(/*#__PURE__*/_jsx(motion.span,{style:{display:\"inline-flex\",alignItems:\"center\",margin:\"0 4px\",opacity:slotOpacities[1]},children:slot2},\"slot2\"));if(slot3&&slot3WordIndex===index)slots.push(/*#__PURE__*/_jsx(motion.span,{style:{display:\"inline-flex\",alignItems:\"center\",margin:\"0 4px\",opacity:slotOpacities[2]},children:slot3},\"slot3\"));return slots;};const textElement=/*#__PURE__*/_jsx(\"div\",{ref:ref,style:{position:\"relative\",display:\"flex\",flexWrap:\"wrap\",alignItems:\"center\",gap:\"0.3em 0.4em\"},children:words.map((word,i)=>{const wordObj=words[i];if(wordObj.isLineBreak){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:`${lineHeight}em`}},`break-${i}`);}const slotsAtIndex=getSlotAtIndex(i);return /*#__PURE__*/_jsxs(React.Fragment,{children:[/*#__PURE__*/_jsx(motion.span,{style:{position:\"relative\",...font,color,opacity:opacities[i]},children:wordObj.word}),slotsAtIndex,i<words.length-1&&!words[i+1]?.isLineBreak&&/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"pre\"},children:\" \"})]},i);})});return textElement;}addPropertyControls(ScrollRevealText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Scroll to reveal\\nthis text on\\nmultiple lines\",displayTextArea:true},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:32,letterSpacing:0,textAlign:\"left\",variant:\"Medium\"}},lineHeight:{type:ControlType.Number,title:\"Line Height\",defaultValue:1.2,min:.8,max:3,step:.1,displayStepper:true},scrollOffsetStart:{type:ControlType.Number,title:\"Scroll Start\",defaultValue:20,min:0,max:100,step:1,displayStepper:true},scrollOffsetEnd:{type:ControlType.Number,title:\"Scroll End\",defaultValue:20,min:0,max:100,step:1,displayStepper:true},slot1:{type:ControlType.Slot,title:\"Slot 1\"},slot2:{type:ControlType.Slot,title:\"Slot 2\"},slot3:{type:ControlType.Slot,title:\"Slot 3\"},slot1WordIndex:{type:ControlType.Number,title:\"Slot 1 Word Position\",defaultValue:2,min:0,step:1,displayStepper:true},slot2WordIndex:{type:ControlType.Number,title:\"Slot 2 Word Position\",defaultValue:4,min:0,step:1,displayStepper:true},slot3WordIndex:{type:ControlType.Number,title:\"Slot 3 Word Position\",defaultValue:6,min:0,step:1,displayStepper:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollRevealText\",\"slots\":[\"slot1\",\"slot2\",\"slot3\"],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollRevealText.map"],"mappings":"wPAIG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,OAAK,OAAK,QAAM,aAAW,QAAM,oBAAkB,kBAAgB,QAAM,QAAM,QAAM,iBAAe,iBAAe,kBAAgB,EAAY,EAAIA,EAAO,IAAI,EAAO,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAAI,OAAO,CAAC,SAAS,EAAkB,GAAG,OAAO,EAAgB,EAAE,CAAC,CAAC,EACpS,EAAvB,EAAK,MAAM;CAAsB,CAAC,CAAC,QAAQ,EAAI,EAAK,IAAY,CACzE,EAAU,GAAG,EAAI,KAAK,CAAC,KAAK,GAAG,YAAY,EAAI,CAAC,EACnD,IAAM,EAAU,EAAK,MAAM,KAAK,CAAC,CAAC,OAAO,GAAM,EAAK,OAAO,CAAC,CAAC,CAAC,IAAI,IAAO,CAAM,OAAK,YAAY,GAAM,QAAQ,EAAK,EAAE,EAC3D,OAA1D,EAAU,KAAK,CAAC,KAAK,GAAG,YAAY,GAAM,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