From 678e13a44c80db4aef48bbae609c22abbc4364a9 Mon Sep 17 00:00:00 2001 From: rgthree Date: Sun, 1 Oct 2023 22:25:05 -0400 Subject: [PATCH] Don't allow reroute default sizes under 10 --- ts/reroute.ts | 10 ++++++++-- web/reroute.js | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ts/reroute.ts b/ts/reroute.ts index 2b8d6b4..5443fef 100644 --- a/ts/reroute.ts +++ b/ts/reroute.ts @@ -30,8 +30,14 @@ declare const LGraphNode: typeof TLGraphNode; declare const LGraphCanvas: typeof TLGraphCanvas; const rerouteConfig = rgthreeConfig?.['nodes']?.['reroute'] || {}; -let configWidth = Math.round((Number(rerouteConfig['default_width']) || 40) / 10) * 10; -let configHeight = Math.round((Number(rerouteConfig['default_height']) || 30) / 10) * 10; +let configWidth = Math.max(Math.round((Number(rerouteConfig['default_width']) || 40) / 10) * 10, 10); +let configHeight = Math.max(Math.round((Number(rerouteConfig['default_height']) || 30) / 10) * 10, 10); +// Don't allow too small sizes. Granted, 400 is too small, but at least you can right click and +// resize... 10x10 you cannot. +while(configWidth * configHeight < 400) { + configWidth += 10; + configHeight += 10; +} const configDefaultSize = [configWidth, configHeight] as Vector2; const configResizable = !!rerouteConfig['default_resizable']; let configLayout: [string, string] = rerouteConfig['default_layout']; diff --git a/web/reroute.js b/web/reroute.js index 4a7a71c..1961c8c 100644 --- a/web/reroute.js +++ b/web/reroute.js @@ -4,8 +4,12 @@ import { rgthreeConfig } from "./rgthree_config.js"; import { rgthree } from "./rgthree.js"; import { LAYOUT_CLOCKWISE, LAYOUT_LABEL_OPPOSITES, LAYOUT_LABEL_TO_DATA, addConnectionLayoutSupport, addMenuItem, getSlotLinks, wait, } from "./utils.js"; const rerouteConfig = ((_a = rgthreeConfig === null || rgthreeConfig === void 0 ? void 0 : rgthreeConfig['nodes']) === null || _a === void 0 ? void 0 : _a['reroute']) || {}; -let configWidth = Math.round((Number(rerouteConfig['default_width']) || 40) / 10) * 10; -let configHeight = Math.round((Number(rerouteConfig['default_height']) || 30) / 10) * 10; +let configWidth = Math.max(Math.round((Number(rerouteConfig['default_width']) || 40) / 10) * 10, 10); +let configHeight = Math.max(Math.round((Number(rerouteConfig['default_height']) || 30) / 10) * 10, 10); +while (configWidth * configHeight < 400) { + configWidth += 10; + configHeight += 10; +} const configDefaultSize = [configWidth, configHeight]; const configResizable = !!rerouteConfig['default_resizable']; let configLayout = rerouteConfig['default_layout'];