Fix ReferenceError by updating gameBoard to klondikeBoard
This commit is contained in:
parent
d66c1dfc02
commit
0fcd6b190d
14
script.js
14
script.js
@ -425,7 +425,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function triggerBouncingCards() {
|
function triggerBouncingCards() {
|
||||||
const boardRect = gameBoard.getBoundingClientRect();
|
const boardRect = klondikeBoard.getBoundingClientRect();
|
||||||
const cardsToBounce = [];
|
const cardsToBounce = [];
|
||||||
|
|
||||||
// Gather all top cards from foundations to start the bounce sequence
|
// Gather all top cards from foundations to start the bounce sequence
|
||||||
@ -702,7 +702,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ====== INPUT HANDLERS ======
|
// ====== INPUT HANDLERS ======
|
||||||
gameBoard.addEventListener('click', e => {
|
klondikeBoard.addEventListener('click', e => {
|
||||||
if (!isActive || isAutoCompleting) return;
|
if (!isActive || isAutoCompleting) return;
|
||||||
|
|
||||||
const clickedCardEl = e.target.closest('.card');
|
const clickedCardEl = e.target.closest('.card');
|
||||||
@ -724,7 +724,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Custom drag and drop functionality
|
// Custom drag and drop functionality
|
||||||
gameBoard.addEventListener('dragstart', e => {
|
klondikeBoard.addEventListener('dragstart', e => {
|
||||||
if (!isActive || isAutoCompleting) { e.preventDefault(); return; }
|
if (!isActive || isAutoCompleting) { e.preventDefault(); return; }
|
||||||
const cardEl = e.target.closest('.card');
|
const cardEl = e.target.closest('.card');
|
||||||
if (!cardEl) { e.preventDefault(); return; }
|
if (!cardEl) { e.preventDefault(); return; }
|
||||||
@ -780,7 +780,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
dragged.ghostEl.style.top = `${e.clientY - dragged.offsetY}px`;
|
dragged.ghostEl.style.top = `${e.clientY - dragged.offsetY}px`;
|
||||||
});
|
});
|
||||||
|
|
||||||
gameBoard.addEventListener('drag', e => {
|
klondikeBoard.addEventListener('drag', e => {
|
||||||
if (dragged.ghostEl && e.clientX !== 0) {
|
if (dragged.ghostEl && e.clientX !== 0) {
|
||||||
// Update ghost element position to follow the cursor
|
// Update ghost element position to follow the cursor
|
||||||
dragged.ghostEl.style.left = `${e.clientX - dragged.offsetX}px`;
|
dragged.ghostEl.style.left = `${e.clientX - dragged.offsetX}px`;
|
||||||
@ -788,7 +788,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gameBoard.addEventListener('dragover', e => {
|
klondikeBoard.addEventListener('dragover', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const targetEl = e.target.closest('.card, .pile');
|
const targetEl = e.target.closest('.card, .pile');
|
||||||
@ -815,7 +815,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gameBoard.addEventListener('dragend', () => {
|
klondikeBoard.addEventListener('dragend', () => {
|
||||||
// Clean up ghost element and reset state
|
// Clean up ghost element and reset state
|
||||||
if (dragged.ghostEl) {
|
if (dragged.ghostEl) {
|
||||||
dragged.ghostEl.remove();
|
dragged.ghostEl.remove();
|
||||||
@ -828,7 +828,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
updateBoard(); // Re-render to ensure everything is correct
|
updateBoard(); // Re-render to ensure everything is correct
|
||||||
});
|
});
|
||||||
|
|
||||||
gameBoard.addEventListener('drop', e => {
|
klondikeBoard.addEventListener('drop', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
document.querySelectorAll('.drag-over').forEach(p => p.classList.remove('drag-over'));
|
document.querySelectorAll('.drag-over').forEach(p => p.classList.remove('drag-over'));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user