From bbc7629df5e7480fe4db4ddbb2059c28a617e5cd Mon Sep 17 00:00:00 2001 From: Palazzini Luca Date: Wed, 18 Sep 2024 20:07:26 +0200 Subject: [PATCH] Fix multiple canvas being added to UI --- web/widgets/graph_widget.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/widgets/graph_widget.js b/web/widgets/graph_widget.js index bd0f958..9c7bdc4 100644 --- a/web/widgets/graph_widget.js +++ b/web/widgets/graph_widget.js @@ -1,5 +1,7 @@ // Type of the canvas widget const WIDGET_CANVAS_TYPE = 'fuwuffyAreaCanvas'; +// The canvas's className +const CANVAS_CLASS_NAME = 'fuwuffy-area-canvas'; // Default height for all widgets const WIDGET_BASE_HEIGHT = LiteGraph.NODE_WIDGET_HEIGHT; // Default size for canvas widget @@ -184,11 +186,12 @@ export function addAreaGraphWidget(app, node, name) { } } } + // Create a new canvas element widget.canvas = document.createElement("canvas"); - widget.canvas.className = "fuwuffy-area-canvas"; + widget.canvas.className = CANVAS_CLASS_NAME; widget.canvas.style.display = "none"; + // Add the widget and canvas to the UI widget.parent = node; - document.body.appendChild(widget.canvas); node.addCustomWidget(widget); node.onResize = size => computeCanvasSize(node, size); return { widget };