Lets a removal made by mistake be undone before the item leaves the list, by timing the fade-out of items leaving a list.

Functions

f
fadeClassName(phase: FadeState | undefined): string | undefined

Returns the class a fading card takes in phase, for DumpCard's className, or undefined for a card that isn't fading.

f
useFading(onFaded?: (id: string) => void): UseFadingResult

Returns the fading state of a list's items and the calls that drive it. onFaded is called with an item whose fade ran to its end, for the list to drop it; a cancelled fade doesn't call it. The timers are cleared on unmount.

Interfaces

I
UseFadingResult

Returned by useFading to useUpvotedList and usePlaylist. The list keeps showing an item while it is in fading.

Type Aliases

T
FadeState = "cooldown" | "dismissing"

Held by useFading for each fading item, and mapped to a CSS class by fadeClassName. cooldown lasts 2 seconds, and dismissing lasts the 350ms of the CSS collapse.