{"version":3,"file":"ScrollReveal.CU2Hqexc.mjs","names":["useRef","p"],"sources":["https:/framerusercontent.com/modules/GZiwBGZyJP6P5g7nnPWI/aGrHgXT4lYOUV6kzJfxz/ScrollReveal.js"],"sourcesContent":["// Text scroll reveal component that animates paragraphs on scroll\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef}from\"react\";import{motion,useScroll,useTransform}from\"framer-motion\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function ScrollReveal(props){const{text=\"This is a sample paragraph that will animate on scroll. Each character will fade from transparent to full color as it comes into view. You can customize the timing of the reveal animation.\",revealDuration=.8,revealDelay=0,staggerDelay=.02,font,textColor=\"#000000\",threshold=.1,triggerPosition=\"middle\",htmlTag=\"p\",style}=props;const containerRef=useRef(null);const isStatic=useIsStaticRenderer();// Calculate offset based on trigger position\nconst getOffset=()=>{switch(triggerPosition){case\"top\":return[\"start 1.0\",\"end 0.0\"];case\"middle\":return[\"start 0.8\",\"end 0.2\"];case\"bottom\":return[\"start 0.6\",\"end 0.4\"];default:return[\"start 0.8\",\"end 0.2\"];}};// Use scroll progress with dynamic offset\nconst{scrollYProgress}=useScroll({target:containerRef,offset:getOffset()});// Split text into paragraphs and then into words\nconst paragraphs=text.split(\"\\n\").filter(p=>p.trim().length>0);// Create word arrays for each paragraph, preserving spaces\nconst paragraphWords=paragraphs.map(paragraph=>{const words=paragraph.split(/(\\s+)/);return words.map((word,index)=>({word,index,isSpace:/^\\s+$/.test(word)}));});// Calculate total word count for progress calculation\nconst totalWords=paragraphWords.reduce((total,words)=>total+words.filter(w=>!w.isSpace).length,0);// Static preview for non-interactive environments\nif(isStatic){return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,position:\"relative\"},children:paragraphs.map((paragraph,index)=>{const Tag=htmlTag;return /*#__PURE__*/_jsx(Tag,{style:{...font,color:textColor,margin:index===paragraphs.length-1?0:\"0 0 1em 0\"},children:paragraph},index);})});}let globalWordIndex=0;return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,position:\"relative\"},children:paragraphWords.map((words,paragraphIndex)=>{const Tag=htmlTag;return /*#__PURE__*/_jsx(Tag,{style:{...font,margin:paragraphIndex===paragraphWords.length-1?0:\"0 0 1em 0\",display:\"block\"},children:words.map(({word,isSpace},wordIndex)=>{if(isSpace){return /*#__PURE__*/_jsx(\"span\",{children:word},`${paragraphIndex}-${wordIndex}`);}const currentGlobalIndex=globalWordIndex++;// Calculate when this word should start and finish revealing\n// Make reveal much faster: reduce spread and overlap more\nconst wordProgress=currentGlobalIndex/totalWords;const revealStart=wordProgress*.3// v1: slower, more spread out\n;const revealEnd=Math.min(.7,revealStart+.18)// v1: reveal ends later\n;// Transform scroll progress to word opacity\nconst opacity=useTransform(scrollYProgress,[revealStart,revealEnd],[0,1]);return /*#__PURE__*/_jsx(motion.span,{style:{color:textColor,opacity},children:word},`${paragraphIndex}-${wordIndex}`);})},paragraphIndex);})});}addPropertyControls(ScrollReveal,{text:{type:ControlType.String,title:\"Text\",description:\"Text content to animate. Use line breaks to create multiple paragraphs.\",defaultValue:\"This is a sample paragraph that will animate on scroll. Each character will fade from transparent to full color as it comes into view. You can customize the timing of the reveal animation.\\n\\nThis is a second paragraph that will animate character by character. You can add multiple paragraphs by separating them with line breaks.\",displayTextArea:true},htmlTag:{type:ControlType.Enum,title:\"HTML Tag\",description:\"Semantic HTML element to use for accessibility and SEO.\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\"],optionTitles:[\"Heading 1\",\"Heading 2\",\"Heading 3\",\"Heading 4\",\"Heading 5\",\"Heading 6\",\"Paragraph\",\"Span\"],defaultValue:\"p\",displaySegmentedControl:false},triggerPosition:{type:ControlType.Enum,title:\"Trigger Position\",description:\"When the animation starts relative to viewport position.\",options:[\"top\",\"middle\",\"bottom\"],optionTitles:[\"Top\",\"Middle\",\"Bottom\"],defaultValue:\"middle\",displaySegmentedControl:true},revealDuration:{type:ControlType.Number,title:\"Duration\",description:\"Total time for the entire text to fully reveal.\",defaultValue:.8,min:.1,max:3,step:.1,unit:\"s\"},revealDelay:{type:ControlType.Number,title:\"Initial Delay\",description:\"Delay before animation starts after trigger.\",defaultValue:0,min:0,max:2,step:.1,unit:\"s\"},staggerDelay:{type:ControlType.Number,title:\"Character Stagger\",description:\"Time delay between each character's animation start.\",defaultValue:.02,min:0,max:.2,step:.01,unit:\"s\"},threshold:{type:ControlType.Number,title:\"Trigger Threshold\",description:\"How much of the element must be visible to trigger animation.\",defaultValue:.1,min:0,max:1,step:.1,unit:\"%\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"16px\",variant:\"Regular\",letterSpacing:\"-0.01em\",lineHeight:\"1.6em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollReveal\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollReveal.map"],"mappings":"iPAIG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,OAAK,+LAA+L,iBAAe,GAAG,cAAY,EAAE,eAAa,IAAI,OAAK,YAAU,UAAU,YAAU,GAAG,kBAAgB,SAAS,UAAQ,IAAI,SAAO,EAAY,EAAaA,EAAO,KAAK,CAAO,EAAS,GAAqB,CAEjc,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAAa,YADlC,CAAC,OAAO,EAAP,CAAwB,IAAI,MAAM,MAAM,CAAC,YAAY,UAAU,CAAC,IAAI,SAAS,MAAM,CAAC,YAAY,UAAU,CAAC,IAAI,SAAS,MAAM,CA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