Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ramzs/f0c982aa6689b01fc90f24bfa317bb68 to your computer and use it in GitHub Desktop.
Save ramzs/f0c982aa6689b01fc90f24bfa317bb68 to your computer and use it in GitHub Desktop.
Мобильное меню с оверлеем и автовысотой
mainSliderDesc.controller.control = mainSlider;
mainSlider.controller.control = mainSliderDesc;
let menuButton = document.querySelector('.menu-button');
let mobileNav = document.querySelector('.mobile-nav');
let mobileNavClose = document.querySelector('.mobile-nav__close');
let overlay = document.querySelector('.overlay');
let body = document.querySelector('body');
let openMenu = function () {
menuButton.classList.toggle('active');
mobileNav.classList.toggle('open');
mobileNav.classList.toggle('hide');
overlay.classList.toggle('active');
body.classList.toggle('overflow');
appHeight();
};
menuButton.addEventListener('click', openMenu, true);
mobileNavClose.addEventListener('click', openMenu, true);
overlay.addEventListener('click', openMenu, true);
// Auto height
const appHeight = () => {
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
};
appHeight();
window.addEventListener('resize', appHeight);
window.addEventListener('load', appHeight);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment