Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(){
- var menuClass = 'header-menu__wrap'; //container ul
- var mainmenu = document.getElementById('header-menu'); //container ul
- var mainmenuHeight;
- var button = document.getElementById('button-xs'); //button
- var translateX = -110 + "%";
- var active = true;
- var headerTop = document.querySelectorAll('.header-top')[0];
- var headerbottom = document.querySelectorAll('.header-bottom')[0];
- var body = document.getElementsByTagName('body');
- var submenulvl2 = document.querySelectorAll('.header-menu__wrap > li > ul > li > ul');
- if (submenulvl2.length > 0) {
- for (var i = 0; submenulvl2.length > i; i++) {
- submenulvl2[i].classList.add("header-submenu__container-level");
- }
- }
- button.addEventListener("click", buttonClick);
- function buttonClick() {
- if (active) {
- button.classList.add("active");
- active = false;
- body[0].style.overflow = 'hidden';
- } else {
- button.classList.remove("active");
- active = true;
- body[0].removeAttribute('style');
- }
- }
- /*
- function addFixedMenu(){
- if (pageYOffset > mainmenuHeight) {
- headerTop.classList.add("header-top_fixed");
- } else {
- headerTop.classList.remove("header-top_fixed");
- }
- }
- */
- if(window.innerWidth >= 768) {
- mainmenuHeight = document.getElementById('header-menu').offsetHeight;
- headerbottom.style.marginTop = mainmenuHeight + "px";
- } else {
- headerbottom.style.marginTop = "0";
- }
- window.onresize = function() {
- if(window.innerWidth >= 768) {
- button.classList.remove("active");
- mainmenuHeight = document.getElementById('header-menu').offsetHeight;
- headerbottom.style.marginTop = mainmenuHeight + "px";
- } else {
- headerbottom.style.marginTop = "0";
- }
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement