Rotate on Scroll
A 100 px tile and the icon it carries make two full turns while the area scrolls from top to bottom: a quarter turn every 65 px, one turn at mid-scroll. A single rule, animation-timeline: scroll(), on a whole block — no JavaScript, and everything runs backwards when you scroll up.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Scroll has 74 effects, including 12 free. Explore the category →
3 usage examples



How it works
The animated element is .sb-rotscroll-shape: a 100 px square with 16 px corners, an indigo → fuchsia gradient, centring a 40 px SVG. It gets @keyframes fx0549Rotate, a single keyframe, to { transform: rotate(720deg) }, and the declaration animation-timeline: scroll(). With no argument, scroll() means the first scrolling area above the tile: the animation's progress becomes that area's position, 0% at the top, 100% at the bottom. Because the rotation is set on the block and not on a stroke drawn inside it, everything it holds turns with it — icon, background, a shadow if you add one.
In the demo the area is 280 px tall and the .sb-rotscroll-content tray 800: 520 px of travel for 720°, i.e. 1.385° per pixel. Read in Chromium 149 and WebKit 26.5: 138° at 100 px, 360° (tile upright again) at 260 px, 554° at 400 px, 720° at the end stop; both engines return the same matrix. Interpolation is linear: the tile turns at the speed of the gesture, stops with it, runs backwards when you scroll up. The tile sits in the flow, in the middle of the tray: it crosses the frame from bottom to top. You see it from 68 to 452 px of scrolling, whole from 183 to 337 px — so about 530° of the 720° pass before your eyes, and the frame is empty when it opens and at the end, where only the caption comes in (at 487 px).
The original animation was left alone; what surrounds it was repaired. Selectors hang from .fx-0549-root and the animation is renamed fx0549Rotate: the catalogue holds another effect with almost the same name that shares the area's classes, and both now live on one page. The area gains overflow-x: hidden — a turning square sweeps its diagonal, 141 px, and used to open a horizontal bar in a narrower column. Added as well: keyboard focus, the reduced-motion rule, and a readable caption (white at 60% instead of 30%).
Accessibility
- Reduced motion: two full turns of an object while you read is exactly what the system setting asks to avoid. Under
prefers-reduced-motion: reducethe animation is removed: the tile stays upright and scrolls with the content like a picture. The hint stops pulsing and scroll jumps are no longer smoothed. - Tile content: put nothing that must be read inside a turning block — a figure or a word is upside down half the time. The SVG carries
aria-hidden="true"; if it means something (a logo, a state), give that meaning as text next to it. The.sb-rotscroll-labelcaption does not turn and is read normally. - Keyboard: the area is reachable with Tab (
tabindex="0",role="region", a name to adapt) and shows a violet outline; each arrow press scrolls 40 px in Chromium, i.e. 55° of rotation. Recorded in Chromium, Firefox and WebKit — the last one skipped the area in the original code. - Contrast and touch: the icon's white stroke reaches 4.5:1 on the indigo side of the tile and 3.5:1 on the fuchsia side (computed); the tile itself stands at 4.4:1 from the background. With a finger the area scrolls natively (150 px swiped, 151 px recorded in touch emulation). On a phone, scroll inertia should carry the rotation on after release: expected, but not verified on a device.
Browser compatibility
CSS only: the floor is that of animation-timeline: scroll() — Chrome and Edge 115, Safari 26, Firefox 159 according to MDN. Identical angles in Chromium 149 and WebKit 26.5 at the four positions recorded. Firefox 151 does not read the rule: the tile stays upright, visible, and crosses the frame without turning. No JavaScript fallback is supplied for that case. Still to be tried: Firefox 159 and later, Safari on a Mac and on an iPhone.
The rotation is declared inside @supports (animation-timeline: scroll()). A browser that fails that test shows the tile at 0°, its icon the right way up: the object stays, the motion is missing. If the rotation means something on your page (a step, a direction), provide that meaning another way for those visitors.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0549-root">
<div class="sdc-scroll-container" tabindex="0" role="region" aria-label="…">
<div class="sb-rotscroll-content">
<div class="sb-rotscroll-shape">
<svg viewBox="0 0 24 24" aria-hidden="true">…</svg>
</div>
<span class="sb-rotscroll-label">…</span>
</div>
</div>
<span class="sdc-scroll-hint" aria-hidden="true">…</span>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Total angle (CSS — @keyframes fx0549Rotate { to { transform: rotate(720deg) } }) |
720°, two turns | 360° for a single turn, 90° for a quarter, a negative value to turn the other way. For a wheel of diameter d to look as if it rolls: angle = travel × 360 ÷ (π × d). |
Tile (CSS — .sb-rotscroll-shape: width, height, border-radius, background) |
100 × 100 px, 16 px corners, gradient #6366f1 → #d946ef | border-radius: 50% gives a disc: the rotation then only shows through what it contains. A tile of side c sweeps c × 1.41 in width. |
Icon (HTML — the svg; CSS — .sb-rotscroll-shape svg) |
three stacked diamonds, 40 px, white 1.5 stroke | Replace it with your drawing or an image. A shape with no symmetry (arrow, letter, valve) makes each quarter turn readable; a symmetrical one looks still. |
Tile position (CSS — .sb-rotscroll-content { align-items: center }) |
middle of the tray, in the flow | To keep it in view for the whole travel: align-items: flex-start on the tray, then position: sticky; top: 90px; margin-top: 90px on the tile. |
Travel (CSS — .sb-rotscroll-content { height: 800px }, .sdc-scroll-container { height: 280px }) |
800 − 280 = 520 px, i.e. 1.385° per pixel | Rotation speed is the angle divided by the travel. With no height and no overflow-y on the area, the whole page turns the tile. |
Caption and hint (HTML — .sb-rotscroll-label, .sdc-scroll-hint) |
a sentence at the bottom of the tray, “Scroll ↓” over the frame | Two demo texts, to delete or rewrite. The caption only shows over the last 33 pixels of the travel. |
FAQ
align-items: flex-start on .sb-rotscroll-content, position: sticky; top: 90px; margin-top: 90px on .sb-rotscroll-shape. Two of the three examples above do so.scroll-snap-type: y mandatory on the area and scroll-snap-align: start on each section (a lead not tried here). Eight equal sections give eight quarter turns: the travel is then eight area heights, and each stop falls on a multiple of 90°.