better remove preview
This commit is contained in:
+10
-2
@@ -2,7 +2,7 @@ import { app } from "../../scripts/app.js";
|
||||
import { api } from "../../scripts/api.js";
|
||||
|
||||
import { create } from "./utils.js";
|
||||
import { popup } from "./popup.js";
|
||||
import { popup, remove_preview } from "./popup.js";
|
||||
import { graph_id_to_tab } from "./weak_map.js";
|
||||
import { Log } from "./log.js";
|
||||
|
||||
@@ -114,11 +114,19 @@ app.registerExtension({
|
||||
},
|
||||
|
||||
afterConfigureGraph() {
|
||||
setTimeout( ()=> { app.graph.nodes.forEach( set_graph_id_widget ) }, 1000 )
|
||||
setTimeout( afterConfigure, 100 )
|
||||
link_to_tab(3)
|
||||
}
|
||||
})
|
||||
|
||||
function afterConfigure() {
|
||||
app.graph.nodes.forEach( (node) => {
|
||||
set_graph_id_widget(node)
|
||||
if (node.comfyClass == 'Mask Image Filter') remove_preview(node.id)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function set_graph_id_widget(node) {
|
||||
const graph_id_widget = node.widgets?.find((n)=>n.name=='graph_id')
|
||||
if (graph_id_widget) {
|
||||
|
||||
+12
-11
@@ -397,16 +397,7 @@ class Popup extends HTMLElement {
|
||||
this._send_response({masked_image:masked_image})
|
||||
|
||||
const the_node = this.node.id
|
||||
setTimeout(this.remove_preview, 500, [the_node,])
|
||||
}
|
||||
}
|
||||
|
||||
remove_preview(node_id) {
|
||||
const node = app.canvas.graph.getNodeById(node_id)
|
||||
const w = node?.widgets?.find((w)=>{return w.name=='$$canvas-image-preview'})
|
||||
if (w) {
|
||||
w.hidden = true
|
||||
node.setSize(node.computeSize())
|
||||
setTimeout(remove_preview, 500, [the_node,])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,4 +702,14 @@ class Popup extends HTMLElement {
|
||||
|
||||
customElements.define('cg-imgae-filter-popup', Popup)
|
||||
|
||||
export const popup = new Popup()
|
||||
export const popup = new Popup()
|
||||
|
||||
|
||||
export function remove_preview(node_id) {
|
||||
const node = app.canvas.graph.getNodeById(node_id)
|
||||
const w = node?.widgets?.find((w)=>{return w.name=='$$canvas-image-preview'})
|
||||
if (w) {
|
||||
w.hidden = true
|
||||
node.setSize(node.computeSize())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user