{"version":3,"file":"ScrollText.DoXdth0L.mjs","names":["useState","useRef","useMemo","wordIndex"],"sources":["https:/framerusercontent.com/modules/W5ZbFjDOcDonbAUGORze/oZNwoqX9oPOvdftMurIs/ScrollText.js"],"sourcesContent":["// Text component that transitions from bold to regular weight on scroll\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition,useMemo}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function ScrollText(props){const{text,fontSize,color,lineHeight,letterSpacing,textAlign,font}=props;const[scrollProgress,setScrollProgress]=useState(0);const elementRef=useRef(null);const isStatic=useIsStaticRenderer();useEffect(()=>{if(isStatic||typeof window===\"undefined\")return;const handleScroll=()=>{if(!elementRef.current)return;const rect=elementRef.current.getBoundingClientRect();const windowHeight=window.innerHeight;// Calculate scroll progress based on element position\nconst elementTop=rect.top;const elementHeight=rect.height;// Start transition when element enters viewport, complete when it exits\nconst startPoint=windowHeight;const endPoint=-elementHeight;const totalDistance=startPoint-endPoint;if(elementTop<=startPoint&&elementTop>=endPoint){// Element is in transition zone\nconst progress=(startPoint-elementTop)/totalDistance;const clampedProgress=Math.max(0,Math.min(1,progress));startTransition(()=>{setScrollProgress(clampedProgress);});}else if(elementTop>startPoint){// Element hasn't entered viewport yet - stay bold\nstartTransition(()=>{setScrollProgress(0);});}else{// Element has passed viewport - stay regular\nstartTransition(()=>{setScrollProgress(1);});}};window.addEventListener(\"scroll\",handleScroll,{passive:true});handleScroll()// Initial check\n;return()=>{window.removeEventListener(\"scroll\",handleScroll);};},[isStatic]);// Split text into words for individual animation\nconst words=useMemo(()=>{return text.split(/(\\s+)/);},[text]);// Count total words for progress calculation\nconst totalWords=useMemo(()=>{return words.filter(word=>!/^\\s+$/.test(word)).length;},[words]);const getWordStyle=(wordIndex,word)=>{// Skip styling for whitespace\nif(/^\\s+$/.test(word)){return{};}// Calculate individual word progress with staggered effect\nconst wordProgress=Math.max(0,Math.min(1,scrollProgress*totalWords-wordIndex));// Interpolate from 400 (thin) to 700 (bold)\nconst fontWeight=400+300*wordProgress;// Interpolate colors from #17272B with 24% opacity (thin) to #17272A (bold)\nconst thinColor={r:23,g:39,b:43,a:.24}// #17272B with 24% opacity\n;const boldColor={r:23,g:39,b:42}// #17272A\n;const r=Math.round(thinColor.r+(boldColor.r-thinColor.r)*wordProgress);const g=Math.round(thinColor.g+(boldColor.g-thinColor.g)*wordProgress);const b=Math.round(thinColor.b+(boldColor.b-thinColor.b)*wordProgress);const a=.24+(1-.24)*wordProgress// From 24% to 100% opacity\n;const interpolatedColor=`rgba(${r}, ${g}, ${b}, ${a})`;return{fontWeight:isStatic?400:Math.round(fontWeight),color:isStatic?\"#17272B\":interpolatedColor,transition:isStatic?\"none\":\"font-weight 0.3s ease, color 0.3s ease\"};};const isFixedWidth=props?.style&&props.style.width===\"100%\";let wordIndex=0;return /*#__PURE__*/_jsx(\"div\",{ref:elementRef,style:{...props.style,position:\"relative\",...isFixedWidth?{...props?.style}:{minWidth:\"max-content\"},fontSize:`${fontSize}px`,lineHeight,letterSpacing:`${letterSpacing}em`,textAlign,...font,whiteSpace:\"pre-wrap\"},children:words.map((word,index)=>{if(/^\\s+$/.test(word)){return /*#__PURE__*/_jsx(\"span\",{children:word},index);}const currentWordIndex=wordIndex++;const wordStyle=getWordStyle(currentWordIndex,word);return /*#__PURE__*/_jsx(\"span\",{style:wordStyle,children:word},index);})});}addPropertyControls(ScrollText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Scratches, stains, warping — most flooring brands focus on showroom perfection but forget how floors actually perform in real homes. They sell you products, not life.\\n\\nThis is for your real-life floors. Built for morning spills, muddy paws, and dancing toddlers.\",displayTextArea:true},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:44,min:12,max:120,step:1,unit:\"px\"},color:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#17272A\"},lineHeight:{type:ControlType.Number,title:\"Line Height\",defaultValue:1.2,min:.8,max:2,step:.1},letterSpacing:{type:ControlType.Number,title:\"Letter Spacing\",defaultValue:-.02,min:-.1,max:.1,step:.01,unit:\"em\"},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},font:{type:ControlType.Font,title:\"Font Style\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"44px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1.2em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollText.map"],"mappings":"6NAIG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,WAAS,QAAM,aAAW,gBAAc,YAAU,QAAM,EAAW,CAAC,EAAe,GAAmBA,EAAS,EAAE,CAAO,EAAWC,EAAO,KAAK,CAAO,EAAS,GAAqB,CAAC,MAAc,CAAC,GAAG,GAAiB,IAAS,OAAY,OAAO,IAAM,MAAiB,CAAC,GAAG,CAAC,EAAW,QAAQ,OAAO,IAAM,EAAK,EAAW,QAAQ,uBAAuB,CAAO,EAAa,EAAO,YAC5a,EAAW,EAAK,IAAU,EAAc,EAAK,OAC7C,EAAW,EAAmB,EAAS,CAAC,EAAoB,EAAc,EAAW,EAAS,GAAG,GAAY,GAAY,GAAY,EAAS,CACpJ,IAAM,GAAU,EAAW,GAAY,EAAoB,EAAgB,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,EAAS,CAAC,CAAC,MAAoB,CAAC,EAAkB,EAAgB,EAAG,MACtK,EADgL,EAAW,MACvK,CAAC,EAA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