{"version":3,"file":"Text_Reveal_on_Scroll.CfPUjsg9.mjs","names":["useRef","React","__esmMin","init_npm_react_18_3_1","e","c","init_jsx_runtime","de","useMotionValueEvent","motion","useScroll","useSpring","useTransform","init_framer_motion_DhsWWWsN","useMotionValue","init_framer_DcxuU94H","addPropertyControls","ControlType","useIsStaticRenderer","toSpringOptions","transition","duration","TextRevealOnScroll","props","text","style","font","balance","primaryColor","AnimatedTextRevealOnScroll","containerRef","maxProgress","scrollYProgress","latest","progressToUse","replay","renderText","items","mode","totalValids","item","currentIdx","itemStr","idx","start","end","RevealItem","mutedColor","init_Text_Reveal_on_Scroll","color","progress","range"],"sources":["https:/framerusercontent.com/modules/zDtiSTBfViqo5tUzeRNn/r5fIqIUYTgYRry5w2nRx/Text_Reveal_on_Scroll.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import React,{useRef}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{motion,useScroll,useTransform,useSpring,useMotionValue,useMotionValueEvent}from\"framer-motion\";function toSpringOptions(transition){const hasSpringValues=typeof transition?.stiffness===\"number\"||typeof transition?.damping===\"number\"||typeof transition?.mass===\"number\";if(!hasSpringValues&&typeof transition?.duration===\"number\"){const duration=Math.max(transition.duration,.05);return{stiffness:170/(duration*duration),damping:26/duration,mass:1,restDelta:.001};}return{stiffness:typeof transition?.stiffness===\"number\"?transition.stiffness:100,damping:typeof transition?.damping===\"number\"?transition.damping:30,mass:typeof transition?.mass===\"number\"?transition.mass:1,restDelta:.001};}/**\n * @framerDisableUnlink\n */export default function TextRevealOnScroll(props){const isStatic=useIsStaticRenderer();if(isStatic){const{text=\"Framer text reveal on scroll effect\",primaryColor=\"#000000\",font,balance=true,style}=props;return /*#__PURE__*/_jsx(\"div\",{role:\"region\",\"aria-label\":text,style:{...style,...font,textWrap:balance?\"balance\":\"wrap\",whiteSpace:\"pre-wrap\",display:\"block\",color:primaryColor},children:text});}return /*#__PURE__*/_jsx(AnimatedTextRevealOnScroll,{...props});}function AnimatedTextRevealOnScroll(props){const{text=\"Framer text reveal on scroll effect\",mutedColor=\"#888888\",primaryColor=\"#000000\",font,balance=true,replay=true,mode=\"word\",style,transition}=props;const containerRef=useRef(null);const{scrollYProgress}=useScroll({target:containerRef,offset:[\"start end\",\"end center\"],layoutEffect:false});const maxProgress=useMotionValue(0);useMotionValueEvent(scrollYProgress,\"change\",latest=>{if(latest>maxProgress.get()){maxProgress.set(latest);}});const sourceProgress=replay?scrollYProgress:maxProgress;const progressToUse=useSpring(sourceProgress,toSpringOptions(transition));const renderText=()=>{if(!text)return null;let items=[];if(mode===\"character\"){// Split string identically into characters including spaces\nitems=text.split(\"\");}else if(mode===\"word\"){// Split into exact word blocks and space blocks\nitems=text.match(/([\\S]+|\\s+)/g)||[];}else if(mode===\"sentence\"){// Split into exact sentence strings and spaces/returns\nitems=text.match(/[^.!?\\n]+(?:[.!?]+)?|\\n|\\s+/g)||[];}// Count how many trackable items (non-whitespace) exist for % offsets\nlet totalValids=0;items.forEach(item=>{if(item.trim().length>0)totalValids++;});let currentIdx=0;return items.map((itemStr,idx)=>{// Let the DOM render straight text nodes for spaces and indents\nif(itemStr.trim().length===0&&itemStr!==\"\\n\"){return /*#__PURE__*/_jsx(React.Fragment,{children:itemStr},`${mode}-space-${idx}`);}if(itemStr===\"\\n\"){return /*#__PURE__*/_jsx(\"br\",{},`${mode}-br-${idx}`);}const start=currentIdx/Math.max(totalValids,1);const end=(currentIdx+1)/Math.max(totalValids,1);currentIdx++;return /*#__PURE__*/_jsx(RevealItem,{progress:progressToUse,range:[start,end],mutedColor:mutedColor,primaryColor:primaryColor,children:itemStr},`${mode}-${idx}`);});};return /*#__PURE__*/_jsx(motion.div,{ref:containerRef,layout:true,role:\"region\",\"aria-label\":text,style:{...style,...font,textWrap:balance?\"balance\":\"wrap\",whiteSpace:\"pre-wrap\",display:\"block\",color:mutedColor},children:/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":\"true\",children:renderText()})});}// Friendly display name for Framer's UI (allows spaces)\nTextRevealOnScroll.displayName=\"Text Reveal on Scroll\";const RevealItem=({children,progress,range,mutedColor,primaryColor})=>{const color=useTransform(progress,range,[mutedColor,primaryColor]);return /*#__PURE__*/_jsx(motion.span,{style:{color},children:children});};TextRevealOnScroll.defaultProps={text:\"Framer text reveal on scroll effect\",mutedColor:\"#888888\",primaryColor:\"#000000\",replay:true,balance:true,mode:\"word\",font:{fontFamily:\"Inter, sans-serif\",fontSize:\"32px\",fontWeight:600},style:{width:\"100%\",height:\"100%\"},transition:{duration:.4}};const DEMO_LINK=\"https://text-reveal-on-scroll.framer.website/\";addPropertyControls(TextRevealOnScroll,{_info:{type:ControlType.Enum,title:\"Developed by\",options:[\"kaniyanstudio\"],optionTitles:[\"KaniyanStudio\"],displaySegmentedControl:true,defaultValue:\"kaniyanstudio\",description:`Made with ❤️ by [@kaniyanstudio](https://www.x.com/kaniyanstudio)\n[Live Demo](${DEMO_LINK})`},text:{type:ControlType.String,title:\"Text\",defaultValue:\"Framer text reveal on scroll effect\",displayTextArea:true},mode:{type:ControlType.Enum,title:\"Reveal By\",options:[\"character\",\"word\",\"sentence\"],optionTitles:[\"Character\",\"Word\",\"Sentence\"],defaultValue:\"word\"},mutedColor:{type:ControlType.Color,title:\"Muted Color\",defaultValue:\"#888888\"},primaryColor:{type:ControlType.Color,title:\"Primary Color\",defaultValue:\"#000000\"},replay:{type:ControlType.Boolean,title:\"Replay\",defaultValue:true},balance:{type:ControlType.Boolean,title:\"Balance\",defaultValue:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\"},transition:{type:ControlType.Transition,title:\"Transition\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextRevealOnScroll\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Text_Reveal_on_Scroll.map"],"mappings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