{"version":3,"file":"ScrollColorText.Clcn2D11.mjs","names":["useRef","useState","__esmMin","init_ssg_sandbox_shims","te","window","_e","de","init_npm_react_18_3_1","ce","addPropertyControls","init_framer_DDfsYcI0","useIsStaticRenderer","ControlType","ScrollColorText","props","ref","progress","setProgress","isStatic","parts","text","wordCount","p","raf","measure","el","r","vh","start","end","total","clamped","onScroll","accentIdx","norm","w","words","phrase","accentText","i","j","lit","balance","balanced","idx","font","style","accentColor","finalColor","initialColor","k","init_ScrollColorText","init_jsx_runtime"],"sources":["https:/framerusercontent.com/modules/MXsSJGhHNhSxEkp3mPQL/u2eLTwcY4mR1sC7DKZDU/ScrollColorText.js"],"sourcesContent":["// Scroll Color Text: verbatim port of the reference component (the reference site, module IU8FaHrLx).\n// Each word goes from initialColor to finalColor as the paragraph scrolls from 85% to 35% of the viewport.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight auto\n * @framerIntrinsicWidth 800\n */export default function ScrollColorText(props){const{text=\"As you scroll through this text, each word gradually shifts from the starting color to the final color, revealing the message word by word.\",initialColor=\"rgba(0, 0, 0, 0.2)\",finalColor=\"#000000\",font,balanced=false,accentText=\"\",accentColor=\"#0369A1\",style}=props;const ref=useRef(null);const[progress,setProgress]=useState(0);const isStatic=useIsStaticRenderer();const parts=text.split(/(\\s+)/);const wordCount=parts.filter(p=>p.trim().length>0).length;useEffect(()=>{if(isStatic||typeof window===\"undefined\")return;let raf=0;const measure=()=>{raf=0;const el=ref.current;if(!el)return;const r=el.getBoundingClientRect();const vh=window.innerHeight||1;const start=vh*.85;const end=vh*.35;const total=r.height+(start-end);const p=total>0?(start-r.top)/total:0;const clamped=Math.min(1,Math.max(0,p));startTransition(()=>setProgress(clamped));};const onScroll=()=>{raf||=window.requestAnimationFrame(measure);};measure();window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",onScroll,{passive:true});return()=>{window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",onScroll);raf&&window.cancelAnimationFrame(raf);};},[isStatic]);// Accent: words belonging to the accentText phrase get accentColor once revealed.\nconst accentIdx=new Set;const norm=w=>w.toLowerCase().replace(RegExp(\"[^\\\\p{L}\\\\p{N}]+\",\"gu\"),\"\");const words=parts.filter(p=>p.trim().length>0).map(norm);const phrase=accentText.split(/\\s+/).map(norm).filter(Boolean);if(phrase.length){for(let i=0;i+phrase.length<=words.length;i++){if(phrase.every((w,j)=>words[i+j]===w))for(let j=0;j<phrase.length;j++)accentIdx.add(i+j);}}const lit=(isStatic?.5:progress)*wordCount;const balance=balanced?{textWrap:\"balance\"}:{};let idx=-1;return /*#__PURE__*/_jsx(\"p\",{ref:ref,style:{margin:0,width:\"100%\",whiteSpace:\"pre-wrap\",...balance,...font,...style},children:parts.map((w,k)=>{if(w.trim().length>0){idx+=1;return /*#__PURE__*/_jsx(\"span\",{style:{color:idx<lit?accentIdx.has(idx)?accentColor:finalColor:initialColor,transition:\"color 0.3s ease\"},children:w},k);}return /*#__PURE__*/_jsx(\"span\",{children:w},k);})});}ScrollColorText.displayName=\"Scroll Color Text\";addPropertyControls(ScrollColorText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"As you scroll through this text, each word gradually shifts from the starting color to the final color, revealing the message word by word.\",displayTextArea:true},initialColor:{type:ControlType.Color,title:\"Initial Color\",defaultValue:\"rgba(0, 0, 0, 0.2)\"},finalColor:{type:ControlType.Color,title:\"Final Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Medium\",lineHeight:\"1.3em\",letterSpacing:\"-0.02em\"}},balanced:{type:ControlType.Boolean,title:\"Balanced\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},accentText:{type:ControlType.String,title:\"Accent Words\",defaultValue:\"\"},accentColor:{type:ControlType.Color,title:\"Accent Color\",defaultValue:\"#0369A1\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollColorText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicWidth\":\"800\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollColorText.map"],"mappings":"A,2MAMG,SAAwBc,EAAgB,EAAM,CAAC,GAAK,CAAC,OAAK,8IAA8I,eAAa,qBAAqB,aAAW,UAAU,OAAK,WAAS,GAAM,aAAW,GAAG,cAAY,UAAU,SAAOC,EAAYC,EAAIhB,EAAO,IAAI,EAAO,CAACiB,EAASC,GAAajB,EAAS,CAAC,EAAQkB,EAASP,EAAoB,EAAQQ,EAAMC,EAAK,MAAM,OAAO,EAAQC,EAAUF,EAAM,OAAO,GAAGG,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAOd,MAAc,CAAC,GAAGU,GAAiBd,IAAS,OAAY,OAAO,IAAImB,EAAI,EAAQC,MAAY,CAAC,EAAI,EAAE,IAAMC,EAAGV,EAAI,QAAQ,GAAG,CAACU,EAAG,OAAO,IAAMC,EAAED,EAAG,sBAAsB,EAAQE,EAAGvB,EAAO,aAAa,EAAQwB,EAAMD,EAAG,IAAUE,EAAIF,EAAG,IAAUG,EAAMJ,EAAE,QAAQE,EAAMC,GAAWP,EAAEQ,EAAM,GAAGF,EAAMF,EAAE,KAAKI,EAAM,EAAQC,EAAQ,KAAK,IAAI,EAAE,KAAK,IAAI,EAAET,CAAC,CAAC,EAAEnB,MAAoBc,EAAYc,CAAO,CAAC,CAAE,EAAQC,MAAa,CAAC,IAAM5B,EAAO,sBAAsBoB,CAAO,CAAE,EAAgI,OAA9HA,EAAQ,EAAEpB,EAAO,iBAAiB,SAAS4B,EAAS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