{"version":3,"file":"ScrollRevealText.DIo7D26i.mjs","names":["useRef","React"],"sources":["https:/framerusercontent.com/modules/YiynSLQjvAyeyJkzGLou/GV9iN9HfIkg9xIeWfMON/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);})});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\",fontWeight:500}},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\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollRevealText.map"],"mappings":"uPAIG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,OAAK,OAAK,QAAM,aAAW,QAAM,oBAAkB,kBAAgB,QAAM,QAAM,QAAM,iBAAe,iBAAe,kBAAgB,EAAY,EAAIA,EAAO,KAAK,CAAM,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAAI,OAAO,CAAC,SAAS,EAAkB,GAAG,OAAO,EAAgB,GAAG,CAAC,CAAC,CACrS,EAAvB,EAAK,MAAM;EAAK,CAAmB,QAAQ,EAAI,EAAK,IAAY,CACzE,EAAU,GAAG,EAAI,KAAK,CAAC,KAAK,GAAG,YAAY,GAAK,CAAC,CACpD,IAAM,EAAU,EAAK,MAAM,MAAM,CAAC,OAAO,GAAM,EAAK,OAAO,EAAE,CAAC,IAAI,IAAO,CAAM,OAAK,YAAY,GAAM,QAAQ,GAAM,EAAE,CAC5D,OAA1D,EAAU,KAAK,CAAC,KAAK,GAAG,YAAY,GAAM,QAAQ,GAAM,CAAC,CAAO,CAAC,GAAG,EAAI,GAAG,EAAU,EAAG,EAAE,CAAC,CACxF,EAAM,OAAO,GAAG,EAAM,EAAM,OAAO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