Scroll Spin

@sushindustries/ui

Rotates its children with the page scroll.

2 min read
View as Markdown

Rotates whatever you put inside it as the page scrolls. Drag the viewport buttons to see it at three widths - the amount of rotation per screen scrolled is the same at every one.

Viewport width
Desktop100%whatever the page has
tanstacktanstack add https://adamjurek.com/r/tanstack/scroll-spin.jsonshadcnpnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/scroll-spin.json

The rotation is written straight onto the node in a requestAnimationFrame callback, never through React state. At 60fps a state-driven version re-renders the subtree on every frame of every scroll, which is the one thing guaranteed to make a light page feel heavy.

Reduced motion

Anyone with reduced motion set gets a still image. The effect never starts, rather than starting and being cancelled.

Install

tanstack add https://adamjurek.com/r/tanstack/scroll-spin.json
shell
pnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/scroll-spin.json
shell
pnpm add @sushindustries/ui @sushindustries/atoms
shell

What you get

Version0.1.0
Categorymotion · Scroll effects
Filesscroll-spin.tsx, use-scroll-turn.ts
DependenciesNone
Also installsuse-scroll-turnuseScrollTurnScroll position as a rotation, delivered once per frame. Drives a CSS transform or a three.js object, never React state.@sushindustries/ui · motion
Tagsscroll, transform, no-deps

No runtime dependencies

It brings nothing with it beyond the stylesheet.

UsesuseScrollTurnuseScrollTurnScroll position as a rotation, delivered once per frame. Drives a CSS transform or a three.js object, never React state.@sushindustries/ui · motion