Slingshot
A slideshow of images and videos that hands each frame to the next through a gravity well. The frame on show winds into a tilted, ringed disc around the pull point, the disc turns, and the next frame unwinds out of it. Plays on its own, and a click moves the pull point.
Included with membership
Members install Slingshot with one command and get the full source, the usage code and the Framer remix, licensed for client work. One membership covers the whole library and the CLI.
When to use it
A hero or a lookbook where a few strong pictures or short films take turns: a collection, a portfolio, a launch reel. It fills its box, so give the box a height, usually the screen's.
- Use seamless loops for films, so one never jumps while it holds.
- Use fit="contain" for pictures of different shapes, so each floats whole on the background. cover crops each one to fill the frame.
- Give every item alt text. The slideshow tells screen readers which item is showing.
- Leave light as "media" to light the disc in the colours of the frames themselves, or pass a near and a far colour to match a brand.
Avoid:
- Do not set the hold much shorter than the default. Each hand-over takes its own few seconds on top, and a slideshow that never rests is hard to watch.
- Do not put two on one page. Each draws a scene the size of its box.
Props
A slideshow of images and videos that hands each frame to the next through a gravity well. The frame on show winds into a tilted, ringed disc around the pull point, the disc turns, and the next frame unwinds out of it. It plays on its own, and a click moves the pull point to where you clicked.
<Slingshot />
The slideshow. It fills the element it renders, so give that element a height.
| Prop | Type | Default | Description |
|---|---|---|---|
items* | (string | SlingshotItem)[] | — | The images and videos, in order: each a path, or an item with its type and alt text. |
interval | number | 3 | Seconds each item holds before the next is pulled in. |
duration | number | 4.5 | Seconds for one hand-over, in and back out. |
dwell | number | 0.2 | Share of the hand-over spent as a turning disc, between the pull in and the release. |
autoPlay | boolean | true | Moves on to the next item on its own. Off, only a click hands over. |
fit | "cover" | "contain" | "cover" | cover fills the frame; contain floats each item on the background. |
inset | number | 0.8 | contain only: the share of the frame an item may fill. |
background | string | "#000000" | The colour behind the frames. |
light | "media" | readonly [string, string] | "media" | "media" lights the disc in the colours of the frames themselves; or a near and a far colour. |
radius | number | 0.42 | Disc size, as a share of the frame's height. |
tilt | number | -12 | Disc tilt in degrees. |
squash | number | 0.34 | Height of the disc against its width: 1 is seen face on, lower is more side on. |
spin | number | 0.8 | Turns the disc makes over one hand-over. |
streak | number | 0.6 | Length of the streaks, 0 to 1. |
flare | number | 1 | Strength of the light and the flare, 0 to 2. |
label | string | "Slideshow" | What a screen reader calls the slideshow. |
onChange | (index: number) => void | — | Called with the index of the item now on show. |
onPull | (pull: SlingshotPull) => void | — | Called as each hand-over starts, with the items it goes from and to and where it pulls. |
className | string | — | Class for the outer element, which the slideshow fills. |
style | React.CSSProperties | — | Style for the outer element. |
<SlingshotItem />
typeOne image or video, when a plain path is not enough.
| Prop | Type | Default | Description |
|---|---|---|---|
src* | string | — | The image or video. |
type | "image" | "video" | — | Read from the file extension when left out. |
alt | string | — | What a screen reader says for it. |
<SlingshotPull />
typeWhat onPull receives as each hand-over starts.
| Prop | Type | Default | Description |
|---|---|---|---|
from* | number | — | The item handed over. |
to* | number | — | The item coming in. |
x* | number | — | The pull point, as a share of the width from the left. |
y* | number | — | The pull point, as a share of the height from the top. |