index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <Catalin.Mititiuc@gmail.com> | 2024-04-06 12:09:08 -0700 |
---|---|---|
committer | Catalin Mititiuc <Catalin.Mititiuc@gmail.com> | 2024-04-06 12:09:08 -0700 |
commit | 5e2a62bb7aa58889e19665fd7c55ff1185ccfbe0 (patch) | |
tree | 57595c9574a6f744c430d6fa372715881cd9b83d /index.js | |
parent | ac9b4563141af33e30f4470500499ea927b87868 (diff) |
Make counter's firing arc visible on mouseover
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -375,7 +375,6 @@ const Counter = new function() { }, clickClone = function() { - console.log('clone counter click fires'); let { troopNumber, troopAllegiance, x, y } = this.dataset, [xAttr, yAttr] = this.parentElement.getAttribute('transform').match(/-?\d+\.?\d*/g); @@ -404,7 +403,27 @@ const Counter = new function() { }, pointerOver = function() { - // console.log('pointer over counter', this); + let { troopNumber, troopAllegiance } = this.dataset; + cp = document.getElementById(`clip-path-${troopAllegiance}-${troopNumber}`); + + if (cp) { + cp.style.display = 'none'; + } + }, + + pointerOut = function() { + let { troopNumber, troopAllegiance } = this.dataset; + cp = document.getElementById(`clip-path-${troopAllegiance}-${troopNumber}`); + + if (cp) { + let isVisible = + document + .getElementById('toggle-firing-arc-vis') + .querySelector(`input[data-allegiance="${troopAllegiance}"]`) + .checked; + + cp.style.display = isVisible ? 'none' : ''; + } }, click = function() { @@ -545,7 +564,6 @@ const Counter = new function() { } trace.setAttributeNS(null, 'points', points); - counter.addEventListener('pointerover', pointerOver); counter.addEventListener('click', clickClone); } else { counter = document.createElementNS(svgns, 'use'), @@ -561,6 +579,7 @@ const Counter = new function() { counter.style.pointerEvents = 'auto'; counter.addEventListener('pointerover', pointerOver); + counter.addEventListener('pointerout', pointerOut); counter.addEventListener('click', click); counter.addEventListener('dblclick', dblClick); } |