Skip to content

Commit

Permalink
Update menu.js
Browse files Browse the repository at this point in the history
  • Loading branch information
undefinedlL authored Mar 12, 2024
1 parent ff2b0a1 commit 1bcaa4f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions js/menu.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
const menuBtn = document.querySelector('.menu_btn');
const menuList = document.querySelector('.nav_block');

const popupBg = document.querySelector('.popup_bg');
const popup = document.querySelector('.popup');
const openPopupButtons = document.querySelectorAll('.open_popup');
const closePopupButton = document.querySelector('.close_popup');

menuBtn.addEventListener('click', () => {
if (menuList.classList.contains('_click_btn')) {
menuList.classList.remove('_click_btn');
} else {
menuList.classList.add('_click_btn');
}
});

openPopupButtons.forEach(button => {
button.addEventListener('click', () => {
popupBg.classList.add('_active');
popup.classList.add('_active');
setTimeout(() => {
menuList.classList.remove('_click_btn')
}, 1000)
;
});
});

closePopupButton.addEventListener('click', () => {
popupBg.classList.remove('_active');
popup.classList.remove('_active');
});

document.addEventListener('click', (e) => {
if(e.target === popupBg) {
popupBg.classList.remove('_active');
popup.classList.remove('_active');
}
});

0 comments on commit 1bcaa4f

Please sign in to comment.