{"version":3,"file":"TextScrollReveal.SbJ2cmpc.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/0a4qN1632bQxeg9yKa64/B4zpl1UPX1Mc1tpVAusH/TextScrollReveal.js"],"sourcesContent":["// Text scroll reveal component - words appear sequentially as user scrolls\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TextScrollReveal(props){const{text=\"This is a sample text that will reveal word by word as you scroll down the page. Each word appears sequentially creating a beautiful scroll reveal effect.\",textStyle,color,backgroundColor,textTransform=\"none\",enableBlur=true,unrevealedOpacity=.1,startPosition=80,endPosition=20}=props;const containerRef=useRef(null);const[revealedWords,setRevealedWords]=useState(0);const isStatic=useIsStaticRenderer();const words=text.split(\" \").filter(word=>word.length>0);useEffect(()=>{if(isStatic){// Show all words in static mode\nstartTransition(()=>setRevealedWords(words.length));return;}const handleScroll=()=>{if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();const windowHeight=window.innerHeight;// Calculate trigger points based on viewport percentages\nconst startTrigger=windowHeight*(startPosition/100);const endTrigger=windowHeight*(endPosition/100);// Element position relative to viewport\nconst elementTop=rect.top;const elementBottom=rect.bottom;// Calculate progress based on element position in viewport\nlet progress=0;if(elementTop>startTrigger){// Element hasn't reached start position yet\nprogress=0;}else if(elementBottom<endTrigger){// Element has passed end position - full reveal\nprogress=1;}else{// Element is between start and end positions\nconst totalDistance=startTrigger-endTrigger;const currentDistance=startTrigger-elementTop;progress=Math.max(0,Math.min(1,currentDistance/totalDistance));}// Apply speed multiplier\nconst adjustedProgress=Math.min(1,progress);const wordsToReveal=Math.floor(adjustedProgress*words.length);startTransition(()=>setRevealedWords(wordsToReveal));};if(typeof window!==\"undefined\"){// Use passive listeners for better performance\nwindow.addEventListener(\"scroll\",handleScroll,{passive:true});window.addEventListener(\"resize\",handleScroll,{passive:true});// Initial check\nhandleScroll();}return()=>{if(typeof window!==\"undefined\"){window.removeEventListener(\"scroll\",handleScroll);window.removeEventListener(\"resize\",handleScroll);}};},[words.length,isStatic,startPosition,endPosition]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...props.style,position:\"relative\",width:\"100%\",height:\"100%\",backgroundColor,overflow:\"visible\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:/*#__PURE__*/_jsx(\"div\",{style:{...textStyle,color,width:\"100%\",height:\"100%\",boxSizing:\"border-box\",textTransform,wordWrap:\"break-word\",overflowWrap:\"break-word\",wordBreak:\"normal\",hyphens:\"none\",whiteSpace:\"normal\"},children:words.map((word,index)=>/*#__PURE__*/_jsxs(\"span\",{style:{opacity:index<revealedWords?1:unrevealedOpacity,filter:index<revealedWords?\"none\":enableBlur?\"blur(2px)\":\"none\",transition:isStatic?\"none\":\"opacity 0.3s ease-out, filter 0.3s ease-out\"},children:[word,index<words.length-1?\" \":\"\"]},index))})});}addPropertyControls(TextScrollReveal,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"This is a sample text that will reveal word by word as you scroll down the page. Each word appears sequentially creating a beautiful scroll reveal effect.\",displayTextArea:true},textStyle:{type:ControlType.Font,title:\"Text Style\",controls:\"extended\",defaultFontType:\"sans-serif\",displayTextAlignment:true,defaultValue:{fontSize:\"16px\",variant:\"Regular\",letterSpacing:\"0em\",lineHeight:\"1.4em\",textAlign:\"left\"}},color:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\",optional:true},textTransform:{type:ControlType.Enum,title:\"Text Transform\",options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],optionTitles:[\"None\",\"UPPERCASE\",\"lowercase\",\"Capitalize\"],defaultValue:\"none\",displaySegmentedControl:true},enableBlur:{type:ControlType.Boolean,title:\"Blur Effect\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},unrevealedOpacity:{type:ControlType.Number,title:\"Unrevealed Opacity\",defaultValue:.1,min:0,max:1,step:.1,unit:\"\"},startPosition:{type:ControlType.Number,title:\"Start Position\",defaultValue:80,min:0,max:100,step:5,unit:\"%\"},endPosition:{type:ControlType.Number,title:\"End Position\",defaultValue:20,min:0,max:100,step:5,unit:\"%\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextScrollReveal\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextScrollReveal.map"],"mappings":"uNAIG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,OAAK,6JAA6J,YAAU,QAAM,kBAAgB,gBAAc,OAAO,aAAW,GAAK,oBAAkB,GAAG,gBAAc,GAAG,cAAY,IAAI,EAAY,EAAaA,EAAO,IAAI,EAAO,CAAC,EAAc,GAAkBC,EAAS,CAAC,EAAQ,EAAS,EAAoB,EAAQ,EAAM,EAAK,MAAM,GAAG,CAAC,CAAC,OAAO,GAAM,EAAK,OAAO,CAAC,EAUlT,OAVoT,MAAc,CAAC,GAAG,EAAS,CACtiB,MAAoB,EAAiB,EAAM,MAAM,CAAC,EAAE,MAAO,CAAC,IAAM,MAAiB,CAAC,GAAG,CAAC,EAAa,QAAQ,OAAO,IAAM,EAAK,EAAa,QAAQ,sBAAsB,EAAQ,EAAa,EAAO,YAChM,EAA2B,EAAc,IAA5B,EAAuC,EAAyB,EAAY,IAA1B,EAC/D,EAAW,EAAK,IAAU,EAAc,EAAK,OAC/C,EAAS,EAAE,GAAG,EAAW,EAC7B,EAAS,OAAQ,GAAG,EAAc,EAClC,EAAS,MAAO,CAChB,IAAM,EAAc,EAAa,EAAiB,EAAgB,E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