Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Centralize on Node

$
0
0

@TricksterX wrote:

Hello!

I'm using the 1.5.23 version of GoJs, and I'm trying to build a function to centralize the canvas on a given node.

My approach is an attempt to solve the following scenario: A user can expand and collapse nodes inside a tree, which may alter the canvas size and positioning, resulting in a blank canvas, until he drags and manually finds where the resulting tree is.

Currently, I'm using the following function:
`

  this.centerNode = function (node) {
      diagram.startTransaction('centralize');
      diagram.centerRect(node.part.actualBounds);
      diagram.commitTransaction('centralize');
  };

`

However, it doesn't work. I tried many configurations, and apparently the only way where this code works is setting the property "scrollMode" to "go.Diagram.InfiniteScroll", which is not desirable because it locks the user inside the canvas while scrolling forever.

Please, could you help me? Summarizing, my question is: given a node, is it possible to centralize the canvas on it, without using the InfiniteScroll mode?

Thanks for the attention!

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles