{"version":3,"file":"TextScrollReveal.CSRtyByy.mjs","names":["Fragment"],"sources":["https:/framerusercontent.com/modules/D75h9oxNgJByzSe5UfeV/uTDdtr6in7NWbmAEyfbn/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,fontWeight:\"normal\",...font},transition:transition}):/*#__PURE__*/_jsx(Character,{word:word,wordIndex:wordIndex,numberOfWords:words.length,scrollYProgress:scrollYProgress,minOpacity:minOpacity,maxOpacity:maxOpacity,style:{color,fontWeight:\"normal\",...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\":{\"framerSupportedLayoutWidth\":\"any-prefer\",\"framerIntrinsicWidth\":\"600\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"any-prefer\",\"framerIntrinsicHeight\":\"300\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextScrollReveal.map"],"mappings":"gZAOG,SAAwB,EAAiB,CAAC,OAAK,OAAK,OAAK,QAAM,UAAQ,QAAQ,CAAC,aAAW,aAAW,CAAC,QAAM,OAAO,CAAC,QAAM,MAAI,aAAW,CAAC,CAAC,CAAC,IAAM,EAAU,EAAO,KAAK,CAAM,CAAC,kBAAgB,CAAC,EAAU,CAAC,OAAO,EAAU,OAAO,EAAE,IAAI,KAAS,IAAI,GAAM,CAAC,EAAC,CAAO,EAAM,EAAK,MAAM,IAAI,CAAO,EAAI,EAAQ,MAAoB,GAAK,EAAI,CAAC,IAAI,EAAU,MAAM,CAAC,GAAG,EAAM,UAAU,EAAK,SAAU,EAAC,SAAS,EAAM,IAAI,CAAC,EAAK,IAAiC,EAAKA,EAAS,CAAC,SAAS,AAA2B,EAA3B,IAAO,OAAyB,EAA+N,EAA1N,CAAM,OAAe,YAAU,cAAc,EAAM,OAAuB,kBAA2B,aAAsB,aAAW,MAAM,CAAC,QAAM,WAAW,SAAS,GAAG,CAAK,EAAY,YAAW,EAAqO,AAAC,EAAC,EAAK,EAAU,CAAG,AAAC,EAAC,AAAE,kBAAqrC,AAPtnE,GAAyD,IAAoD,IAAmE,IAAmC,CAOovB,EAAU,CAAC,CAAC,O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