{"version":3,"file":"TextScrollReveal.DnvaUmcD.mjs","names":["useRef","Tag","Fragment","__esmMin","init_npm_react_18_3_1","x","de","init_jsx_runtime","c","p","motion","useScroll","useTransform","init_framer_motion_DbYmcygs","useSpring","addPropertyControls","ControlType","init_framer_iLM2NxCW","TextScrollReveal","container","start","end","words","text","htmlTag","style","font","type","Word","Character","word","wordIndex","init_TextScrollReveal","wordStart","numberOfWords","wordEnd","charStart","charIndex","charEnd","scaleY","scrollYProgress","transition","opacity","minOpacity","maxOpacity","char"],"sources":["https:/framerusercontent.com/modules/Z31MPLIICwc4hRXdJUtr/1zwTLIKY1GHwcA8AStJZ/TextScrollReveal.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useScroll,useTransform,useSpring}from\"framer-motion\";import{useRef,Fragment}from\"react\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer\n * @framerIntrinsicWidth 600\n * @framerSupportedLayoutHeight any-prefer\n * @framerIntrinsicHeight 300\n */export default function TextScrollReveal({text,type,font,color,htmlTag,opacity:{minOpacity,maxOpacity},style,appear:{start,end,transition}}){const container=useRef(null);const{scrollYProgress}=useScroll({target:container,offset:[`0 ${start}`,`0 ${end}`]});const words=text.split(\" \");const Tag=htmlTag;return /*#__PURE__*/_jsx(Tag,{ref:container,style:{...style,textAlign:font.textAlign},children:words.map((word,wordIndex)=>{return /*#__PURE__*/_jsx(Fragment,{children:type===\"word\"?/*#__PURE__*/_jsx(Word,{word:word,wordIndex:wordIndex,numberOfWords:words.length,scrollYProgress:scrollYProgress,minOpacity:minOpacity,maxOpacity:maxOpacity,style:{color,...font},transition:transition}):/*#__PURE__*/_jsx(Character,{word:word,wordIndex:wordIndex,numberOfWords:words.length,scrollYProgress:scrollYProgress,minOpacity:minOpacity,maxOpacity:maxOpacity,style:{color,...font},transition:transition})},word+wordIndex);})});}const Character=({word,wordIndex,numberOfWords,scrollYProgress,minOpacity,maxOpacity,style,transition})=>{const wordStart=wordIndex/numberOfWords;const wordEnd=wordStart+1/numberOfWords;return /*#__PURE__*/_jsxs(motion.span,{style:style,children:[word.split(\"\").map((char,charIndex)=>{const charStart=wordStart+charIndex/word.length*(wordEnd-wordStart);const charEnd=wordStart+(charIndex+1)/word.length*(wordEnd-wordStart);const scaleY=useSpring(scrollYProgress,transition);const opacity=useTransform(scaleY,[charStart,charEnd],[minOpacity,maxOpacity]);return /*#__PURE__*/_jsx(motion.span,{style:{opacity,...style},children:char},`${wordIndex}-${charIndex}`);}),wordIndex<numberOfWords-1&&\" \"]},word+wordIndex);};const Word=({word,wordIndex,numberOfWords,scrollYProgress,minOpacity,maxOpacity,style,transition})=>{const wordStart=wordIndex/numberOfWords;const wordEnd=wordStart+1/numberOfWords;const scaleY=useSpring(scrollYProgress,transition);const opacity=useTransform(scaleY,[wordStart,wordEnd],[minOpacity,maxOpacity]);return /*#__PURE__*/_jsxs(motion.span,{style:{opacity,...style},children:[word,wordIndex<numberOfWords-1&&\" \"]},word+wordIndex);};TextScrollReveal.displayName=\"Text Scroll Reveal\";addPropertyControls(TextScrollReveal,{text:{title:\"Text\",type:ControlType.String,displayTextArea:true,defaultValue:\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\"},htmlTag:{type:ControlType.Enum,title:\"Tag\",defaultValue:\"h1\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"span\",\"p\"],optionTitles:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"span\",\"p\"]},type:{title:\"Type\",type:ControlType.Enum,defaultValue:\"word\",options:[\"word\",\"character\"],optionTitles:[\"Word\",\"Character\"]},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\"},color:{title:\"Color\",type:ControlType.Color,defaultValue:\"#000\"},opacity:{title:\"Opacity\",type:ControlType.Object,controls:{minOpacity:{title:\"Min\",type:ControlType.Number,defaultValue:.2,min:0,max:1,step:.1,displayStepper:true},maxOpacity:{title:\"Max\",type:ControlType.Number,defaultValue:1,min:0,max:1,step:.1,displayStepper:true}}},appear:{title:\"Appear\",type:ControlType.Object,controls:{start:{title:\"Start\",type:ControlType.Enum,defaultValue:\"1\",options:[\"1\",\"0.75\",\"0.5\"],optionTitles:[\"Bottom\",\"Bottom/Center\",\"Center\"]},end:{title:\"End\",type:ControlType.Enum,defaultValue:\"0\",options:[\"0\",\"0.25\",\"0.5\"],optionTitles:[\"Top\",\"Top/Center\",\"Center\"]},transition:{title:\"Transition\",type:ControlType.Transition}},description:\"Full tutorial on [FramerMart](https://framermart.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextScrollReveal\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"any-prefer\",\"framerSupportedLayoutWidth\":\"any-prefer\",\"framerIntrinsicWidth\":\"600\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"300\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextScrollReveal.map"],"mappings":"A,kQAOG,SAAwBkB,EAAiB,CAAC,OAAK,OAAK,OAAK,QAAM,UAAQ,QAAQ,CAAC,aAAW,cAAY,QAAM,OAAO,CAAC,QAAM,MAAI,eAAa,CAAC,IAAMC,EAAUnB,EAAO,IAAI,EAAO,CAAC,mBAAiBW,EAAU,CAAC,OAAOQ,EAAU,OAAO,CAAC,KAAKC,IAAQ,KAAKC,GAAK,CAAC,CAAC,EAAQC,EAAMC,EAAK,MAAM,GAAG,EAAoB,MAAoB,gBAAKtB,EAAI,CAAC,IAAIkB,EAAU,MAAM,CAAC,GAAGM,EAAM,UAAUC,EAAK,SAAS,EAAE,SAASJ,EAAM,KAAK,EAAK,IAAiC,gBAAKpB,EAAS,CAAC,SAAoCM,EAA3BmB,IAAO,OAAyBC,EAA2MC,EAAtM,CAA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