update the player token to have 9999 z index when moved to keep it on top of other tokens.
This commit is contained in:
parent
3d84f9053c
commit
07a8bdca8d
|
|
@ -15,12 +15,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
cell.id = `cell-${i}-${j}`
|
cell.id = `cell-${i}-${j}`
|
||||||
cell.dataset.piece = ""
|
cell.dataset.piece = ""
|
||||||
cell.classList.add('cell')
|
cell.classList.add('cell')
|
||||||
// if ((i + j) % 2 == 0) {
|
|
||||||
// cell.classList.add('dark')
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// cell.classList.add('light')
|
|
||||||
// }
|
|
||||||
|
|
||||||
const board = document.getElementById('board')
|
const board = document.getElementById('board')
|
||||||
board.appendChild(cell)
|
board.appendChild(cell)
|
||||||
|
|
@ -53,6 +47,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
// check for the player grabbing the player icon
|
// check for the player grabbing the player icon
|
||||||
player_token.addEventListener('pointerdown', (e) => {
|
player_token.addEventListener('pointerdown', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
player_token.style.zIndex = "9999";
|
||||||
const rect = player_token.getBoundingClientRect();
|
const rect = player_token.getBoundingClientRect();
|
||||||
player_token.style.width = `${rect.width}px`;
|
player_token.style.width = `${rect.width}px`;
|
||||||
player_token.style.height = `${rect.height}px`;
|
player_token.style.height = `${rect.height}px`;
|
||||||
|
|
@ -68,6 +63,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
// Impliment the dragging
|
// Impliment the dragging
|
||||||
player_token.addEventListener('pointermove', (e) => {
|
player_token.addEventListener('pointermove', (e) => {
|
||||||
if (!isDragging) return;
|
if (!isDragging) return;
|
||||||
|
player_token.style.zIndex = "9999";
|
||||||
|
|
||||||
player_token.style.position = 'absolute';
|
player_token.style.position = 'absolute';
|
||||||
player_token.style.left = `${e.pageX - offsetX}px`;
|
player_token.style.left = `${e.pageX - offsetX}px`;
|
||||||
player_token.style.top = `${e.pageY - offsetY}px`;
|
player_token.style.top = `${e.pageY - offsetY}px`;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue