Scroll Velocity
Web (React)
A marque text effect whose speed scales dynamically based on scroll velocity.
A high-performance text marquee powered by framer-motion's useVelocity, useScroll, and useTransform. As the user scrolls faster, the text marquee speed multiplies dynamically.
MODUS UI
REACT COMPONENTS
FRAMER MOTION
Installation
CLI
npx @modus-ui/cli add scroll-velocityManual
- Copy the code from the component tab.
- Create a file at
components/ui/scroll-velocity.tsx. - Paste the code.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
scrollContainerRef | React.RefObject<HTMLElement> | - | Scroll container to track instead of the window. |
texts | string[] | [] | One scrolling row per string. |
velocity | number | 100 | Base speed of the rows. |
damping | number | 50 | Damping of the scroll-velocity spring. |
stiffness | number | 400 | Stiffness of the scroll-velocity spring. |
numCopies | number | 6 | Copies of the text per row. |
velocityMapping | { input: number[]; output: number[] } | { input: [0, 1000], output: [0, 5] } | Maps scroll velocity to the speed multiplier. |
parallaxClassName | string | - | Classes for each row's container. |
scrollerClassName | string | - | Classes for each moving row. |
parallaxStyle | React.CSSProperties | - | Inline styles for each row's container. |
scrollerStyle | React.CSSProperties | - | Inline styles for each moving row. |
Comments