From ba1e9009a3586dc75456e117ab1d7946d518dd5d Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Sat, 6 Apr 2024 11:21:22 -0700
Subject: Avoid hiding firing arc if visibility is toggled when changing unit
selection
---
index.js | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/index.js b/index.js
index fc9f884..07cff21 100644
--- a/index.js
+++ b/index.js
@@ -605,8 +605,20 @@ const RecordSheet = new function() {
let unclipped = document.querySelectorAll('#firing-arcs polygon:not([clip-path])');
unclipped.forEach(el => {
- let { troopNumber, troopAllegiance } = el.dataset;
- el.setAttributeNS(null, 'clip-path', `url(#clip-path-${troopAllegiance}-${troopNumber})`);
+ let { troopNumber, troopAllegiance } = el.dataset,
+ clipPathId = `clip-path-${troopAllegiance}-${troopNumber}`;
+
+ let isVisible =
+ document
+ .getElementById('toggle-firing-arc-vis')
+ .querySelector(`input[data-allegiance="${troopAllegiance}"]`)
+ .checked;
+
+ if (isVisible) {
+ document.getElementById(clipPathId).style.display = 'none';
+ }
+
+ el.setAttributeNS(null, 'clip-path', `url(#${clipPathId})`);
});
};
--
cgit v1.2.3