update the player token to have 9999 z index when moved to keep it on top of other tokens.

This commit is contained in:
taylor berukoff 2025-11-13 15:25:48 -10:00
parent 3d84f9053c
commit 07a8bdca8d
1 changed files with 3 additions and 6 deletions

View File

@ -15,12 +15,6 @@ document.addEventListener('DOMContentLoaded', () => {
cell.id = `cell-${i}-${j}`
cell.dataset.piece = ""
cell.classList.add('cell')
// if ((i + j) % 2 == 0) {
// cell.classList.add('dark')
// }
// else {
// cell.classList.add('light')
// }
const board = document.getElementById('board')
board.appendChild(cell)
@ -53,6 +47,7 @@ document.addEventListener('DOMContentLoaded', () => {
// check for the player grabbing the player icon
player_token.addEventListener('pointerdown', (e) => {
e.preventDefault();
player_token.style.zIndex = "9999";
const rect = player_token.getBoundingClientRect();
player_token.style.width = `${rect.width}px`;
player_token.style.height = `${rect.height}px`;
@ -68,6 +63,8 @@ document.addEventListener('DOMContentLoaded', () => {
// Impliment the dragging
player_token.addEventListener('pointermove', (e) => {
if (!isDragging) return;
player_token.style.zIndex = "9999";
player_token.style.position = 'absolute';
player_token.style.left = `${e.pageX - offsetX}px`;
player_token.style.top = `${e.pageY - offsetY}px`;