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

@@ -5,7 +5,8 @@ import {
LGraphNode,
LiteGraph,
RenderShape,
type Vector2
type Vector2,
createBounds
} from '@comfyorg/litegraph'
import type {
ISerialisableNodeInput,
@@ -651,11 +652,23 @@ export const useLitegraphService = () => {
canvas.setDirty(true, true)
}
function fitView() {
const canvas = canvasStore.canvas
if (!canvas) return
const bounds = createBounds(app.graph.nodes)
if (!bounds) return
canvas.ds.fitToBounds(bounds)
canvas.setDirty(true, true)
}
return {
registerNodeDef,
addNodeOnGraph,
getCanvasCenter,
goToNode,
resetView
resetView,
fitView
}
}