{"version":3,"file":"ScrollColorText.BA6eJ19a.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/bosLkPCsBqcroYxKjs8L/mQMK977BGnTYv8u0aZ9N/ScrollColorText.js"],"sourcesContent":["// Animated text color on scroll using Framer Motion's useScroll\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useScroll,useTransform,motion}from\"framer-motion\";/**\n * ScrollColorText\n *\n * Animates text color from grayscale to a selected color as you scroll.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function ScrollColorText(props){const{text,targetColor,font,grayscale,style}=props;const ref=useRef(null);const{scrollYProgress}=useScroll({target:ref,offset:[\"start center\",\"end center\"]});// Split text into words and preserve newlines\nconst lines=text.split(/\\r?\\n/);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...style,...font,background:\"none\",border:\"none\",padding:0,margin:0,display:\"block\",width:style&&style.width?style.width:\"100%\",minHeight:0,minWidth:0,whiteSpace:\"pre-line\"},\"aria-label\":text,children:lines.map((line,lineIdx)=>/*#__PURE__*/_jsx(\"span\",{style:{display:\"block\",width:\"100%\"},children:line.split(/(\\s+)/).map((word,i,arr)=>{// If whitespace, render as is\n    if(/^\\s+$/.test(word))return word;// Calculate wave offset for each word\n    const totalWords=arr.filter(w=>!/^\\s+$/.test(w)).length;const wordIndex=arr.slice(0,i+1).filter(w=>!/^\\s+$/.test(w)).length-1;// Offset the color animation for each word\n    const waveStart=wordIndex/Math.max(1,totalWords);const waveEnd=(wordIndex+1)/Math.max(1,totalWords);const wordColor=useTransform(scrollYProgress,[waveStart,waveEnd],[grayscale,targetColor]);return /*#__PURE__*/_jsx(motion.span,{style:{color:wordColor,display:\"inline-block\",transition:\"color 0.2s\"},children:word},i);})},lineIdx))});}addPropertyControls(ScrollColorText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Scroll to animate color\",displayTextArea:true,placeholder:\"Type your text...\"},grayscale:{type:ControlType.Color,title:\"Grayscale\",defaultValue:\"#888888\"},targetColor:{type:ControlType.Color,title:\"Target Color\",defaultValue:\"#0099FF\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollColorText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollColorText.map"],"mappings":"yOAQG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,OAAK,cAAY,OAAK,YAAU,SAAO,EAAY,EAAIA,EAAO,IAAI,EAAO,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAAI,OAAO,CAAC,eAAe,YAAY,CAAC,CAAC,EACxM,EAAM,EAAK,MAAM,OAAO,EAAE,OAAoB,EAAK,MAAM,CAAK,MAAI,MAAM,CAAC,GAAG,EAAM,GAAG,EAAK,WAAW,OAAO,OAAO,OAAO,QAAQ,EAAE,OAAO,EAAE,QAAQ,QAAQ,MAAM,GAAO,EAAM,MAAM,EAAM,MAAM,OAAO,UAAU,EAAE,SAAS,EAAE,WAAW,UAAU,EAAE,aAAa,EAAK,SAAS,EAAM,KAAK,EAAK,IAAuB,EAAK,OAAO,CAAC,MAAM,CAAC,QAAQ,QAAQ,MAAM,MAAM,EAAE,SAAS,EAAK,MAAM,OAAO,CAAC,CAAC,KAAK,EAAK,EAAE,IAAM,CAC5Z,GAAG,QAAQ,KAAK,CAAI,EAAE,OAAO,EAC7B,IAAM,EAAW,EAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,OAAa,EAAU,EAAI,MAAM,EAA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