Hi Walter,
just wanted to know that, we can modify the diagram.commandHandler.scrollToPart()
.
currently it moves the viewport of the provided part to the center of the canvas.
But for some product requirement i want scrollToPart to move it to some extent (could be to little left/right edge or top/bottom edge, but not center).
How can we do that?
Let me know, if the question is not clear.
Thanks
There is no Diagram.scrollToPart method. But there is a CommandHandler.scrollToPart method: CommandHandler | GoJS API
From your description maybe you want to call Diagram | GoJS API
If that doesn’t do what you want, you can implement what you want by computing and setting the Diagram.position, which is basically what all of those methods do. Here is the definition of scrollToRect:
public scrollToRect(r: Rect): void {
const vb = this.viewportBounds;
if (vb.containsRect(r)) return; // do nothing if R is already in view
const midpt = r.center;
midpt.x -= vb.width / 2;
midpt.y -= vb.height / 2;
this.position = midpt;
}
Yes, but you will need to adapt the code to meet your requirements, which seem rather vague to me.