feat(memory-graph): respect prefers-reduced-motion - #1576
Open
abhay-codes07 wants to merge 1 commit into
Open
Conversation
The graph is in near-constant motion — the force simulation animates nodes into place on load and keeps settling, panning has fling momentum, and zoom/centering ease via a spring. There was no path for users who set "reduce motion", even though the rest of the app honors it (loaders, confetti, the review modal). Honor prefers-reduced-motion in the two engines that drive that motion, with no loss of functionality: - ForceSimulation: pre-settle as usual, then stay static instead of running the perpetual settle; reheat() (fired on drag) is a no-op. Dragging still moves the grabbed node directly, so interaction is unchanged — just no neighbour jiggle. - ViewportState: drop fling momentum, and snap zoom / centering to their targets in a single tick instead of easing. Detection lives in canvas/reduced-motion.ts (SSR-safe matchMedia). Behavior is unchanged when reduce-motion is off. Added reduced-motion.test.ts (9 tests); full package suite 205 passing, build and type-check clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposal
The issue: the memory graph is the most animation-heavy surface in the product and it ignores the OS reduce motion preference. On load the force simulation animates every node flying into place and keeps settling for a while; panning has fling momentum; zoom and centering (auto-fit, node focus, slideshow) ease in via a spring. For someone with a vestibular disorder or motion sensitivity that is exactly the kind of continuous, non-essential motion WCAG 2.3.3 (Animation from Interactions) is about.
It's also inconsistent with the rest of the app, which already honors the setting —
superloader,onboarding-confetti,orbit-memory, andreview-memories-modalall checkprefers-reduced-motion. The graph was the gap.The proposal: honor
prefers-reduced-motionin the two engines that produce the motion, with zero loss of functionality — a calm, static graph that's still fully pan/zoom/click/drag-able.Changes
ForceSimulation— still runs the pre-settle ticks, then stays static instead of kicking off the perpetual settle (the same path dense graphs already use).reheat()(fired on node drag) becomes a no-op. Dragging still moves the grabbed node directly via the input handler, so it works exactly as before, just without neighbours jiggling.ViewportState—releaseWithVelocitydrops fling momentum, andtick()snaps zoom and pan/centering straight to their targets in one frame instead of easing.canvas/reduced-motion.ts— small SSR-safematchMediahelper; the viewport caches theMediaQueryListso the per-frame check stays cheap while.matchesstill reflects a live OS change.When reduce-motion is off, behavior is byte-for-byte unchanged (the new branches are gated on the flag).
Testing
reduced-motion.test.ts— 9 tests: the helper (missing matchMedia → false, reflects the query), the simulation staying static + ignoring reheat under reduced motion (and running normally otherwise), and the viewport dropping momentum / snapping zoom + pan (vs. easing normally).@supermemory/memory-graphsuite: 205 passing.tscandvite buildclean.Touches only
canvas/*engine files, so it composes cleanly with the graph work in my other open PRs.