marquee
diceui-base/marqueeFreeComponent
diceui/base publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/base-vega/marquee.jsonSource
1"use client";23import { mergeProps } from "@base-ui/react/merge-props";4import { useRender } from "@base-ui/react/use-render";5import { cva, type VariantProps } from "class-variance-authority";6import * as React from "react";7import { cn } from "@/lib/utils";8import { useComposedRefs } from "@/registry/bases/base/lib/compose-refs";9import { useDirection } from "@/registry/bases/base/ui/direction";1011const ROOT_NAME = "Marquee";12const CONTENT_NAME = "MarqueeContent";1314type Side = "left" | "right" | "top" | "bottom";15type Orientation = "horizontal" | "vertical";16type Direction = "ltr" | "rtl";1718type RootElement = HTMLDivElement;19type ContentElement = HTMLDivElement;2021interface Dimensions {22 width: number;23 height: number;24}2526interface ElementDimensions {27 rootSize: number;28 contentSize: number;29}3031function createResizeObserverStore() {32 const listeners = new Set<() => void>();33 let observer: ResizeObserver | null = null;34 const elements = new Map<Element, Dimensions>();35 const refCounts = new Map<Element, number>();36 const isSupported = typeof ResizeObserver !== "undefined";37 let notificationScheduled = false;3839 const snapshotCache = new WeakMap<40 Element,41 WeakMap<42 Element,43 { horizontal: ElementDimensions; vertical: ElementDimensions }44 >45 >();4647 function notify() {48 if (notificationScheduled) return;49 notificationScheduled = true;50 queueMicrotask(() => {51 notificationScheduled = false;52 for (const callback of listeners) {53 callback();54 }55 });56 }5758 function cleanup() {59 if (observer) {60 observer.disconnect();61 observer = null;62 }63 elements.clear();64 refCounts.clear();65 }6667 function subscribe(callback: () => void) {68 listeners.add(callback);69 return () => {70 listeners.delete(callback);71 if (listeners.size === 0) {72 cleanup();73 }74 };75 }7677 function getSnapshot(78 rootElement: RootElement | null,79 contentElement: ContentElement | null,80 orientation: Orientation,81 ): ElementDimensions | null {82 if (!rootElement || !contentElement) return null;8384 const rootDims = elements.get(rootElement);85 const contentDims = elements.get(contentElement);8687 if (!rootDims || !contentDims) return null;8889 const rootSize =90 orientation === "vertical" ? rootDims.height : rootDims.width;91 const contentSize =92 orientation === "vertical" ? contentDims.height : contentDims.width;9394// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from diceui/base
All 192 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| action-baraction-bar | diceui/base | Components | Free | 1 dep | |
| angle-sliderangle-slider | diceui/base | Components | Free | 1 dep · 3 files | |
| avatar-groupavatar-group | diceui/base | Components | Free | 1 dep | |
| badge-overflowbadge-overflow | diceui/base | Components | Free | 1 dep · 2 files | |
| bannerbanner | diceui/base | Components | Free | 1 dep | |
| circular-progresscircular-progress | diceui/base | Components | Free | 1 dep | |
| client-onlyclient-only | diceui/base | Components | Free | no deps | |
| color-pickercolor-picker | diceui/base | Components | Free | 1 dep · 2 files |
