Spaces:
Running
Running
File size: 961 Bytes
9ba650c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
const sidebar = document.querySelector(".sidebar");
const menuButton = document.querySelector(".menu-button");
function toggleSidebar(event) {
if (sidebar.classList.contains("shown")) {
hideSidebar(event.target);
} else {
showSidebar(event.target);
}
window.scrollTo(0, 0);
}
function showSidebar(target) {
sidebar.classList.add("shown");
target.classList.add("rotated");
document.body.style.overflow = "hidden";
}
function hideSidebar(target) {
sidebar.classList.remove("shown");
target.classList.remove("rotated");
document.body.style.overflow = "auto";
}
menuButton.addEventListener("click", toggleSidebar);
document.body.addEventListener('click', function(event) {
if (event.target.matches('.conversation-title')) {
const menuButtonStyle = window.getComputedStyle(menuButton);
if (menuButtonStyle.display !== 'none') {
hideSidebar(menuButton);
}
}
});
|