hidable menu content

This commit is contained in:
2021-12-31 13:17:37 +01:00
parent 39fc339776
commit 15613b3f4c
3 changed files with 104 additions and 76 deletions

10
main.js
View File

@ -11,6 +11,7 @@ const resetBtn = document.querySelector('#reset');
const stopBtn = document.querySelector('#stop');
const cellSize = document.querySelector('#cellSize');
const loop = document.querySelector('#loop');
const menuRow = document.querySelectorAll('.menu-row');
canvas.width = main.offsetWidth * 0.9;
canvas.height = main.offsetHeight * 0.9;
@ -123,3 +124,12 @@ resetBtn.addEventListener('click', async () => {
stopBtn.addEventListener('click', async () => {
drawing = 0;
});
menuRow.forEach((elem) => {
elem.querySelector('h2').addEventListener('click', async (e) => {
// ugly
const menuDisplay = e.currentTarget.parentNode.querySelector('.menu-row-content').style;
if (menuDisplay.display !== 'none') menuDisplay.setProperty('display', 'none');
else menuDisplay.setProperty('display', 'block');
});
});