Skip to content

Center on a specific node during simulation? #47

Answered by Stukova
awaterho asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @awaterho!

The name of the trackNodesByIds method sounds a bit confusing, it has nothing to do with centring the camera on a Node. We've renamed it to trackNodePositionsByIds for clarity.

To centre the camera on a Node, try using the zoomToNodeById method together with the onTick callback:

simulation: {
  onTick: () => {
    graph.zoomToNodeById(nodeIdToCenter, 0, graph.getZoomLevel())
  }
}

Please check the example on Codesandbox with a demonstration. Let as know if you need any more help.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@awaterho
Comment options

Answer selected by rokotyan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #43 on March 17, 2023 07:53.