fix: disable page scroll when mobile nav is opened

This commit is contained in:
Matthieu Bessat 2023-05-21 22:46:45 +02:00
parent 8da6e620ea
commit 7ad361d49f

View file

@ -33,3 +33,16 @@
</div> </div>
</div> </div>
</header> </header>
<script>
// workaround to limit the page scroll if the mobile nav is opened
const nav_button = document.getElementById("navi-toggle")
nav_button.addEventListener("change", event => {
if (event.target.checked) {
document.body.style.overflow = "hidden";
}
if (!event.target.checked) {
document.body.style.overflow = "initial";
}
})
</script>