Fit view on workflow load without extra.ds (#3822)

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2025-05-08 17:39:44 -04:00
committed by GitHub
parent 2019c1d877
commit 2a297e512d
31 changed files with 138 additions and 34 deletions

View File

@@ -1069,6 +1069,13 @@ export class ComfyApp {
) {
this.canvas.ds.offset = graphData.extra.ds.offset
this.canvas.ds.scale = graphData.extra.ds.scale
} else {
// @note: Set view after the graph has been rendered once. fitView uses
// boundingRect on nodes to calculate the view bounds, which only become
// available after the first render.
requestAnimationFrame(() => {
useLitegraphService().fitView()
})
}
} catch (error) {
useDialogService().showErrorDialog(error, {

View File

@@ -132,7 +132,12 @@ export const defaultGraph: ComfyWorkflowJSON = {
],
groups: [],
config: {},
extra: {},
extra: {
ds: {
offset: [0, 0],
scale: 1
}
},
version: 0.4
}