mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 19:21:54 +00:00
Fix badge width when invisble (#132)
This commit is contained in:
@@ -40,7 +40,13 @@ export class LGraphBadge {
|
|||||||
this.cornerRadius = cornerRadius;
|
this.cornerRadius = cornerRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get visible() {
|
||||||
|
return this.text.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
getWidth(ctx: CanvasRenderingContext2D) {
|
getWidth(ctx: CanvasRenderingContext2D) {
|
||||||
|
if (!this.visible) return 0;
|
||||||
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.font = `${this.fontSize}px sans-serif`;
|
ctx.font = `${this.fontSize}px sans-serif`;
|
||||||
const textWidth = ctx.measureText(this.text).width;
|
const textWidth = ctx.measureText(this.text).width;
|
||||||
@@ -53,7 +59,7 @@ export class LGraphBadge {
|
|||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
): void {
|
): void {
|
||||||
if (!this.text) return;
|
if (!this.visible) return;
|
||||||
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.font = `${this.fontSize}px sans-serif`;
|
ctx.font = `${this.fontSize}px sans-serif`;
|
||||||
|
|||||||
Reference in New Issue
Block a user