More things

This commit is contained in:
space-nuko
2023-05-08 03:45:22 -05:00
parent e6172b0648
commit dd00cf52b5
5 changed files with 39 additions and 6 deletions

View File

@@ -11,8 +11,7 @@ export class ComfyQueueEvents extends ComfyGraphNode {
static slotLayout: SlotLayout = {
outputs: [
{ name: "beforeQueued", type: BuiltInSlotType.EVENT },
{ name: "afterQueued", type: BuiltInSlotType.EVENT },
{ name: "prompt", type: "*" }
{ name: "afterQueued", type: BuiltInSlotType.EVENT }
],
}

View File

@@ -51,6 +51,11 @@ export default class ComfyValueControl extends ComfyGraphNode {
}
}
delayChangeEvent: boolean = true;
private _aboutToChange: number = 0;
private _aboutToChangeValue: any = null;
constructor(title?: string) {
super(title);
}
@@ -60,6 +65,16 @@ export default class ComfyValueControl extends ComfyGraphNode {
this.setProperty("min", this.getInputData(3))
this.setProperty("max", this.getInputData(4))
this.setProperty("step", this.getInputData(5) || 1)
if (this._aboutToChange > 0) {
this._aboutToChange -= 1;
if (this._aboutToChange <= 0) {
const value = this._aboutToChangeValue;
this._aboutToChange = 0;
this._aboutToChangeValue = null;
this.triggerSlot(1, value)
}
}
}
override onAction(action: any, param: any) {
@@ -95,9 +110,16 @@ export default class ComfyValueControl extends ComfyGraphNode {
v = clamp(v, min, max)
this.setProperty("value", v)
this.triggerSlot(1, v)
this.setOutputData(0, v)
if (this.delayChangeEvent) {
this._aboutToChange = 2;
this._aboutToChangeValue = v;
}
else {
this.triggerSlot(1, v)
}
console.debug("ValueControl", v, this.properties)
};
}

View File

@@ -26,6 +26,11 @@ import RadioWidget from "$lib/widgets/RadioWidget.svelte";
* attribute and set `validNodeTypes` to the type of the litegraph node
* - Add a new entry in the `values` array, like "knob" or "dial" for ComfySliderWidget
* - Add an {#if widget.attrs.variant === <...>} statement in the corresponding Svelte component
*
* Also, BEWARE of calling setOutputData() and triggerSlot() on the same frame!
* You will have to either implement an internal delay on the event triggering
* or use an Event Delay node to ensure the output slot data can propagate to
* the rest of the graph first (see `delayChangedEvent` for details)
*/
export interface ComfyWidgetProperties extends ComfyGraphNodeProperties {