mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-05 13:10:24 +00:00
Minor bug fixes & refactors (#245)
* Fix TS errors - use correct property * Fix graph version bumped without change * Fix onDrawForeground callback has wrong area * Move node pos getter/setter to class decl
This commit is contained in:
@@ -339,9 +339,6 @@ export class LGraphCanvas {
|
||||
/** Implement this function to allow conversion of widget types to input types, e.g. number -> INT or FLOAT for widget link validation checks */
|
||||
getWidgetLinkType?: (widget: IWidget, node: LGraphNode) => string | null | undefined
|
||||
|
||||
// FIXME: Has never worked - undefined
|
||||
visible_rect?: Rect
|
||||
|
||||
/**
|
||||
* Creates a new instance of LGraphCanvas.
|
||||
* @param canvas The canvas HTML element (or its id) to use, or null / undefined to leave blank.
|
||||
@@ -3841,8 +3838,7 @@ export class LGraphCanvas {
|
||||
this.onDrawLinkTooltip?.(ctx, null)
|
||||
|
||||
//custom info
|
||||
// FIXME: Has never worked - visible_rect is undefined
|
||||
this.onDrawForeground?.(ctx, this.visible_rect)
|
||||
this.onDrawForeground?.(ctx, this.visible_area)
|
||||
|
||||
ctx.restore()
|
||||
}
|
||||
@@ -6020,14 +6016,12 @@ export class LGraphCanvas {
|
||||
}
|
||||
/**
|
||||
* resizes the canvas to a given size, if no size is passed, then it tries to fill the parentNode
|
||||
* @todo Remove or rewrite
|
||||
**/
|
||||
resize(width?: number, height?: number): void {
|
||||
if (!width && !height) {
|
||||
// TODO: Type-check parentNode
|
||||
const parent = this.canvas.parentNode
|
||||
// @ts-expect-error
|
||||
const parent = this.canvas.parentElement
|
||||
width = parent.offsetWidth
|
||||
// @ts-expect-error
|
||||
height = parent.offsetHeight
|
||||
}
|
||||
|
||||
|
||||
@@ -134,9 +134,7 @@ export class LGraphNode {
|
||||
flags?: INodeFlags
|
||||
widgets?: IWidget[]
|
||||
|
||||
size: Point
|
||||
pos: Point
|
||||
_pos: Point
|
||||
size: Size
|
||||
locked?: boolean
|
||||
|
||||
// Execution order, automatically computed during run
|
||||
@@ -183,6 +181,17 @@ export class LGraphNode {
|
||||
removable?: boolean
|
||||
block_delete?: boolean
|
||||
|
||||
_pos: Point
|
||||
public get pos() {
|
||||
return this._pos
|
||||
}
|
||||
public set pos(value) {
|
||||
if (!value || value.length < 2) return
|
||||
|
||||
this._pos[0] = value[0]
|
||||
this._pos[1] = value[1]
|
||||
}
|
||||
|
||||
get shape(): RenderShape {
|
||||
return this._shape
|
||||
}
|
||||
@@ -288,26 +297,7 @@ export class LGraphNode {
|
||||
// Initialize _pos with a Float32Array of length 2, default value [10, 10]
|
||||
this._pos = new Float32Array([10, 10])
|
||||
|
||||
Object.defineProperty(this, "pos", {
|
||||
set: function (v) {
|
||||
if (!v || v.length < 2) {
|
||||
return
|
||||
}
|
||||
this._pos[0] = v[0]
|
||||
this._pos[1] = v[1]
|
||||
},
|
||||
get: function () {
|
||||
return this._pos
|
||||
},
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
if (LiteGraph.use_uuids) {
|
||||
this.id = LiteGraph.uuidv4()
|
||||
}
|
||||
else {
|
||||
this.id = -1 //not know till not added
|
||||
}
|
||||
this.id = LiteGraph.use_uuids ? LiteGraph.uuidv4() : -1
|
||||
this.type = null
|
||||
|
||||
//inputs available: array of inputs
|
||||
@@ -2301,8 +2291,8 @@ export class LGraphNode {
|
||||
* Collapse the node to make it smaller on the canvas
|
||||
**/
|
||||
collapse(force?: boolean): void {
|
||||
this.graph._version++
|
||||
if (!this.collapsible && !force) return
|
||||
this.graph._version++
|
||||
this.flags.collapsed = !this.flags.collapsed
|
||||
this.setDirtyCanvas(true, true)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user