{"version":3,"file":"TextReveal.CUayQscC.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/od9TQtWOOGlaslnj8xra/6mfUy9k4WnoTGn57VVXr/TextReveal.js"],"sourcesContent":["// Text reveal on scroll with color transition from first color to second color\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useScroll,useTransform,motion}from\"framer-motion\";import{useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function TextReveal(props){const{text=\"Scroll to reveal this text\",firstColor=\"#CCCCCC\",secondColor=\"#000000\",font,triggerStart=.9,triggerEnd=.3,style}=props;const containerRef=useRef(null);const{scrollYProgress}=useScroll({target:containerRef,offset:[`start ${triggerStart}`,`start ${triggerEnd}`]});const words=text.split(\" \");const getJustifyContent=()=>{if(font?.textAlign===\"center\")return\"center\";if(font?.textAlign===\"right\")return\"flex-end\";return\"flex-start\";};return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,position:\"relative\",display:\"flex\",flexWrap:\"wrap\",justifyContent:getJustifyContent()},children:words.map((word,index)=>{const start=index/words.length;const end=start+1/words.length;return /*#__PURE__*/_jsx(Word,{word:word,scrollYProgress:scrollYProgress,start:start,end:end,firstColor:firstColor,secondColor:secondColor,font:font,isLast:index===words.length-1},index);})});}function Word({word,scrollYProgress,start,end,firstColor,secondColor,font,isLast}){const opacity=useTransform(scrollYProgress,[start,end],[.3,1]);const color=useTransform(scrollYProgress,[start,end],[firstColor,secondColor]);return /*#__PURE__*/_jsx(motion.span,{style:{...font,color,opacity,marginRight:isLast?0:\"0.25em\"},children:word});}addPropertyControls(TextReveal,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Scroll to reveal this text\",displayTextArea:true},firstColor:{type:ControlType.Color,title:\"First Color\",defaultValue:\"#CCCCCC\"},secondColor:{type:ControlType.Color,title:\"Second Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},triggerStart:{type:ControlType.Number,title:\"Trigger Start\",defaultValue:.9,min:0,max:1,step:.1,displayStepper:true},triggerEnd:{type:ControlType.Number,title:\"Trigger End\",defaultValue:.3,min:0,max:1,step:.1,displayStepper:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextReveal\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextReveal.map"],"mappings":"yOAIG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,6BAA6B,aAAW,UAAU,cAAY,UAAU,OAAK,eAAa,GAAG,aAAW,GAAG,SAAO,EAAY,EAAaA,EAAO,KAAK,CAAM,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAAa,OAAO,CAAC,SAAS,IAAe,SAAS,IAAa,CAAC,CAAC,CAAO,EAAM,EAAK,MAAM,IAAI,CAAO,MAA0B,GAAM,YAAY,SAAe,SAAY,GAAM,YAAY,QAAc,WAAiB,aAAe,OAAoB,EAAK,MAAM,CAAC,IAAI,EAAa,MAAM,CAAC,GAAG,EAAM,SAAS,WAAW,QAAQ,OAAO,SAAS,OAAO,eAAe,GAAmB,CAAC,CAAC,SAAS,EAAM,KAAK,EAAK,IAAQ,CAAC,IAAM,EAAM,EAAM,EAAM,OAAsC,OAAoB,EAAK,EAAK,CAAM,OAAqB,kBAAsB,QAAM,IAA1G,EAAM,EAAE,EAAM,OAA+G,aAAuB,cAAiB,OAAK,OAAO,IAAQ,EAAM,OAAO,EAAE,CAAC,EAAM,EAAG,CAAC,CAAC,CAAE,SAAS,EAAK,CAAC,OAAK,kBAAgB,QAAM,MAAI,aAAW,cAAY,OAAK,UAAQ,CA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