Improve sidebar handling when JavaScript is enabled

This commit is contained in:
William Brawner 2024-07-09 17:27:04 -06:00
parent a3d9be660e
commit 0fd0b16b4c
Signed by: wbrawner
GPG key ID: 8FF12381C6C90D35

View file

@ -5,4 +5,19 @@ for (let i = 0; i < forms.length; i++) {
form.onsubmit = () => {
form.querySelector('input[type="submit"]').disabled = true
}
}
}
const sidebar = document.querySelector('#sidebar')
document.querySelector('#hamburger').onclick = (e) => {
e.preventDefault()
sidebar.style.transform = 'translateX(0)'
}
document.addEventListener('click', (e) => {
const style = window.getComputedStyle(sidebar)
const matrix = new DOMMatrixReadOnly(style.getPropertyValue("transform"))
if (matrix.m41 === 0) {
sidebar.style.transform = 'translateX(-100%)'
}
})