diff --git a/src/lib/components/ComfyApp.svelte b/src/lib/components/ComfyApp.svelte index ac2f83c..e9b3c88 100644 --- a/src/lib/components/ComfyApp.svelte +++ b/src/lib/components/ComfyApp.svelte @@ -20,6 +20,7 @@ import ComfyProperties from "./ComfyProperties.svelte"; import queueState from "$lib/stores/queueState"; import ComfyUnlockUIButton from "./ComfyUnlockUIButton.svelte"; + import ComfyGraphView from "./ComfyGraphView.svelte"; export let app: ComfyApp = undefined; let imageViewer: ImageViewer; @@ -59,6 +60,7 @@ $layoutState.currentSelection = [] let graphSize = 0; + let graphTransitioning = false; function toggleGraph() { if (graphSize == 0) { @@ -121,10 +123,6 @@ } } - function doRecenter(): void { - app.lCanvas.recenter(); - } - $: if ($uiState.uiUnlocked && !hasShownUIHelpToast) { hasShownUIHelpToast = true; toast.push("Right-click to open context menu.") @@ -145,11 +143,18 @@ } $: if (containerElem) { - let wrappers = containerElem.querySelectorAll(".pane-wrapper") - for (const wrapper of wrappers) { - const paneNode = wrapper.parentNode as HTMLElement; // get the node inside the - paneNode.ontransitionend = () => { - app.resizeCanvas() + const canvas = containerElem.querySelector("#graph-canvas") + if (canvas) { + console.warn("reg!"); + const paneNode = canvas.closest(".splitpanes__pane") + if (paneNode) { + (paneNode as HTMLElement).ontransitionstart = () => { + graphTransitioning = true + } + (paneNode as HTMLElement).ontransitionend = () => { + graphTransitioning = false + app.resizeCanvas() + } } } } @@ -190,9 +195,7 @@ -
- -
+
@@ -226,9 +229,6 @@ - @@ -273,15 +273,6 @@ height: 100vh; } - #comfy-ui { - } - - #comfy-graph { - } - - #graph-canvas { - } - #bottombar { padding-top: 0.5em; display: flex; @@ -302,12 +293,6 @@ } } - .canvas-wrapper { - width: 100%; - height: 100%; - background-color: #333; - } - .sidebar-wrapper { width: 100%; height: 100%; diff --git a/src/lib/components/ComfyApp.ts b/src/lib/components/ComfyApp.ts index 794064f..2070e00 100644 --- a/src/lib/components/ComfyApp.ts +++ b/src/lib/components/ComfyApp.ts @@ -106,6 +106,8 @@ export default class ComfyApp { LiteGraph.release_link_on_empty_shows_menu = true; LiteGraph.alt_drag_do_clone_nodes = true; + (window as any).LiteGraph = LiteGraph; + // await this.#invokeExtensionsAsync("init"); await this.registerNodes(); diff --git a/src/lib/components/ComfyGraphView.svelte b/src/lib/components/ComfyGraphView.svelte new file mode 100644 index 0000000..f272fcc --- /dev/null +++ b/src/lib/components/ComfyGraphView.svelte @@ -0,0 +1,76 @@ + + +
+
+ +
+
+ {#if !transitioning} + + + + {/if} +
+
+ + diff --git a/src/lib/components/ComfyProperties.svelte b/src/lib/components/ComfyProperties.svelte index 5e9e871..b4fe006 100644 --- a/src/lib/components/ComfyProperties.svelte +++ b/src/lib/components/ComfyProperties.svelte @@ -65,7 +65,7 @@ } function validNodeProperty(spec: AttributesSpec, node: LGraphNode | null): boolean { - if (node == null) + if (node == null || spec.location !== "nodeProps") return false; if (spec.canShow && !spec.canShow(node)) @@ -77,8 +77,21 @@ return spec.name in node.properties } + function validNodeVar(spec: AttributesSpec, node: LGraphNode | null): boolean { + if (node == null || spec.location !== "nodeVars") + return false; + + if (spec.canShow && !spec.canShow(node)) + return false; + + if (spec.validNodeTypes) { + return spec.validNodeTypes.indexOf(node.type) !== -1; + } + return spec.name in node + } + function validWidgetAttribute(spec: AttributesSpec, widget: IDragItem | null): boolean { - if (widget == null) + if (widget == null || spec.location !== "widget") return false; if (spec.canShow) return spec.canShow(widget); @@ -86,6 +99,13 @@ return spec.name in widget.attrs } + function validWorkflowAttribute(spec: AttributesSpec): boolean { + if (spec.location !== "workflow") + return false; + + return spec.name in $layoutState.attrs + } + function getAttribute(target: IDragItem, spec: AttributesSpec): any { let value = target.attrs[spec.name] if (value == null) @@ -200,7 +220,7 @@ {#each category.specs as spec(spec.id)} - {#if spec.location === "widget" && validWidgetAttribute(spec, target)} + {#if validWidgetAttribute(spec, target)}
{#if spec.type === "string"} {:else if node} - {#if spec.location === "nodeProps" && validNodeProperty(spec, node)} + {#if validNodeProperty(spec, node)}
{#if spec.type === "string"} {/if}
- {:else if spec.location === "nodeVars" && spec.name in node} + {:else if validNodeVar(spec, node)}
{#if spec.type === "string"} {/if} - {:else if spec.location === "workflow" && spec.name in $layoutState.attrs} + {:else if !node && !target && validWorkflowAttribute(spec)}
{#if spec.type === "string"} -
+