{"version":3,"file":"TextRevealScroll.CI6V2Ina.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/hkfBx4ZJvIqp7K6sbvyU/WucSyBNjgACZnhE45fUY/TextRevealScroll.js"],"sourcesContent":["// Text reveal scroll component that reveals another layer of text as user scrolls down\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef}from\"react\";import{useScroll,useTransform,motion,useInView}from\"framer-motion\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TextRevealScroll(props){const{backgroundText=\"SCROLL TO REVEAL\",revealText=\"AMAZING CONTENT\",backgroundColor=\"#000000\",backgroundTextColor=\"#333333\",revealTextColor=\"#FFFFFF\",backgroundFont,revealFont,alignment=\"center\",revealMode=\"line\",startOffset=0,endOffset=100,lineBreakCharacter=\"|\"}=props;const containerRef=useRef(null);const isInView=useInView(containerRef,{once:false,margin:\"0px\"});const isStatic=useIsStaticRenderer();const{scrollYProgress}=useScroll({target:containerRef,offset:[\"start end\",\"end start\"]});// Transform scroll progress to reveal progress with custom start/end offsets\nconst revealProgress=useTransform(scrollYProgress,[startOffset/100,endOffset/100],[0,100]);// Split text based on reveal mode\nconst splitText=text=>{// First replace custom line break characters with actual line breaks\nconst processedText=text.replace(new RegExp(lineBreakCharacter.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\"),\"g\"),\"\\n\");switch(revealMode){case\"line\":return processedText.split(\"\\n\").map(line=>line||\" \");case\"word\":return processedText.split(/(\\s+)/);case\"letter\":return processedText.split(\"\");default:return[processedText];}};const textParts=splitText(revealText);const backgroundParts=splitText(backgroundText);if(isStatic){return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",backgroundColor,display:\"flex\",alignItems:\"center\",justifyContent:alignment,overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",textAlign:alignment,...revealFont,color:revealTextColor,whiteSpace:\"pre-wrap\",wordBreak:\"break-word\",width:\"100%\"},children:revealText.replace(new RegExp(lineBreakCharacter.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\"),\"g\"),\"\\n\")})});}return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",backgroundColor,display:\"flex\",alignItems:\"center\",justifyContent:alignment,overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:alignment,zIndex:1},children:/*#__PURE__*/_jsx(\"div\",{style:{textAlign:alignment,...backgroundFont,color:backgroundTextColor,whiteSpace:\"pre-wrap\",wordBreak:\"break-word\",width:\"100%\"},children:backgroundText.replace(new RegExp(lineBreakCharacter.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\"),\"g\"),\"\\n\")})}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",textAlign:alignment,...revealFont,color:revealTextColor,whiteSpace:\"pre-wrap\",wordBreak:\"break-word\",zIndex:2,width:\"100%\"},children:textParts.map((part,index)=>{const partProgress=(index+1)/textParts.length*100;return /*#__PURE__*/_jsx(motion.span,{style:{opacity:useTransform(revealProgress,[partProgress-100/textParts.length,partProgress],[0,1]),display:revealMode===\"line\"?\"block\":\"inline\"},children:part===\"\\n\"?/*#__PURE__*/_jsx(\"br\",{}):part},index);})})]});}addPropertyControls(TextRevealScroll,{backgroundText:{type:ControlType.String,title:\"Background Text\",defaultValue:\"SCROLL TO REVEAL\",displayTextArea:true},revealText:{type:ControlType.String,title:\"Reveal Text\",defaultValue:\"AMAZING CONTENT\",displayTextArea:true},lineBreakCharacter:{type:ControlType.String,title:\"Line Break Character\",defaultValue:\"|\",placeholder:\"Enter character to break lines\"},revealMode:{type:ControlType.Enum,title:\"Reveal Mode\",options:[\"line\",\"word\",\"letter\"],optionTitles:[\"Line by Line\",\"Word by Word\",\"Letter by Letter\"],defaultValue:\"line\",displaySegmentedControl:true},backgroundColor:{type:ControlType.Color,title:\"Background Color\",defaultValue:\"#000000\"},backgroundTextColor:{type:ControlType.Color,title:\"Background Text Color\",defaultValue:\"#333333\"},revealTextColor:{type:ControlType.Color,title:\"Reveal Text Color\",defaultValue:\"#FFFFFF\"},backgroundFont:{type:ControlType.Font,title:\"Background Font\",defaultValue:{fontSize:\"48px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1.1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},revealFont:{type:ControlType.Font,title:\"Reveal Font\",defaultValue:{fontSize:\"48px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1.1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},alignment:{type:ControlType.Enum,title:\"Text Alignment\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\",displaySegmentedControl:true},startOffset:{type:ControlType.Number,title:\"Start Offset\",defaultValue:0,min:0,max:100},endOffset:{type:ControlType.Number,title:\"End Offset\",defaultValue:100,min:0,max:100}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextRevealScroll\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextRevealScroll.map"],"mappings":"iQAIG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,iBAAe,mBAAmB,aAAW,kBAAkB,kBAAgB,UAAU,sBAAoB,UAAU,kBAAgB,UAAU,iBAAe,aAAW,YAAU,SAAS,aAAW,OAAO,cAAY,EAAE,YAAU,IAAI,qBAAmB,KAAK,EAAY,EAAaA,EAAO,KAAK,CAAgB,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