Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Add a button to reset the view.

comfyanonymous4f63ee99f185
diff --git a/web/scripts/app.js b/web/scripts/app.js
index a0fe8b290..7ed262cb2 100644
--- a/web/scripts/app.js
+++ b/web/scripts/app.js
@@ -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
*/
diff --git a/web/scripts/ui.js b/web/scripts/ui.js
index d0fa46efb..36fed3238 100644
--- a/web/scripts/ui.js
+++ b/web/scripts/ui.js
@@ -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({