Use upper graph in subgraph stack for saved offset/scale

This commit is contained in:
space-nuko
2023-05-17 20:37:12 -05:00
parent 1408d12575
commit a9cebc23d1
2 changed files with 12 additions and 3 deletions

View File

@@ -47,10 +47,16 @@ export default class ComfyGraphCanvas extends LGraphCanvas {
_selectedNodes: Set<NodeID> = new Set();
serialize(): SerializedGraphCanvasState {
return {
offset: this.ds.offset,
scale: this.ds.scale
let offset = this.ds.offset;
let scale = this.ds.scale;
// Use top-level graph for saved offset if we're viewing a subgraph
if (this._graph_stack?.length > 0) {
offset = this._graph_stack[0].offset;
scale = this._graph_stack[0].scale;
}
return { offset, scale }
}
deserialize(data: SerializedGraphCanvasState) {