{"version":3,"file":"Scroll_Text_reveal.BLPyvZLa.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/wy1boFF8IEghi7BUbYdO/CsDbr30QjG1ykt297Nk9/Scroll_Text_reveal.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef}from\"react\";import{addPropertyControls,ControlType,useInView,motion,useScroll,useTransform}from\"framer\";/**\n * Text Reveal Word by Word\n *\n * Reveals text word by word on scroll when text is in view\n */export default function TextReveal(props){const{text=\"\",font,textColor,revealColor,textAlign,textOverflow,style}=props;const containerRef=useRef(null);const isInView=useInView(containerRef,{amount:.1});const{scrollYProgress}=useScroll({target:containerRef,offset:[\"start end\",\"end center\"]});// Suddivide il testo riconoscendo <br>, <br/>, spazi e parole\nconst tokens=[];const chunks=text.split(/(<br\\s*\\/?>)/gi);for(const chunk of chunks){if(!chunk)continue;if(/^<br\\s*\\/?>$/i.test(chunk)){tokens.push({type:\"br\",text:chunk});}else{const parts=chunk.match(/\\S+|\\s+/g)||[];for(const part of parts){if(/\\S/.test(part)){tokens.push({type:\"word\",text:part});}else{tokens.push({type:\"space\",text:part});}}}}const wordCount=Math.max(tokens.filter(t=>t.type===\"word\").length,1);let currentWordIndex=0;return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,position:\"relative\",width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",overflow:textOverflow===\"ellipsis\"?\"hidden\":textOverflow},children:/*#__PURE__*/_jsx(\"div\",{style:{...font,textAlign,width:\"100%\",display:\"block\",whiteSpace:textOverflow===\"ellipsis\"?\"nowrap\":\"pre-wrap\",overflow:textOverflow===\"ellipsis\"?\"hidden\":textOverflow,textOverflow:textOverflow===\"ellipsis\"?\"ellipsis\":undefined},children:tokens.map((token,index)=>{if(token.type===\"br\"){return /*#__PURE__*/_jsx(\"br\",{},index);}if(token.type===\"space\"){return /*#__PURE__*/_jsx(\"span\",{children:token.text},index);}const start=currentWordIndex/wordCount;const end=(currentWordIndex+1)/wordCount;currentWordIndex++;return /*#__PURE__*/_jsx(Word,{word:token.text,progress:scrollYProgress,range:[start,end],textColor:textColor,revealColor:revealColor,isInView:isInView},index);})})});}function Word({word,progress,range,textColor,revealColor,isInView}){const color=useTransform(progress,range,[textColor,revealColor]);return /*#__PURE__*/_jsx(motion.span,{style:{color:isInView?color:textColor,display:\"inline\"},children:word});}TextReveal.defaultProps={text:\"This text will reveal word by word as you scroll\",textColor:\"#CCCCCC\",revealColor:\"#000000\",textAlign:\"left\",textOverflow:\"visible\"};addPropertyControls(TextReveal,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"This text will reveal word by word as you scroll\",displayTextArea:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1.2em\"}},textOverflow:{type:ControlType.Enum,title:\"Overflow\",options:[\"visible\",\"hidden\",\"ellipsis\",\"clip\"],optionTitles:[\"Visible\",\"Hidden\",\"Ellipsis\",\"Clip\"],defaultValue:\"visible\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#CCCCCC\"},revealColor:{type:ControlType.Color,title:\"Reveal Color\",defaultValue:\"#000000\"},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextReveal\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Scroll_Text_reveal.map"],"mappings":"2OAIG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,GAAG,OAAK,YAAU,cAAY,YAAU,eAAa,SAAO,EAAY,EAAaA,EAAO,IAAI,EAAQ,EAAS,EAAU,EAAa,CAAC,O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