{"version":3,"file":"ScrollOpacityText.Bo-D3tFB.mjs","names":["useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/YCUOGqZrgkq5GjtD26SM/zwbtBdtHUezlhDBeljwQ/ScrollOpacityText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useScroll,useTransform,motion}from\"framer-motion\";import{useRef,useMemo}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Scroll-based text opacity component using Framer's native scroll system\n * Text opacity increases from startOpacity to endOpacity as user scrolls\n * Animation is driven by scroll progress and reverses when scrolling up\n * Scroll trigger: Start at 3/4 down screen, End at 1/4 down screen\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function ScrollOpacityText(props){const{text=\"Scroll to reveal this text\",type=\"word\",font,color=\"#000000\",startOpacity=.2,endOpacity=1,style}=props;const containerRef=useRef(null);const{scrollYProgress}=useScroll({target:containerRef,offset:[\"start 0.75\",\"start 0.25\"]});const segments=useMemo(()=>{if(type===\"word\"){return text.split(/(\\s+)/).filter(s=>s.length>0);}return text.split(\"\");},[text,type]);const totalSegments=segments.filter(s=>s.trim().length>0).length;return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,position:\"relative\",display:\"inline-block\"},children:/*#__PURE__*/_jsx(\"div\",{style:{...font,color,whiteSpace:\"pre-wrap\",wordWrap:\"break-word\"},children:segments.map((segment,index)=>{if(type===\"word\"&&/^\\s+$/.test(segment)){return /*#__PURE__*/_jsx(\"span\",{children:segment},index);}const actualIndex=segments.slice(0,index).filter(s=>s.trim().length>0).length;const segmentStart=actualIndex/totalSegments;const segmentEnd=(actualIndex+1)/totalSegments;const opacity=useTransform(scrollYProgress,[segmentStart,segmentEnd],[startOpacity,endOpacity]);return /*#__PURE__*/_jsx(motion.span,{style:{opacity},children:segment},index);})})});}addPropertyControls(ScrollOpacityText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Scroll to reveal this text\",displayTextArea:true},type:{type:ControlType.Enum,title:\"Type\",options:[\"word\",\"character\"],optionTitles:[\"Word\",\"Character\"],defaultValue:\"word\",displaySegmentedControl:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},startOpacity:{type:ControlType.Number,title:\"Start Opacity\",defaultValue:.2,min:0,max:1,step:.1},endOpacity:{type:ControlType.Number,title:\"End Opacity\",defaultValue:1,min:0,max:1,step:.1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollOpacityText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollOpacityText.map"],"mappings":"mPAQG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,OAAK,6BAA6B,OAAK,OAAO,OAAK,QAAM,UAAU,eAAa,GAAG,aAAW,EAAE,SAAO,EAAY,EAAaA,EAAO,KAAK,CAAM,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAAa,OAAO,CAAC,aAAa,aAAa,CAAC,CAAC,CAAO,EAASC,MAAgB,IAAO,OAAe,EAAK,MAAM,QAAQ,CAAC,OAAO,GAAG,EAAE,OAAO,EAAE,CAAS,EAAK,MAAM,GAAG,CAAG,CAAC,EAAK,EAAK,CAAC,CAAO,EAAc,EAAS,OAAO,GAAG,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,OAAoB,EAAK,MAAM,CAAC,IAAI,EAAa,MAAM,CAAC,GAAG,EAAM,SAAS,WAAW,QAAQ,eAAe,CAAC,SAAsB,EAAK,MAAM,CAAC,MAAM,CAAC,GAAG,EAAK,QAAM,WAAW,WAAW,SAAS,aAAa,CAAC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