Skip to content

Fix/bubble dpr position and relayout selection#3

Merged
Mnikley merged 3 commits into
mainfrom
fix/bubble-dpr-position-and-relayout-selection
Jun 17, 2026
Merged

Fix/bubble dpr position and relayout selection#3
Mnikley merged 3 commits into
mainfrom
fix/bubble-dpr-position-and-relayout-selection

Conversation

@Mnikley

@Mnikley Mnikley commented Jun 17, 2026

Copy link
Copy Markdown
Member

No description provided.

Mnikley added 3 commits June 17, 2026 15:45
Dragging the window to a monitor with a different device-pixel-ratio left
bubble groups (and the heatmap field) misaligned until a sidebar toggle
forced a resize.

Root cause: a monitor move changes window.devicePixelRatio without changing
the container's CSS box, so sigma.resize() refreshes its pixelRatio but
early-returns before re-sizing any canvas — the WebGL layers stay at the old
backing resolution while the overlays repaint at the new ratio. The overlay
canvases also never had an explicit CSS display size (createCanvasContext
sets only position:absolute), so at >1 DPR they rendered at their backing-
store size (width*dpr px) instead of the logical viewport.

- add watchDevicePixelRatio (dpr_watch.js): on every DPR change force
  sigma.resize(true) + re-render, re-sizing all canvases to the new ratio
  (the same recovery a sidebar toggle triggered manually)
- bubble_layer/heatmap_layer #prepareCanvas now own the CSS display size,
  keeping each overlay 1:1 with the WebGL layers regardless of resize timing
- tests for the watcher, the A->B monitor-move sequence, and DPR-1/2 sizing
All six Arrange Selection tools (shrink/expand/circle/force/grid/random)
were silent no-ops: layoutSelectedNodes persisted positions before pushing
them to the graph, and persistNodePositions reads via getNodeData(), which
re-syncs nodeRef.style from graphology — clobbering the freshly computed
coordinates back to their pre-layout values before they ever reached the
renderer. Push to the graph first, then persist.

Replace the hand-rolled circle/force/random geometry (incl. a ~90-line
force sim that clamped toward world-origin instead of the selection
centroid) with layoutSelectionSubgraph(): run graphology circular/
forceAtlas2/random on a throwaway subgraph of the selection and recenter
on the original centroid. Grid stays manual (no graphology grid) and
shrink/expand stay as centroid scaling.

Rewrite the regression test with a faithful adapter mock (backing store
synced into refs by getNodeData) so it reproduces the clobbering bug;
verified it fails on the old persist-before-push order.
Patch release covering the two bug fixes since v1.15.0:
- Arrange Selection tools no longer silent no-ops
- bubble/heatmap overlays stay aligned across DPR changes
@Mnikley Mnikley merged commit 28ee065 into main Jun 17, 2026
2 checks passed
@Mnikley Mnikley deleted the fix/bubble-dpr-position-and-relayout-selection branch June 17, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant