{"version":3,"file":"Recoloring_text.DFGoRVR5.mjs","names":["useRef","useState","__esmMin","window","init_ssg_sandbox_shims","init_npm_react_18_3_1","ce","init_jsx_runtime","c","p","_e","de","useTransform","useScroll","init_framer_motion_DhsWWWsN","motion","addPropertyControls","init_framer_CN96F41L","ControlType","ScrollColorTextComponent","ref","viewportHeight","setViewportHeight","offsetStartPx","scrollStartPx","scrollEndPx","totalLetters","text","words","globalLetterIndex","alignment","lineHeight","font","fontSize","word","start","end","color","scrollYProgress","startColor","endColor","letterIndex","letterSpacing","letter","wordIndex","init_Recoloring_text"],"sources":["https:/framerusercontent.com/modules/MqPHHG3yvOPtRjvhRAXQ/GTXPZSofD81MDcHPbDiK/Recoloring_text.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{motion,useScroll,useTransform}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";import{useRef,useEffect,useState}from\"react\";export default function ScrollColorTextComponent({text,font,fontSize,letterSpacing,lineHeight,alignment,startColor,endColor,scrollStartPx,scrollEndPx}){const ref=useRef(null);const[viewportHeight,setViewportHeight]=useState(0);useEffect(()=>{if(typeof window!==\"undefined\"){setViewportHeight(window.innerHeight);}},[]);const offsetStartPx=viewportHeight+scrollStartPx;const{scrollYProgress}=useScroll({target:ref,offset:[`start ${offsetStartPx}px`,`end ${scrollEndPx}px`]});const allLetters=text?.replace(/\\s+/g,\"\").split(\"\")||[];const totalLetters=allLetters.length||1;const words=text?.split(\" \")||[];let globalLetterIndex=0;return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{textAlign:alignment,whiteSpace:\"normal\",wordWrap:\"break-word\",lineHeight:`${lineHeight}em`,fontFamily:font?.fontFamily||\"sans-serif\",fontWeight:font?.fontWeight||400,fontSize:`${fontSize}px`},children:words.map((word,wordIndex)=>/*#__PURE__*/_jsxs(\"span\",{style:{display:\"inline-block\",whiteSpace:\"nowrap\"},children:[word.split(\"\").map((letter,letterIndex)=>{const start=globalLetterIndex/totalLetters;const end=(globalLetterIndex+1)/totalLetters;globalLetterIndex++;const color=useTransform(scrollYProgress,[start,end],[startColor,endColor]);return /*#__PURE__*/_jsx(motion.span,{style:{color,display:\"inline-block\",whiteSpace:\"pre\",marginRight:letterIndex<word.length-1?`${letterSpacing}em`:undefined},children:letter===\" \"?\"\\xa0\":letter},`${wordIndex}-${letterIndex}`);}),/*#__PURE__*/_jsx(\"span\",{children:\"\\xa0\"})]},wordIndex))});}addPropertyControls(ScrollColorTextComponent,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Скролль, чтобы окрасить каждую букву.\"},font:{type:ControlType.Font,title:\"Font\",defaultFontType:\"sans-serif\",defaultValue:{fontFamily:\"Inter\",fontWeight:400}},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:48,min:10,max:200,unit:\"px\"},letterSpacing:{type:ControlType.Number,title:\"Letter Spacing (em)\",defaultValue:0,min:-.2,max:1,step:.01,unit:\"em\"},lineHeight:{type:ControlType.Number,title:\"Line Height (em)\",defaultValue:1.4,min:.5,max:3,step:.1,unit:\"em\"},alignment:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\"},startColor:{type:ControlType.Color,title:\"Start Color\",defaultValue:\"#000000\"},endColor:{type:ControlType.Color,title:\"End Color\",defaultValue:\"#0070f3\"},scrollStartPx:{type:ControlType.Number,title:\"Scroll Start Offset (px)\",defaultValue:100,min:-500,max:1e3,unit:\"px\"},scrollEndPx:{type:ControlType.Number,title:\"Scroll End Offset (px)\",defaultValue:100,min:-500,max:1e3,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollColorTextComponent\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Recoloring_text.map"],"mappings":"A,4QAAmN,SAAwBmB,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