Skip to content

Commit

Permalink
Betere code om lengte van tekst te meten die ook werkt op het situati…
Browse files Browse the repository at this point in the history
…eschema.
  • Loading branch information
igoethal committed Jan 1, 2025
1 parent 2a9774c commit 0e28091
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion builddate.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
var CONF_builddate="20250101-164553"
var CONF_builddate="20250101-192145"
15 changes: 8 additions & 7 deletions eendraadschema.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ function svgTextWidth(input, fontsize, options) {
if (options === void 0) { options = ''; }
var div = document.createElement('div');
div.innerHTML = '<svg width="1000" height="20"><text x="0" y="10" style="text-anchor:start" font-family="Arial, Helvetica, sans-serif" font-size="' + Number(fontsize) + '" ' + options + '>' + input + '</text></svg>';
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);
Expand Down
9 changes: 6 additions & 3 deletions src/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ function svgTextWidth(input:String, fontsize:Number = 10, options:String = '') {
const div = document.createElement('div');
div.innerHTML = '<svg width="1000" height="20"><text x="0" y="10" style="text-anchor:start" font-family="Arial, Helvetica, sans-serif" font-size="' + Number(fontsize) + '" ' + options + '>' + input + '</text></svg>';

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;
Expand Down

0 comments on commit 0e28091

Please sign in to comment.