BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/componentry/scroll-based-velocity

scroll-based-velocity

componentry/scroll-based-velocity
FreeComponent

Text that scrolls across the screen and skews/speeds up based on the users scroll velocity.

Live preview

live · rendered by the registry
Rendered by componentry on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://componentry.dev/r/scroll-based-velocity.json

Source

components/ui/scroll-based-velocity.tsxcomponentry.dev/r/scroll-based-velocity.json
1"use client";
2
3import React, { useRef } from "react";
4import {
5 motion,
6 useScroll,
7 useSpring,
8 useTransform,
9 useMotionValue,
10 useVelocity,
11 useAnimationFrame,
12 wrap,
13} from "framer-motion";
14import { cn } from "@workspace/ui/lib/utils";
15
16interface ScrollBasedVelocityProps {
17 text: string;
18 default_velocity?: number;
19 className?: string;
20 containerRef?: React.RefObject<HTMLElement | null>;
21}
22
23interface ParallaxProps {
24 children: string;
25 baseVelocity: number;
26 className?: string;
27 containerRef?: React.RefObject<HTMLElement | null>;
28}
29
30function ParallaxText({ children, baseVelocity = 100, className, containerRef }: ParallaxProps) {
31 const baseX = useMotionValue(0);
32 const { scrollY } = useScroll(containerRef ? { container: containerRef } : undefined);
33 const scrollVelocity = useVelocity(scrollY);
34 const smoothVelocity = useSpring(scrollVelocity, {
35 damping: 50,
36 stiffness: 400,
37 });
38 const velocityFactor = useTransform(smoothVelocity, [0, 1000], [0, 5], {
39 clamp: false,
40 });
41
42 /**
43 * This is a magic wrapping for the length of the text - you
44 * have to replace for wrapping that works for you or dynamically
45 * calculate
46 */
47 const x = useTransform(baseX, (v) => `${wrap(-12.5, 0, v)}%`);
48
49 const directionFactor = useRef<number>(1);
50 useAnimationFrame((t, delta) => {
51 let moveBy = directionFactor.current * baseVelocity * (delta / 1000);
52
53 /**
54 * This is what changes the direction of the scroll once we
55 * switch scrolling directions.
56 */
57 if (velocityFactor.get() < 0) {
58 directionFactor.current = -1;
59 } else if (velocityFactor.get() > 0) {
60 directionFactor.current = 1;
61 }
62
63 moveBy += directionFactor.current * moveBy * velocityFactor.get();
64
65 baseX.set(baseX.get() + moveBy);
66 });
67
68 return (
69 <div className="overflow-hidden whitespace-nowrap flex flex-nowrap" style={{ width: '100%' }}>
70 <motion.div
71 className={cn("flex whitespace-nowrap", className)}
72 style={{ x }}
73 >
74 {Array.from({ length: 8 }).map((_, i) => (
75 <span key={i} className="block mr-10 last:mr-10">{children}</span>
76 ))}
77 </motion.div>
78 </div>
79 );
80}
81
82export function ScrollBasedVelocity({
83 text,
84 default_velocity = 5,
85 className,
86 containerRef,
87// … truncated

Facts

Registry
componentry
Type
registry:ui
Access
Free
Files written
0
Licence
MIT
First indexed
2026-08-02
Last confirmed
yesterday

Go to the source

Docs on componentry componentry.dev harshjdhv/componentry on GitHub Raw registry item This item as JSON

More from componentry

All 59 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Animated Gradientanimated-gradientcomponentryComponentsFreeno deps
ASCII Effectascii-effectcomponentryComponentsFreeno deps
Aurora Flowaurora-flowcomponentryComponentsFreeno deps
auth-modalauth-modalcomponentryComponentsFreeno deps
border-beamborder-beamcomponentryComponentsFreeno deps
circuit-boardcircuit-boardcomponentryComponentsFreeno deps
closing-plasmaclosing-plasmacomponentryComponentsFreeno deps
collection-surfercollection-surfercomponentryComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex