From 0e28091f088559d595b3e3e6c5f421be83793b1d Mon Sep 17 00:00:00 2001 From: Ivan Goethals Date: Wed, 1 Jan 2025 19:24:38 +0100 Subject: [PATCH] Betere code om lengte van tekst te meten die ook werkt op het situatieschema. --- builddate.js | 2 +- eendraadschema.js | 15 ++++++++------- src/general.ts | 9 ++++++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/builddate.js b/builddate.js index eaec69e..ff1da75 100644 --- a/builddate.js +++ b/builddate.js @@ -1 +1 @@ -var CONF_builddate="20250101-164553" +var CONF_builddate="20250101-192145" diff --git a/eendraadschema.js b/eendraadschema.js index 24d0b8d..ed7ee21 100644 --- a/eendraadschema.js +++ b/eendraadschema.js @@ -114,13 +114,14 @@ function svgTextWidth(input, fontsize, options) { if (options === void 0) { options = ''; } var div = document.createElement('div'); div.innerHTML = '' + input + ''; - var tryoutdiv; - if (document.getElementById("configsection").style.display === 'block') { - tryoutdiv = document.getElementById("configsection"); - } - else { - tryoutdiv = document.getElementById("right_col_inner"); - } + var tryoutdiv = document.body; + /*if (document.getElementById("configsection").style.display === 'block') { + tryoutdiv = document.getElementById("configsection") as HTMLElement; + } else if (document.getElementById("outerbox").style.display === 'block') { + tryoutdiv = document.getElementById("outerbox") as HTMLElement; + } else { + tryoutdiv = document.getElementById("right_col_inner") as HTMLElement; + }*/ tryoutdiv.appendChild(div); var width = div.children[0].children[0].getBBox().width; tryoutdiv.removeChild(div); diff --git a/src/general.ts b/src/general.ts index e928c4e..b35eda4 100644 --- a/src/general.ts +++ b/src/general.ts @@ -55,12 +55,15 @@ function svgTextWidth(input:String, fontsize:Number = 10, options:String = '') { const div = document.createElement('div'); div.innerHTML = '' + input + ''; - let tryoutdiv: HTMLElement; - if (document.getElementById("configsection").style.display === 'block') { + let tryoutdiv: HTMLElement = document.body; + + /*if (document.getElementById("configsection").style.display === 'block') { tryoutdiv = document.getElementById("configsection") as HTMLElement; + } else if (document.getElementById("outerbox").style.display === 'block') { + tryoutdiv = document.getElementById("outerbox") as HTMLElement; } else { tryoutdiv = document.getElementById("right_col_inner") as HTMLElement; - } + }*/ tryoutdiv.appendChild(div); const width = (div.children[0].children[0] as SVGGraphicsElement).getBBox().width;