{"version":3,"file":"ScrollMotionTextFX.Bat8xToh.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/5A7Dd4aqASk3y43ik76e/H9aYFD0Z0V9wcgcYfFjx/ScrollMotionTextFX.js"],"sourcesContent":["// ScrollVelocity.tsx\n\"use client\"// if using Next.js App Router\n;import{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();window.addEventListener(\"resize\",updateWidth);return()=>{window.removeEventListener(\"resize\",updateWidth);};},[ref]);return width;}function VelocityText({children,baseVelocity,damping,stiffness,numCopies,velocityMapping,font,textColor,style}){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;// modulo wrap\nconst mod=((v-min)%range+range)%range;return mod+min;}const x=useTransform(baseX,v=>{if(copyWidth===0)return\"0px\";const wrapped=wrap(-copyWidth,0,v);return`${wrapped}px`;});const directionFactor=useRef(1);useAnimationFrame((t,delta)=>{const velocityVal=velocityFactor.get();// flip direction when user scrolls opposite\nif(velocityVal<0){directionFactor.current=-1;}else if(velocityVal>0){directionFactor.current=1;}const moveBy=directionFactor.current*baseVelocity*(delta/1e3);const additional=directionFactor.current*moveBy*velocityVal;baseX.set(baseX.get()+moveBy+additional);});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,whiteSpace:\"pre\",...style},children:children},i));}return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",overflow:\"hidden\",width:\"100%\"},children:/*#__PURE__*/_jsx(motion.div,{style:{x,display:\"flex\",whiteSpace:\"nowrap\",textAlign:\"center\"},children:spans})});}export default function ScrollVelocity(props){const{texts=[\"DiverseKit\",\"Scroll Down\"],velocity=100,damping=50,stiffness=400,numCopies=6,velocityInputMin=0,velocityInputMax=1e3,velocityOutputMin=0,velocityOutputMax=5,font,textColor,style}=props;const velocityMapping={input:[velocityInputMin,velocityInputMax],output:[velocityOutputMin,velocityOutputMax]};return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",position:\"relative\",...style},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:\"80px\",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.\"},style:{type:ControlType.Object,title:\"Container Style\",defaultValue:{},description:\"Optional additional style for the outer container.\",controls:\"extended\",defaultFontType:\"sans-serif\",description:\"More Components at [DiverseKit](https://framer.link/se2heI4)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollVelocity\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollMotionTextFX.map"],"mappings":"wSAEiR,SAAS,EAAgB,EAAI,CAAC,GAAK,CAAC,EAAM,GAAUA,EAAS,EAAE,CAAoO,OAAnO,MAAoB,CAAC,SAAS,GAAa,CAAI,EAAI,SAAS,EAAS,EAAI,QAAQ,YAAY,CAA+D,OAA5D,GAAa,CAAC,EAAO,iBAAiB,SAAS,EAAY,KAAW,CAAC,EAAO,oBAAoB,SAAS,EAAY,GAAK,CAAC,EAAI,CAAC,CAAQ,EAAO,SAAS,EAAa,CAAC,WAAS,eAAa,UAAQ,YAAU,YAAU,kBAAgB,OAAK,YAAU,SAAO,CAAC,IAAM,EAAM,EAAe,EAAE,CAAM,CAAC,WAAS,GAAW,CAAoH,EAAe,EAAnE,EAA1C,EAAY,EAAQ,CAA+C,CAAC,UAAQ,YAAU,CAAC,CAAkD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