Positioning starting node in the middle of canvas #44
-
Hello all! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hello! To position the starting node at the center of the f-canvas with a scale of 1:1, you need to calculate the dimensions of your f-flow component window and the size of your node. Knowing these dimensions, you can compute the position so that the node is centered relative to the window. Then, set a new position for the f-canvas component based on these calculations. Since the sizes may vary in each instance of the component, this calculation needs to be performed dynamically. Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
@doritones canvasPosition = PointExtensions.initialize(
(flow.width - node.width) / 2 - nodePosition.x * canvasScale,
(flow.height - node.height) / 2 - nodePosition.y * canvasScale
); |
Beta Was this translation helpful? Give feedback.
@doritones
I added a method to the CanvasComponent called centerGroupOrNode. You can read more on this page FCanvasComponent Documentation.
If you need to set the correct position before the first render, here is the code on how to calculate the required position of the canvas: