Skip to content

Commit

Permalink
dweam_web/game: fix controls collapsing
Browse files Browse the repository at this point in the history
  • Loading branch information
irgolic committed Jan 2, 2025
1 parent 9407bf7 commit 1798f14
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dweam_web/src/pages/game/[type]/[id].astro
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ try {
</svg>
</div>
</button>
<div id="controls-wrapper" class="transition-all duration-300 overflow-hidden">
<div id="controls-wrapper" class="transition-all duration-300 overflow-hidden opacity-100">
<div id="controls-content" class="space-y-2 mt-4">
{Object.entries(gameData.buttons).map(([action, key]) => (
<div class="flex justify-between items-center">
Expand Down Expand Up @@ -143,13 +143,14 @@ try {
const chevron = document.getElementById('controls-chevron');

if (toggleButton && controlsWrapper && controlsContent && chevron) {
// Add a larger buffer to the height calculation
let isExpanded = true;

controlsWrapper.style.maxHeight = (controlsContent.offsetHeight + 24) + 'px';

toggleButton.addEventListener('click', () => {
const isExpanded = controlsWrapper.style.maxHeight !== '0px';
isExpanded = !isExpanded;

if (isExpanded) {
if (!isExpanded) {
controlsWrapper.style.maxHeight = '0px';
controlsWrapper.style.opacity = '0';
chevron.style.transform = 'rotate(-90deg)';
Expand Down

0 comments on commit 1798f14

Please sign in to comment.