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

Flowviewer - Auto Frame Content

Open joepavitt opened this issue 9 months ago • 1 comments

Currently, the flowviewer default zoom level to "1", with a current scale limit at 0.5.

Assuming that scale 0.5 means twice as zoomed out as 1, then if there are nodes out of this view, they cannot be seen. until a user zooms and pans accordingly. A quick solution here would be to measures the maximum x/y coordinates of the nodes, adds a padding factor (e.g. 1.05), and then reassert the zoom level to be:

zoom = fudge_factor * (init_window_size.x / max_node_x)

e.g. if window width is 300, and a node is found at 450, then with a fudge_factor of 1.05 the zoom level would 0.7.

joepavitt avatar Sep 21 '23 08:09 joepavitt

My experience is that there will always be content that won't fit (e.g. content that is thin and long either vertically or horizontally), hence I use the bounding box of the all content (that's why I created the containerGroup) and set the viewBox of the svg to that. That ensures a) the browser does the work and b) it works on mobile and desktop.

Disadvantage is that this happens in the browser and hence the user will notice it - zoom is reset.

EDIT:

additionally some flows have their content far away from (0,0) and then zoom becomes even weirder since you have work on where to center the zoom ...

gorenje avatar Sep 21 '23 09:09 gorenje