Unroll
v1.0.0An image rolled up like a scroll, in grey. Point at it, or tap it, and it unrolls flat as its colour comes in; move away and it rolls back up. Shows the plain image under reduced motion.
Installation
Run once in your project root to configure paths and dependencies:
npx vectorvesper initDownloads and registers the component in your project:
npx vectorvesper add unrollIf installing manually or managing your package lock:
npm install @vectorvesper/motion threeUsage
A single feature image that should reward a hover: a case study cover, a product photo, a gallery piece. The image fits inside the area whole, with room left round it for the roll.
Import
Usage
Do
- Write alt text: the component is announced as an image.
- Pick a colourful image when grayscale is on, so the colour arriving is the payoff.
Don't
- Do not set rest to 1 and expect a hover effect: it then rests fully open.
WebGL — render it on the client only
On Next.js, load it with ssr: false from a Client Component, as below. Vite apps need nothing extra.
prefers-reduced-motion and provides a graceful fallback.Props
An image rolled up like a scroll, in grey. Point at it, or tap it, and it unrolls flat as its colour comes in; move away and it rolls back up.
<Unroll />
The rolled image. Fills the area, which is 100svh tall unless you size it, and fits the image inside it.
| Prop | Type | Default | Description |
|---|---|---|---|
src* | string | — | The image. |
alt* | string | — | What the image shows, for screen readers. |
turns | number | 2 | How many times the image wraps round when rolled. |
radius | number | 0.17 | How thick the roll is, as a share of the image's width. |
speed | number | 2 | How quickly it unrolls and rolls back. |
grayscale | boolean | true | Rolled up, the image is grey, and its colour comes in as it opens. |
rest | number | 0 | How far open it rests, 0 rolled to 1 flat. |
className | string | — | Sizes the area. The image fits inside it, whole. Without a height it is 100svh tall. |
style | React.CSSProperties | — | Inline styles for the area. A height here wins over the default. |