From 6cb0e8e334c867f52968b4c8f71380618a55613a Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Wed, 24 Apr 2024 21:30:07 +0300 Subject: [PATCH] set/get tweaks --- .gitignore | 3 ++- web/js/setgetnodes.js | 32 +++++++------------------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 587d297..be53a8b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ __pycache__ *.ckpt *.pth types -models \ No newline at end of file +models +jsconfig.json \ No newline at end of file diff --git a/web/js/setgetnodes.js b/web/js/setgetnodes.js index 51e44bd..1601445 100644 --- a/web/js/setgetnodes.js +++ b/web/js/setgetnodes.js @@ -1,5 +1,5 @@ import { app } from "../../../scripts/app.js"; -import { ComfyWidgets } from '../../../scripts/widgets.js'; + //based on diffus3's SetGet: https://github.com/diffus3/ComfyUI-extensions // Nodes that allow you to tunnel connections for cleaner graphs @@ -243,18 +243,10 @@ app.registerExtension({ content: `${getter.title} id: ${getter.id}`, callback: () => { - if (this.canvas?.ds?.offset) { - const nodeCenterX = getter.pos[0] + (getter.size[0] / 2); - const nodeCenterY = getter.pos[1] + (getter.size[1] / 2); - - this.canvas.ds.offset[0] = -nodeCenterX + this.canvas.mouse[0]; - this.canvas.ds.offset[1] = -nodeCenterY + this.canvas.mouse[1]; - } - if (this.canvas?.ds?.scale != null) { - this.canvas.ds.scale = Number(1); - } - this.canvas.selectNode(getter, false) + this.canvas.centerOnNode(getter); + this.canvas.selectNode(getter, false); this.canvas.setDirty(true, true); + }, })); @@ -437,19 +429,9 @@ app.registerExtension({ }; this.goToSetter = function() { - const setter = this.findSetter(this.graph); - if (this.canvas?.ds?.offset) { - const nodeCenterX = setter.pos[0] + (setter.size[0] / 2); - const nodeCenterY = setter.pos[1] + (setter.size[1] / 2); - - this.canvas.ds.offset[0] = -nodeCenterX + this.canvas.mouse[0]; - this.canvas.ds.offset[1] = -nodeCenterY + this.canvas.mouse[1]; - } - if (this.canvas?.ds?.scale != null) { - this.canvas.ds.scale = Number(1); - } - this.canvas.selectNode(setter, false) - this.canvas.setDirty(true, true); + const setter = this.findSetter(this.graph); + this.canvas.centerOnNode(setter); + this.canvas.selectNode(setter, false); }; // This node is purely frontend and does not impact the resulting prompt so should not be serialized