Shelf Drop
Six prints on a picture ledge. Press one to knock it off, in front of the shelf or behind it.
Press a print to knock it off the shelf.
Six photographic prints stand on a picture ledge. Press one and it topples off. Which side it lands on is chosen for you: a card that drops in front of the ledge passes over its lip and grows on the way down, and one that drops behind goes under the lip and comes out below smaller than it went in. Press "Put them back" and each print is set down again in turn.
With the keyboard, tab to a print and press Enter or Space. Focus moves to the next print still standing, so the whole row can be cleared without leaving the keys.
How it works
- The side is depth, not z-index. The scene is
preserve-3d, so the browser paints by depth. The ledge's lip is a plane that a card is either in front of or behind, and the fall is the same motion with a different sign on one number. - Gravity accelerates and a tumble does not. The card's
yeases in, like a falling body, while its spin, drift and depth run linear. Put them on one curve and the spin appears to speed up, and the card reads as thrown rather than dropped. - It topples, it doesn't spin. A knocked print pivots on the edge it was standing on and goes over forwards or backwards, leaning the way it is going. Past ninety degrees you see the back of the print, which is plain paper.
- The throw is rolled once. Side, spin, drift, tilt and duration are decided on the press and kept, so a card never changes its mind mid-fall.
- The sides come from a bag, not a coin. Each refill holds one of each side per print, shuffled, and never opens on the side the last bag closed on, so you don't get a run of five backs.
- The hover is a separate layer. The button owns the fall and the hit area. A nested layer owns the small tip toward you on hover, so the two never fight over
rotateX. - Putting them back is a hand, not a rewind. A spring with no bounce, staggered across the row, rather than the fall played backwards.
- Reduced motion replaces the fall with a fade where the print stands, and drops the hover tip.
A print that has been knocked off is inert, so you can't tab to or press one you can't see. "Put them back" is inert until there is something to put back.
Installation
Usage
import ShelfDrop from "@/components/ui/shelf-drop";
<ShelfDrop />;The component draws its own 400px stage and fits the row to the width of its container. Pass className to change the wrapper, hint to change the line under the stage (or false to remove it), and prints and gap to stand your own on the ledge. A print is a size, a resting lean and a picture, defined by the Print type in items.ts: a src, or four colours for the original sky-over-ground. The pictures keep their own palette, since a photograph's colours are the object.
API
| Prop | Type | Default | Description |
|---|---|---|---|
prints | readonly Print[] | six prints | What stands on the ledge, in order. |
gap | number | 18 | Space between prints, in stage pixels. |
hint | string | false | a short line | The line under the stage. false hides it. |
className | string | - | Classes for the outer wrapper. |
Pictures
The six prints are public-domain works from the Metropolitan Museum of Art's Open Access collection, released under CC0. Each is cropped to 3:4 and lightly graded, and they are hosted on this site, so the component adds no image weight to your bundle. Pass your own prints for anything you ship.
- Shower: Utagawa Hiroshige, Sudden Shower over Shin-Ōhashi Bridge and Atake, 1857
- Carp: Yashima Gakutei, Carp and Pine
- Crane: Yashima Gakutei, White Crane Flying across the Sun's Disc
- Cypress: Vincent van Gogh, Cypresses, 1889
- Moon: John Adams Whipple, The Moon, 1857-60
- Snow: Utagawa Hiroshige, Evening Snow at Kanbara, ca. 1833-34