diff options
Diffstat (limited to 'public/app.js')
| -rw-r--r-- | public/app.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/public/app.js b/public/app.js index b0a0db4..a80623f 100644 --- a/public/app.js +++ b/public/app.js @@ -210,7 +210,6 @@ function renderNav(id) { if (!TOUCH) { zone.addEventListener("pointermove", () => { if (adjacentTile(id, ex.dir)) return - if (cur && cur.id === id) return cancelHideGhost() showGhost(choosePlacement(id, ex.dir)) }) @@ -344,6 +343,13 @@ function traverseFrom(id, dir) { let ghost = null let ghostKey = "" +let ghostVisible = false +function setPreviewHidden(hidden) { + ghostVisible = hidden + if (!cur) return + const zs = zones.get(cur.id) + if (zs) for (const z of zs) z.classList.toggle("hidden", hidden) +} function showGhost(p) { if (!p) return const key = p.id + "|" + p.rect.x + "," + p.rect.y @@ -362,6 +368,7 @@ function showGhost(p) { el.appendChild(img) world.appendChild(el) ghost = el + setPreviewHidden(true) } function hideGhost() { @@ -370,6 +377,7 @@ function hideGhost() { ghost = null } ghostKey = "" + setPreviewHidden(false) } let hideGhostTimer = 0 @@ -435,6 +443,7 @@ function renderTileZones(id) { z.addEventListener("click", () => traverseFrom(id, bestDir)) world.appendChild(z) zones.set(id, [z]) + setPreviewHidden(ghostVisible) } function refreshPreviews() { |
