Skip to content

fix vertical dragging in visualizer - #80

Open
Amos-Rai-KEYS wants to merge 2 commits into
mainfrom
fix-visualizer-bug
Open

fix vertical dragging in visualizer#80
Amos-Rai-KEYS wants to merge 2 commits into
mainfrom
fix-visualizer-bug

Conversation

@Amos-Rai-KEYS

Copy link
Copy Markdown
Collaborator

Fix: Restore vertical dragging after level separation and node spacing slider moves

Summary

When users adjusted the "Level Separation" or "Node Spacing" sliders in the control panel, nodes became locked to their vertical axis and could no longer be dragged. This fix restores full dragging freedom after layout adjustments.

Problem

The infragraph visualizer uses vis-network's hierarchical layout, which pins every node on its level axis to maintain the graph structure:

  • fixed.y = true for vertical (DU/UD) fabric view
  • fixed.x = true for horizontal (LR) internal view

The drag handler only moves nodes on axes where fixed is false, so pinned axes are immovable.

On initial render, nodes are unpinned after stabilization (cleared fixed back to false). However, when either slider triggered a layout re-run via setOptions(), the layout engine re-applied the pins but the slider handlers never cleared them again. Result: first slider touch permanently froze the vertical axis.

Solution

Introduced unpinNodes(network) helper that:

  1. Captures the layout's final node positions via getPositions()
  2. Writes them back to the DataSet as explicit x/y (durable position + sets predefinedPosition = true)
  3. Clears fixed: false on all nodes to restore drag freedom

The helper is called in all three places the layout stabilizes: initial render and both slider handlers.

Changes

src/infragraph/visualizer/frontend/js/network.js

  • Added unpinNodes(network) helper function (lines 40–51)
  • Updated renderNetwork() to call unpinNodes() after stabilization (line 61)
  • Removed inline unpin logic, now uses the helper

src/infragraph/visualizer/frontend/js/controller.js

  • Added respaceLayout(hierarchical, repulsion) helper to deduplicate slider logic (lines 36–57)
  • Space slider now calls respaceLayout({}, { nodeDistance: spacing }) (lines 59–62)
  • Level slider now calls respaceLayout({ levelSeparation: spacing }, {}) (lines 64–67)
  • Both helpers now call unpinNodes(net) after stabilization ✓
  • Both helpers call net.off('stabilizationIterationsDone') to prevent stale listener stacking
  • Removed 30+ lines of redundant setOptions() calls and duplicated config

src/infragraph/visualizer/frontend/js/app.js

  • Updated render() to use unpinNodes(net) instead of inline unpin logic (line 52)

@Amos-Rai-KEYS Amos-Rai-KEYS self-assigned this Aug 20, 2026
@Amos-Rai-KEYS Amos-Rai-KEYS changed the title fix vertical dragging fix vertical dragging in visualizer Aug 20, 2026
harsh-sikhwal
harsh-sikhwal previously approved these changes Aug 21, 2026
@harsh-sikhwal
harsh-sikhwal requested a review from ajbalogh August 21, 2026 10:05
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.

3 participants