{"version":3,"file":"ScrollFlowTextFX_3.CE8ei6Fr.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/0jYrznYo8VbbAkqnMbpQ/IcsnTdo2gqKO076VvzDs/ScrollFlowTextFX_3.js"],"sourcesContent":["// Scroll velocity text component that animates based on scroll speed\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useLayoutEffect,useState}from\"react\";import{motion,useScroll,useSpring,useTransform,useMotionValue,useVelocity,useAnimationFrame}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";function useElementWidth(ref){const[width,setWidth]=useState(0);useLayoutEffect(()=>{function updateWidth(){if(ref.current){setWidth(ref.current.offsetWidth);}}updateWidth();if(typeof window!==\"undefined\"){window.addEventListener(\"resize\",updateWidth);return()=>window.removeEventListener(\"resize\",updateWidth);}},[ref]);return width;}function VelocityText({children,baseVelocity,damping,stiffness,numCopies,velocityMapping,font,textColor}){const baseX=useMotionValue(0);const{scrollY}=useScroll();const scrollVelocity=useVelocity(scrollY);const smoothVelocity=useSpring(scrollVelocity,{damping,stiffness});const velocityFactor=useTransform(smoothVelocity,velocityMapping.input,velocityMapping.output,{clamp:false});const copyRef=useRef(null);const copyWidth=useElementWidth(copyRef);function wrap(min,max,v){const range=max-min;const mod=((v-min)%range+range)%range;return mod+min;}const x=useTransform(baseX,v=>{if(copyWidth===0)return\"0px\";return`${wrap(-copyWidth,0,v)}px`;});const directionFactor=useRef(1);useAnimationFrame((t,delta)=>{let moveBy=directionFactor.current*baseVelocity*(delta/1e3);if(velocityFactor.get()<0){directionFactor.current=-1;}else if(velocityFactor.get()>0){directionFactor.current=1;}moveBy+=directionFactor.current*moveBy*velocityFactor.get();baseX.set(baseX.get()+moveBy);});const spans=[];for(let i=0;i<numCopies;i++){spans.push(/*#__PURE__*/_jsx(\"span\",{ref:i===0?copyRef:null,style:{flexShrink:0,...font,color:textColor},children:children},i));}return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",overflow:\"hidden\",paddingTop:\"40px\",paddingBottom:\"40px\"},children:/*#__PURE__*/_jsx(motion.div,{style:{x,display:\"flex\",whiteSpace:\"nowrap\",textAlign:\"center\"},children:spans})});}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function ScrollVelocity(props){const{texts=[\"Divrsekit\",\"Scroll Down\"],velocity=100,damping=50,stiffness=400,numCopies=6,velocityInputMin=0,velocityInputMax=1e3,velocityOutputMin=0,velocityOutputMax=5,font,textColor}=props;const velocityMapping={input:[velocityInputMin,velocityInputMax],output:[velocityOutputMin,velocityOutputMax]};return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",position:\"relative\"},children:texts.map((text,index)=>/*#__PURE__*/_jsxs(VelocityText,{baseVelocity:index%2!==0?-velocity:velocity,damping:damping,stiffness:stiffness,numCopies:numCopies,velocityMapping:velocityMapping,font:font,textColor:textColor,children:[text,\"\\xa0\"]},index))});}addPropertyControls(ScrollVelocity,{texts:{type:ControlType.Array,title:\"Texts\",control:{type:ControlType.String},defaultValue:[\"DiverseKit\",\"Scroll Down\"],description:\"An array of text strings that will be animated or looped in sequence.\"},velocity:{type:ControlType.Number,title:\"Velocity\",defaultValue:100,min:-500,max:500,step:10,description:\"Controls the base speed of the text animation.\"},damping:{type:ControlType.Number,title:\"Damping\",defaultValue:50,min:1,max:100,step:1,description:\"Controls how quickly the motion slows down; higher values reduce bouncing.\"},stiffness:{type:ControlType.Number,title:\"Stiffness\",defaultValue:400,min:1,max:1e3,step:10,description:\"Defines how rigid or snappy the animation feels; higher values create a tighter spring.\"},numCopies:{type:ControlType.Number,title:\"Copies\",defaultValue:6,min:2,max:20,step:1,description:\"Sets how many copies of the text will be rendered in the looping animation.\"},velocityInputMin:{type:ControlType.Number,title:\"Input Min\",defaultValue:0,step:10,description:\"Defines the minimum input value for velocity mapping (e.g., scroll speed).\"},velocityInputMax:{type:ControlType.Number,title:\"Input Max\",defaultValue:1e3,step:10,description:\"Defines the maximum input value for velocity mapping (e.g., scroll speed).\"},velocityOutputMin:{type:ControlType.Number,title:\"Output Min\",defaultValue:0,step:.1,description:\"Sets the minimum output velocity value after mapping.\"},velocityOutputMax:{type:ControlType.Number,title:\"Output Max\",defaultValue:5,step:.1,description:\"Sets the maximum output velocity value after mapping.\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"200px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"},description:\"Choose and style the font for the animated text (size, weight, spacing, etc.).\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\",description:\"Sets the color of the displayed text.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollVelocity\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollFlowTextFX_3.map"],"mappings":"ySACgR,SAAS,EAAgB,EAAI,CAAC,GAAK,CAAC,EAAM,GAAUA,EAAS,EAAE,CAAkQ,OAAjQ,MAAoB,CAAC,SAAS,GAAa,CAAI,EAAI,SAAS,EAAS,EAAI,QAAQ,YAAY,CAAiB,GAAd,GAAa,CAAW,IAAS,OAA2D,OAA9C,EAAO,iBAAiB,SAAS,EAAY,KAAW,EAAO,oBAAoB,SAAS,EAAY,EAAI,CAAC,EAAI,CAAC,CAAQ,EAAO,SAAS,EAAa,CAAC,WAAS,eAAa,UAAQ,YAAU,YAAU,kBAAgB,OAAK,aAAW,CAAC,IAAM,EAAM,EAAe,EAAE,CAAM,CAAC,WAAS,GAAW,CAAoH,EAAe,EAAnE,EAA1C,EAAY,EAAQ,CAA+C,CAAC,UAAQ,YAAU,CAAC,CAAkD,EAAgB,MAAM,EAAgB,OAAO,CAAC,MAAM,GAAM,CAAC,CAAO,EA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