Made the dialog close when clicking off of it.
This commit is contained in:
parent
b2a29e2b13
commit
b100435d9c
1 changed files with 13 additions and 1 deletions
|
@ -115,6 +115,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
}
|
}
|
||||||
let gameScriptLoaded = false;
|
let gameScriptLoaded = false;
|
||||||
|
const gameDialog = document.getElementById('game-container-wrapper')
|
||||||
$('#show-game-btn').on('click', function() {
|
$('#show-game-btn').on('click', function() {
|
||||||
console.log('Show game button clicked');
|
console.log('Show game button clicked');
|
||||||
if (!gameScriptLoaded) {
|
if (!gameScriptLoaded) {
|
||||||
|
@ -127,8 +128,19 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
} else {
|
} else {
|
||||||
window.resetGame();
|
window.resetGame();
|
||||||
}
|
}
|
||||||
document.getElementById('game-container-wrapper').showModal();
|
gameDialog.showModal();
|
||||||
});
|
});
|
||||||
|
gameDialog.addEventListener("click", e => {
|
||||||
|
const dialogDimensions = gameDialog.getBoundingClientRect()
|
||||||
|
if (
|
||||||
|
e.clientX < dialogDimensions.left ||
|
||||||
|
e.clientX > dialogDimensions.right ||
|
||||||
|
e.clientY < dialogDimensions.top ||
|
||||||
|
e.clientY > dialogDimensions.bottom
|
||||||
|
) {
|
||||||
|
gameDialog.close()
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<div id="game-container">
|
<div id="game-container">
|
||||||
|
|
Loading…
Reference in a new issue