Key Takeaways
- Hidden 0x0 container mounts recover automatically on first layout via ResizeObserver or opt-in deferInitialLayout with zero spring jump.
- Touch-scroll direction-locking and peak-displacement click tolerance stop interactive canvases from hijacking vertical mobile scrolling or firing accidental taps after pans.
- Zero-relayout itemFilter ('dim' | 'hide') keeps every node anchored while updating visibility, selection marquees, structured legend counts, and WCAG 2.1 AA keyboard navigation in one batch() commit.
A spatial visualization can pass every geometric benchmark in a standalone sandbox and still frustrate users the moment it lands inside a real product. Users open pages in background tabs, view dashboards on phones, toggle sidebar filters while comparing clusters, navigate solely by keyboard, or paste a URL to share what they just found.
Across milestones 0.9 through 0.13, we focused on closing that gap between laboratory demos and production-grade applications.
1. Mounting in Hidden Tabs & Scrolling on Phones
Two real-world host behaviors break naive canvas/SVG visualizations almost immediately:
- Mounting at
0×0inside hidden tabs, accordions, or modals. If a graph initializes before CSS finishes loading or while its parent panel is collapsed (width === 0, height === 0), offscreengetBBox()measurements cache degenerate zero boxes and initial coordinates collapse around the origin. When the panel finally opens, nodes either stay crushed or snap violently across the screen. - Trapping vertical page scroll on touch devices. When a full-width graph fills a mobile screen, a casual downward thumb swipe meant to scroll down the article often gets captured as a pan gesture—leaving the reader stuck inside the widget.
SimplexViz handles both at the controller boundary without requiring host-app hacks:
- Automatic
0×0Recovery &deferInitialLayout: Mounting inside a0×0host container no longer locks in degenerate hulls. As soon asResizeObserverreports the first non-zero box, cached hulls invalidate and the engine performs a clean'initial'viewport solve with zero spring jump. WithdeferInitialLayout: true(or{ fallbackTimeoutMs }), you can even skip provisional layout math entirely until the tab becomes visible. - Vertical Touch-Scroll Yielding & Clean Taps: By setting
touch-action: pan-ywhenevertouchScrollLockPx > 0(default8 px), single-finger vertical swipes scroll the page naturally, while horizontal swipes and two-finger pinches engage the map. Meanwhile,clickTolerancePx(default12 px) tracks peak pointer displacement across a gesture—so dragging out and drifting back to the start point never triggers an accidental node click.
Technical Details: Viewport Recovery, Touch Thresholds & Batch OptionsCore engine and controller configuration for mount timing, touch-gesture thresholds, shape styling, and atomic option coalescing.Show detailsHide details
- Headless Engine (
@simplex-viz/core):deferInitialSolve?: booleanonSimplexGraphEngineConfigdelays clustering and SAT layout untilengine.reinitializeViewport(width, height)receives real dimensions.engine.batch(fn)queues nested mutations (items, strategies, filters, viewport, theme) and flushes a single minimal pipeline pass on outermost exit.
- SVG & Canvas Controllers (
@simplex-viz/svg,@simplex-viz/canvas):deferInitialLayout?: boolean | { fallbackTimeoutMs?: number }skips the provisional960×620solve on0×0mounts until visibility or fallback expiry.touchScrollLockPx(default8, settersetTouchScrollLockPx()) controls single-finger scroll lock direction;clickTolerancePx(default12, settersetClickTolerancePx()) measures peak Euclidean displacement across bothfree-cameraanddrill-downmodes.controller.setOptions(opts)wraps multi-property runtime updates insideengine.batch(...)automatically (used directly by React’s atomic prop-sync effect).shapeOptions(hoverScale,hoverRingColor,dimmedOpacity,strokeColor,strokeWidth) onGeometricShapeSvgViewandcreatePresetViews()are factored directly into convex hull measurement and preserved acrossmorph().
2. Filtering Without Moving the Map
In a traditional force-directed graph, hiding half the dataset triggers a fresh layout pass—reshuffling everything on screen and destroying the user’s spatial memory of where topics live.
SimplexViz separates topological coordinates from active visibility:
// Dim non-matching items in place or hide them completely—coordinates never drift
controller.setItemFilter(
(item) => item.year >= 1960 && item.tags.includes('sci-fi'),
{ mode: 'hide' },
);
Because itemFilter runs purely at render and hit-test time without re-clustering or re-solving convex SAT hulls, toggling checkboxes in a faceted sidebar keeps every surviving item pinned to its exact position at 60 fps. Switching between 'dim' (muted contextual backdrop) and 'hide' (suppressing visual presence, hit-testing, and keyboard targets) is instantaneous, and getLegendModel() / onLegendChange reflect the filtered counts automatically.
3. Keyboard Navigation, Cohort Selection & Shareable Links
Visual exploration also needs first-class non-pointer workflows and a way to preserve complex views across reloads:
- Single-Tabstop WCAG 2.1 AA Navigation: Rather than dumping hundreds of tab stops into the page, the stage exposes one clean
role="application"root (tabindex="0") paired witharia-activedescendant,Arrow/Home/Endtraversal across clusters, items, and triangles, zoom-adaptive high-contrast double-halo focus rings, and politearia-live="polite"announcements—plusreducedMotion: 'auto'to snap springs immediately whenprefers-reduced-motion: reduceis active. - Multi-Selection, Linked Views & Deep-Linking: Hold
Shiftto toggle items or drag a rectangular selection marquee (marqueeSelection: true), jump straight to search matches withfocusItem()orzoomToItem(), connect external sidebars via diff-gatedonLegendChangeor custom HTMLSimplexDomTooltipRendererobjects, and serialize the full view—camera,zoomPath, focus, highlights, selection, pins, and activetimelineStep—withgetViewState()andrestoreViewState().
Technical Details: Accessibility Contracts, Selection State & ViewState v1 SchemaExact keyboard bindings, ARIA metadata hooks, legend diffing, tooltip renderers, and SimplexViewState serialization.Show detailsHide details
- Keyboard & Screen-Reader Contract:
- Single root container uses
role="application",tabindex="0",aria-activedescendant, and deterministic instance-scoped IDs (ariaIdPrefixviaSvgAriaMetadataResolver). - Keys:
ArrowRight/ArrowDown(next target),ArrowLeft/ArrowUp(previous target),Home/End(first/last),Enter/Space(activate/drill),Shift+Enter/Shift+Space(toggle selection),Escape(clear selection or drill up). - Polite announcements live in
.sv-sr-announcer[role="status"][aria-live="polite"], deduped across rapid zoom frames. reducedMotion:'auto' | boolean(setReducedMotion(),getReducedMotion(),isReducedMotionActive()).
- Single root container uses
- Multi-Selection & Linked Views:
selectedIds(NodeInteractionState.isSelected) is orthogonal tohighlightedIds,pinnedIds, and hover/focus states.shiftClickSelects(defaulttrue) processesShift+Clickcohort toggles before invoking consumeronContentClickcallbacks so detail drawers never swallow multi-selection.setHighlightedIds(Iterable<string> | null),focusItem(id, { highlight?, hover?, announce? }), andzoomToItem(id, { maxDrillSteps? })link external search bars and tables directly to canvas/SVG state.
- Legend Model & Custom Tooltips:
getLegendModel(options?)/onLegendChangeemitSimplexLegendModel(entries: SimplexLegendEntry[], active/visible item counts, swatches, roles, tags, focus flags), diff-gated inside the engine so unchanged topology/visibility produces zero redundant callbacks.SimplexDomTooltipRenderer:{ render(target, container), onHide?, className?, unstyled?, pointerEvents? }caches active target keys and flips cleanly at container edges; string formatters returningnull | undefined | ''suppress the tooltip container.
- Deep-Linking (
SimplexViewStatev1):interface SimplexViewState { version: 1; camera: { x: number; y: number; scale: number }; zoomPath: readonly SimplexViewZoomStep[]; focusedClusterUid: string | null; focusedTriangleIndex: number | null; focusedItemId: string | null; highlightedIds: readonly string[]; selectedIds: readonly string[]; pinnedIds: readonly string[]; timelineStep?: number; }restoreViewState(state, options?)snaps immediately by default, replayszoomPathcleanly from root, restores active timeline frames when enabled, and ignores stale item/cluster IDs gracefully without throwing.