Skip to content

Commit 9aa07e8

Browse files
authored
don't create text element if empty (#131)
1 parent 92cb540 commit 9aa07e8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docs/static/hexmaps.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,11 @@ function drawPath(hexEntry) {
627627
}
628628

629629
function placeTextAtPoint(pt) {
630+
const textInput = TEXT_INPUT_DIV.value;
631+
if (!textInput) {
632+
console.log("eh")
633+
return;
634+
}
630635
const textbox = document.createElementNS("http://www.w3.org/2000/svg", "text");
631636
textbox.setAttribute("font-size", TEXT_FONT_SIZE_DIV.value);
632637
if (GLOBAL_STATE.layers.TEXT.bold) {
@@ -642,7 +647,7 @@ function placeTextAtPoint(pt) {
642647
textbox.setAttribute("x", pt.x);
643648
textbox.setAttribute("y", pt.y);
644649
textbox.setAttribute("fill", GLOBAL_STATE.layers.TEXT.primaryColor);
645-
textbox.textContent = TEXT_INPUT_DIV.value;
650+
textbox.textContent = textInput;
646651
textbox.classList.add("no-pointer-events");
647652
textbox.classList.add("in-image-text");
648653
textbox.addEventListener("click", e => {

templates/template_hexmaps.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
</div>
9292
<div class="layer-control control-panel flex-column gappy overlaid" data-control="TEXT">
9393
<div class="flex-row gappy">
94-
<input id="textFontSize" type="number" dir="rtl" class="border-box" value="45"></input>
94+
<input id="textFontSize" type="number" class="border-box" value="45"></input>
9595
<div id="textBold" class="btn border-box">B️</div>
9696
<div id="textItalics" class="btn border-box">I</div>
9797
<div id="textUnderline" class="btn border-box">U</div>

0 commit comments

Comments
 (0)