f-flow icon indicating copy to clipboard operation
f-flow copied to clipboard

Add a max scale option in canvas.fitToScreen

Open dja-dsd opened this issue 10 months ago • 2 comments

Description

In the case the canvas bounding box is 'small' (a few nodes) the fit to screen option can lead to nodes being magnified quite aggresively. A max scale parameter may be helpful there.

Additional Context

No response

dja-dsd avatar Mar 26 '25 13:03 dja-dsd

Hi! Thanks for the suggestion — you’re absolutely right that aggressive zooming can be an issue when there are only a few nodes on the canvas.

We already provide a built-in method for this:

fitToScreen(padding: IPoint = { x: 0, y: 0 }, animated: boolean = true): void;

The fitToScreen method automatically adjusts the view so that all nodes fit within the canvas, scaling and centering them. You can provide a custom padding to add horizontal and vertical space around the content — this helps avoid zooming in too much when the layout is small. You can also control whether the transition is animated.

Let me know if you’d like more control (e.g., a maxScale limit) — we may consider that for future updates.

siarheihuzarevich avatar Jun 21 '25 07:06 siarheihuzarevich

I would love it if fitToScreen would listen to the max and min zoom levels set on the canvas. Or at least have the option to listen to them.

coonh avatar Nov 10 '25 10:11 coonh