{"version":3,"file":"ScrollColorText.C03kmuE5.mjs","names":["useRef","useState","__esmMin","init_ssg_sandbox_shims","te","window","_e","de","init_npm_react_18_3_1","ce","addPropertyControls","init_framer_CKT6jEEQ","useIsStaticRenderer","ControlType","ScrollColorText","props","rootRef","progress","setProgress","isStatic","words","text","wordCount","w","frame","update","target","rect","vh","start","end","denom","p","clamped","onScroll","coloredCount","balanceStyle","balanced","\"textWrap\"","wordIndex","font","style","token","finalColor","initialColor","i","init_ScrollColorText","init_jsx_runtime"],"sources":["https:/framerusercontent.com/modules/ggdiVLagvnBpbHOYoyZ5/pBXENZV7zm66HjSyHlmQ/ScrollColorText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\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,style}=props;const rootRef=useRef(null);const[progress,setProgress]=useState(0);const isStatic=useIsStaticRenderer();const words=text.split(/(\\s+)/);const wordCount=words.filter(w=>w.trim().length>0).length;useEffect(()=>{if(isStatic)return;if(typeof window===\"undefined\")return;let frame=0;const update=()=>{frame=0;const target=rootRef.current;if(!target)return;const rect=target.getBoundingClientRect();const vh=window.innerHeight||1;const start=vh*.85;const end=vh*.35;const denom=rect.height+(start-end);const p=denom>0?(start-rect.top)/denom:0;const clamped=Math.min(1,Math.max(0,p));startTransition(()=>setProgress(clamped));};const onScroll=()=>{if(frame)return;frame=window.requestAnimationFrame(update);};update();window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",onScroll,{passive:true});return()=>{window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",onScroll);if(frame)window.cancelAnimationFrame(frame);};},[isStatic]);const activeProgress=isStatic?.5:progress;const coloredCount=activeProgress*wordCount;const balanceStyle=balanced?{[\"textWrap\"]:\"balance\"}:{};let wordIndex=-1;return /*#__PURE__*/_jsx(\"p\",{ref:rootRef,style:{margin:0,width:\"100%\",// Preserve manual line breaks (Shift+Enter) while still\n// wrapping long lines at the container edge.\nwhiteSpace:\"pre-wrap\",...balanceStyle,...font,...style},children:words.map((token,i)=>{const isWord=token.trim().length>0;if(!isWord)return /*#__PURE__*/_jsx(\"span\",{children:token},i);wordIndex+=1;const isColored=wordIndex<coloredCount;return /*#__PURE__*/_jsx(\"span\",{style:{color:isColored?finalColor:initialColor,transition:\"color 0.3s ease\"},children:token},i);})});}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\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollColorText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollColorText.map"],"mappings":"A,2MAGG,SAAwBc,EAAgB,EAAM,CAAC,GAAK,CAAC,OAAK,8IAA8I,eAAa,qBAAqB,aAAW,UAAU,OAAK,WAAS,GAAM,SAAOC,EAAYC,EAAQ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