Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

GitHub Engineering 4 min read How-to mediumAdept

How to make Storybook Interactions respect user motion preferences

Storybook's Interactions addon auto-plays simulated user interactions on page load and ignores the OS-level prefers-reduced-motion setting, which can disorient users or trigger seizures in people with photosensitive epilepsy or vertigo. A custom toolbar addon fixes this. It stores an interaction preference in localStorage, defaults it to disabled when matchMedia('(prefers-reduced-motion)') matches and no preference exists yet, and reloads the page when the user toggles it. Each story's play function then checks a shouldInteractionPlay() helper before running, so all users can opt in or out without changing OS settings.

Assumes: React hooksStorybook stories and play functions

Related posts

  • Improving the Storage Access API in Firefox

    Mozilla Hacks mediumAdept

    Ahead of enabling State Partitioning for all users, Firefox is changing its Storage Access API implementation in four ways. Automatic storage grants now require recent user interaction with the third party, and accepted prompts or iframe interactions count as interaction. Permissions are scoped to the Site rather than the origin, which fixes login flows that move across subdomains. Interaction rules are tightened: denying a prompt clears the interaction, accepting resets its timer, and a reload requires new interaction. When third-party cookies are blocked, requestStorageAccess always rejects and hasStorageAccess returns false starting in Firefox 98.

  • What the iPhone Duo means for web development

    Mux mediumAdept

    Safari on the foldable iPhone Duo exposes the Device Posture API and Viewport Segments API behind WebKit feature flags. They let pages detect a folded posture via `navigator.devicePosture` or `@media (device-posture: folded)` and position content per screen segment with `env(viewport-segment-*)` variables. Using these plus a flagged Fullscreen API, a Netflix-style folded video player was built from Video.js v10 components, with video on the top half and tiled controls on the bottom. A blurred, mirrored reflection is drawn by copying frames to a small canvas via requestVideoFrameCallback, since -webkit-box-reflect doesn't work on video in iOS Safari. In practice it needs three feature flags on iOS, and Chromium on a Pixel Fold clips fullscreen content to the top half, so the design isn't shippable today.

  • Two lines of Cross-Document View Transitions code you can use on every website today

    WebKit mediumAdept

    Adding `@view-transition { navigation: auto; }` to a site's CSS enables cross-document View Transitions, so elements shared between pages stay fixed and everything else crossfades instead of flashing blank between navigations. A simple crossfade doesn't introduce motion and generally needn't be disabled under `prefers-reduced-motion`. Support covers Safari 18.2, Chrome 126 and Edge 126 (about 85% of users), and unsupported browsers simply ignore the rule, making it a safe progressive enhancement.

  • Building Custom Animations in the Workflow Builder

    Slack Engineering mediumAdept

    Slack's Workflow Builder added drag-and-drop from a new steps sidebar into workflows by moving react-beautiful-dnd's DragDropContext to wrap the whole builder page, with two draggable/droppable lists. A custom context provider holds drag state fed by the library's responders. On top of that the team built several workarounds: custom transforms to re-center differently sized steps, DOM-measured dynamic placeholders the library doesn't support, and a velocity-based tilt effect driven by requestAnimationFrame. A key lesson was hiding hint boxes in onBeforeCapture rather than onBeforeDragStart, because only the former runs before the library measures the DOM.

  • Managing Focus Transitions in Slack

    Slack Engineering mediumAdept

    Slack built FocusTransitionManager, a React Context-based coordinator that lets sender components request focus moves via transitionFocusTo({focusKey}) and receiver components claim them via shouldTransitionFocus, so keyboard and screen-reader users don't lose focus when React re-renders remove the focused element. Extensions include focusMetadata for targeting specific items, forceFocus for non-keyboard users, an additionalCondition callback to defer focus until data loads, timeouts to reset stale requests, and first-request-wins handling of concurrent requests. It was adopted across 100+ user flows within months, wired into the routing layer to focus the likely next action in each view, and built into Modal so all menus, popovers and modals restore focus reliably.

The quest for software engineering knowledge.

Look:
Layout: