fix: [workflows:editor] Fixed zoom when there is only one node in the graph

pull/8530/head
Sami Mokaddem 2022-07-25 13:27:45 +02:00
parent e4d764de06
commit 4a26475b14
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 2 additions and 3 deletions

View File

@ -207,13 +207,12 @@ function initDrawflow() {
var offset_y = (editor_bcr.height - parentOffsetY) / 2
var canvasCentroid = getCanvasCentroid()
var calc_zoom = Math.min(
1,
Math.min(
var calc_zoom = Math.min(1, Math.min(
(editor_bcr.width - sidebarWidth) / ((canvasCentroid.maxX - canvasCentroid.minX) + sidebarWidth),
editor_bcr.height / ((canvasCentroid.maxY - canvasCentroid.minY) - parentOffsetY)
),
) // Zoom out if needed
calc_zoom = calc_zoom > 0 ? calc_zoom : 1
calc_zoom = calc_zoom * 0.95
offset_x += 100 * (1 / calc_zoom) // dirty fix to offset the position relative to the sidebar
offset_y -= 100 * (1 / calc_zoom) // dirty fix to slightly move the graph up