marquee
diceui-radix/marqueeFreeComponent
diceui/radix publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/radix-nova/marquee.jsonSource
1"use client";23import { cva, type VariantProps } from "class-variance-authority";4import {5 Direction as DirectionPrimitive,6 Slot as SlotPrimitive,7} from "radix-ui";8import * as React from "react";9import { useComposedRefs } from "@/lib/compose-refs";10import { cn } from "@/lib/utils";1112const ROOT_NAME = "Marquee";13const CONTENT_NAME = "MarqueeContent";1415type Side = "left" | "right" | "top" | "bottom";16type Orientation = "horizontal" | "vertical";17type Direction = "ltr" | "rtl";1819type RootElement = React.ComponentRef<typeof Marquee>;20type ContentElement = React.ComponentRef<typeof MarqueeContent>;2122interface Dimensions {23 width: number;24 height: number;25}2627interface ElementDimensions {28 rootSize: number;29 contentSize: number;30}3132function createResizeObserverStore() {33 const listeners = new Set<() => void>();34 let observer: ResizeObserver | null = null;35 const elements = new Map<Element, Dimensions>();36 const refCounts = new Map<Element, number>();37 const isSupported = typeof ResizeObserver !== "undefined";38 let notificationScheduled = false;3940 const snapshotCache = new WeakMap<41 Element,42 WeakMap<43 Element,44 { horizontal: ElementDimensions; vertical: ElementDimensions }45 >46 >();4748 function notify() {49 if (notificationScheduled) return;50 notificationScheduled = true;51 queueMicrotask(() => {52 notificationScheduled = false;53 for (const callback of listeners) {54 callback();55 }56 });57 }5859 function cleanup() {60 if (observer) {61 observer.disconnect();62 observer = null;63 }64 elements.clear();65 refCounts.clear();66 }6768 function subscribe(callback: () => void) {69 listeners.add(callback);70 return () => {71 listeners.delete(callback);72 if (listeners.size === 0) {73 cleanup();74 }75 };76 }7778 function getSnapshot(79 rootElement: RootElement | null,80 contentElement: ContentElement | null,81 orientation: Orientation,82 ): ElementDimensions | null {83 if (!rootElement || !contentElement) return null;8485 const rootDims = elements.get(rootElement);86 const contentDims = elements.get(contentElement);8788 if (!rootDims || !contentDims) return null;8990 const rootSize =91 orientation === "vertical" ? rootDims.height : rootDims.width;92 const contentSize =93 orientation === "vertical" ? contentDims.height : contentDims.width;9495 let rootCache = snapshotCache.get(rootElement);96 if (!rootCache) {97 rootCache = new WeakMap();98// … truncated
What it pulls in
npm packages
Files it writes
More from diceui/radix
All 58 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| action-baraction-bar | diceui/radix | Components | Free | 1 dep · 2 files | |
| angle-sliderangle-slider | diceui/radix | Components | Free | 1 dep · 3 files | |
| avatar-groupavatar-group | diceui/radix | Components | Free | 1 dep | |
| badge-overflowbadge-overflow | diceui/radix | Components | Free | 1 dep · 2 files | |
| bannerbanner | diceui/radix | Components | Free | 1 dep | |
| checkbox-groupcheckbox-group | diceui/radix | Components | Free | 1 dep | |
| circular-progresscircular-progress | diceui/radix | Components | Free | 1 dep | |
| client-onlyclient-only | diceui/radix | Components | Free | no deps |
