{"version":3,"file":"TextRevealScroll.CF0mcZpC.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/25JEPkKrfa8J9J0EGzti/b4pIXGKBvzwJ7BssPkVy/TextRevealScroll.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef}from\"react\";import{useScroll,useTransform,motion}from\"framer-motion\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";// --- CONSISTENCY STYLES ---\n// Forces identical font rendering on both layers\nconst TEXT_CONSISTENCY_STYLES={fontKerning:\"normal\",fontFeatureSettings:'\"liga\" 0, \"clig\" 0',WebkitFontSmoothing:\"antialiased\",textRendering:\"optimizeLegibility\",whiteSpace:\"pre-wrap\",wordBreak:\"break-word\"};/**\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 isStatic=useIsStaticRenderer();const{scrollYProgress}=useScroll({target:containerRef,offset:[\"start end\",\"end start\"]});const revealProgress=useTransform(scrollYProgress,[startOffset/100,endOffset/100],[0,100]);// Helper to split text\nconst splitText=text=>{const escapedChar=lineBreakCharacter.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");const processedText=text.replace(new RegExp(escapedChar,\"g\"),\"\\n\");switch(revealMode){case\"line\":return processedText.split(\"\\n\").map(line=>line||\" \");case\"word\":return processedText.split(/(\\s+)/).filter(part=>part.length>0);case\"letter\":return processedText.split(\"\");default:return[processedText];}};const textParts=splitText(revealText);const backgroundParts=splitText(backgroundText);// Calculate padding\nconst getPadding=()=>{const basePadding=20;switch(alignment){case\"left\":return{paddingLeft:basePadding,paddingRight:basePadding*3};case\"right\":return{paddingLeft:basePadding*3,paddingRight:basePadding};case\"center\":default:return{paddingLeft:basePadding,paddingRight:basePadding};}};// Common styles for both layers to ensure identical layout\nconst layerStyles={...TEXT_CONSISTENCY_STYLES,textAlign:alignment,width:\"100%\",margin:0,padding:0,// Grid specific: both layers sit in row 1, col 1\ngridArea:\"1 / 1\"};if(isStatic){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",backgroundColor,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",overflow:\"hidden\",...getPadding()},children:/*#__PURE__*/_jsx(\"div\",{style:{...layerStyles,...revealFont,color:revealTextColor},children:revealText.replace(new RegExp(\"\\\\|\",\"g\"),\"\\n\")})});}return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",backgroundColor,// KEY FIX: CSS GRID\n// This forces both children to overlap in the exact same space\ndisplay:\"grid\",placeItems:\"center\",overflow:\"hidden\",...getPadding()},children:[/*#__PURE__*/_jsx(\"div\",{style:{...layerStyles,...backgroundFont,color:backgroundTextColor,zIndex:1,pointerEvents:\"none\"},children:backgroundParts.map((part,index)=>/*#__PURE__*/_jsx(\"span\",{style:{display:revealMode===\"line\"?\"block\":revealMode===\"word\"?\"inline\":\"inline-block\",opacity:1},children:part},index))}),/*#__PURE__*/_jsx(\"div\",{style:{...layerStyles,...revealFont,color:revealTextColor,zIndex:2},children:textParts.map((part,index)=>{const partProgress=(index+1)/textParts.length*100;const prevProgress=partProgress-100/textParts.length;return /*#__PURE__*/_jsx(motion.span,{style:{opacity:useTransform(revealProgress,[prevProgress,partProgress],[0,1]),display:revealMode===\"line\"?\"block\":revealMode===\"word\"?\"inline\":\"inline-block\"},children: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":"wPAKG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,iBAAe,mBAAmB,aAAW,kBAAkB,kBAAgB,UAAU,sBAAoB,UA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