Lab

useTrackReorder

Reorders tracks: drag a track's grip to move it, with the view scrolling at its edges and a copy of its header under the pointer, or press Up and Down on the grip. With the grip, the copy and the line where the track would land.

pnpm dlx shadcn@latest add @audio-ui/use-track-reorder
import { useTrackReorder } from "@/hooks/use-track-reorder";
Fileshooks/use-track-reorder.ts, components/audio-ui/track-grip.tsx
Depends onsortable-drag
npmNothing
Used byarrangement-editor, arrangement-view, block-timeline
ExportKindWhat it is
TrackGhostinterfaceThe copy of a track's header that follows the pointer: draw it fixed, at this box, with ref on it.
useTrackReorderfunctionReorders the tracks of a timeline: drag a track's grip to move it, or press Up or Down on it.

Usage

useTrackReorder moves tracks: give each track a grip, and drag the grip, or press Up or Down on it. The copy of the dragged track's header follows the pointer, the others slide aside, and the view scrolls at its edges, with no render while it moves (sortable-drag). The grip and the copy are TrackGrip and TrackReorderGhost, installed with it.

It is one of the parts the Arrangement composes.

API

Props · 7

Built by Ouest Labs, the source code is available on GitHub.
RSS