Simple Carousel
fancy/simple-carouselFreeComponent
A ui component.
Install it
npx shadcn@latest add https://www.fancycomponents.dev/r/simple-carousel.jsonSource
1import { RefObject, useRef } from "react"2import {3 motion,4 SpringOptions,5 useAnimationFrame,6 useMotionValue,7 useScroll,8 useSpring,9 useTransform,10 useVelocity,11} from "motion/react"1213import { cn } from "@/lib/utils"1415// Custom wrap function16const wrap = (min: number, max: number, value: number): number => {17 const range = max - min18 return ((((value - min) % range) + range) % range) + min19}2021interface SimpleMarqueeProps {22 children: React.ReactNode // The elements to be scrolled23 className?: string // Additional CSS classes for the container24 direction?: "left" | "right" | "up" | "down" // The direction of the marquee25 baseVelocity?: number // The base velocity of the marquee in pixels per second26 easing?: (value: number) => number // The easing function for the animation27 slowdownOnHover?: boolean // Whether to slow down the animation on hover28 slowDownFactor?: number // The factor to slow down the animation on hover29 slowDownSpringConfig?: SpringOptions // The spring config for the slow down animation30 useScrollVelocity?: boolean // Whether to use the scroll velocity to control the marquee speed31 scrollAwareDirection?: boolean // Whether to adjust the direction based on the scroll direction32 scrollSpringConfig?: SpringOptions // The spring config for the scroll velocity-based direction adjustment33 scrollContainer?: RefObject<HTMLElement | null> | HTMLElement | null // The container to use for the scroll velocity34 repeat?: number // The number of times to repeat the children.35 draggable?: boolean // Whether to allow dragging of the marquee36 dragSensitivity?: number // The sensitivity of the drag movement37 dragVelocityDecay?: number // The decay of the drag velocity. This means how fast the velocity will gradually reduce to baseVelocity when we release the drag38 dragAwareDirection?: boolean // Whether to adjust the direction based on the drag velocity39 dragAngle?: number // The angle of the drag movement in degrees. This is useful if you eg. rotating your marquee by 45 degrees40 grabCursor?: boolean // Whether to change the cursor to grabbing when dragging41}4243const SimpleMarquee = ({44 children,45 className,46 direction = "right",47 baseVelocity = 5,48 slowdownOnHover = false,49 slowDownFactor = 0.3,50 slowDownSpringConfig = { damping: 50, stiffness: 400 },51 useScrollVelocity = false,52 scrollAwareDirection = false,53 scrollSpringConfig = { damping: 50, stiffness: 400 },54 scrollContainer,55 repeat = 3,56// … truncated
What it pulls in
npm packages
Files it writes
More from fancy
All 158 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Gradient With Svganimated-gradient-with-svg | fancy | Components | Free | no deps | |
| Basic Number Tickerbasic-number-ticker | fancy | Components | Free | 1 dep | |
| Box Carouselbox-carousel | fancy | Components | Free | 1 dep | |
| Breathing Textbreathing-text | fancy | Components | Free | 1 dep | |
| Circling Elementscircling-elements | fancy | Components | Free | 1 dep | |
| Css Boxcss-box | fancy | Components | Free | 1 dep | |
| Cursor Attractor And Gravitycursor-attractor-and-gravity | fancy | Components | Free | 5 deps | |
| Drag Elementsdrag-elements | fancy | Components | Free | 1 dep |
