mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 14:27:40 +00:00
Improve slot render stability & perf (#954)
- `draw` is now skipped for slots that should not be shown (prev. drawn with 0 alpha) - Fixes slot always rendered when widget not found in `node.widgets` - Remove redundant check from `isWidgetInputSlot` - type is already `INodeInputSlot`
This commit is contained in:
@@ -3493,7 +3493,8 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
return this.#getMouseOverSlot(slot) === slot
|
||||
}
|
||||
|
||||
#isMouseOverWidget(widget: IWidget): boolean {
|
||||
#isMouseOverWidget(widget: IWidget | undefined): boolean {
|
||||
if (!widget) return false
|
||||
return this.mouseOver?.overWidget === widget
|
||||
}
|
||||
|
||||
@@ -3535,19 +3536,20 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
// - the mouse is over the widget
|
||||
// - the slot is valid during link drop
|
||||
// - the slot is connected
|
||||
const showSlot = isMouseOverSlot ||
|
||||
if (
|
||||
isMouseOverSlot ||
|
||||
isValidTarget ||
|
||||
!slotInstance.isWidgetInputSlot ||
|
||||
this.#isMouseOverWidget(this.getWidgetFromSlot(slotInstance)!) ||
|
||||
this.#isMouseOverWidget(this.getWidgetFromSlot(slotInstance)) ||
|
||||
slotInstance.isConnected()
|
||||
|
||||
ctx.globalAlpha = showSlot ? (isValid ? editorAlpha : 0.4 * editorAlpha) : 0
|
||||
|
||||
slotInstance.draw(ctx, {
|
||||
colorContext,
|
||||
lowQuality,
|
||||
highlight,
|
||||
})
|
||||
) {
|
||||
ctx.globalAlpha = isValid ? editorAlpha : 0.4 * editorAlpha
|
||||
slotInstance.draw(ctx, {
|
||||
colorContext,
|
||||
lowQuality,
|
||||
highlight,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,11 +72,11 @@ export function toNodeSlotClass(slot: INodeInputSlot | INodeOutputSlot): NodeInp
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this slot is an input slot and attached to a widget.
|
||||
* Type guard: Whether this input slot is attached to a widget.
|
||||
* @param slot The slot to check.
|
||||
*/
|
||||
export function isWidgetInputSlot(slot: INodeInputSlot): slot is IWidgetInputSlot {
|
||||
return isINodeInputSlot(slot) && !!slot.widget
|
||||
return !!slot.widget
|
||||
}
|
||||
|
||||
export abstract class NodeSlot implements INodeSlot {
|
||||
|
||||
Reference in New Issue
Block a user