Skip to content

Commit

Permalink
Add a button to reset the view.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed May 10, 2024
1 parent f374ea7 commit 4f63ee9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions web/scripts/app.js
Expand Up @@ -2313,6 +2313,12 @@ export class ComfyApp {
await this.#invokeExtensionsAsync("refreshComboInNodes", defs);
}

resetView() {
app.canvas.ds.scale = 1;
app.canvas.ds.offset = [0, 0]
app.graph.setDirtyCanvas(true, true);
}

/**
* Clean current state
*/
Expand Down
7 changes: 7 additions & 0 deletions web/scripts/ui.js
Expand Up @@ -597,16 +597,23 @@ export class ComfyUI {
if (!confirmClear.value || confirm("Clear workflow?")) {
app.clean();
app.graph.clear();
app.resetView();
}
}
}),
$el("button", {
id: "comfy-load-default-button", textContent: "Load Default", onclick: async () => {
if (!confirmClear.value || confirm("Load default workflow?")) {
app.resetView();
await app.loadGraphData()
}
}
}),
$el("button", {
id: "comfy-reset-view-button", textContent: "Reset View", onclick: async () => {
app.resetView();
}
}),
]);

const devMode = this.settings.addSetting({
Expand Down

0 comments on commit 4f63ee9

Please sign in to comment.