Centering the diagram based on node

I try to center the diagram in the middle of the viewport based on the clicked node.

I have tried to achieve this by getting some values that I could use for proper calculation. Is there any way to get for example the node alignment in the viewport? Or in any other “container” (sorry if my terminology is bad, I try to absorb all of it still). For example

node.alignmentIn(parentPanel) // 0.4

or something similar?

Do you have any other ways for solving the initial problem?


if you want to make a particular Node be centered in the viewport,
call either centerRect or scrollToRect with the Node’s GraphObject.actualBounds, depending on whether or not you want the view to be scrolled if the node is already in view.

Also, please read: and