click touchstart not working for my full screen menu overlay
Hello :-)
I am really struggling with getting my menu to work on a mobile device. It works beautifully on a desktop.
- function initNavigationSetup() {
console.log("1");
// Menu Variables
var menu = $('#menu');
var header = $('header');
var burger = $('header button#brgr');
var logo = $('a.logo');
var menuItems = $('#menu #navigation ul li');
menuOpen = false;
burger.on('click touchstart', burger, function (event) {
event.preventDefault();
console.log("2");
if (!menuOpen) {
console.log("3");
header.addClass('is-open');
menu.addClass('is-open');
menuItems.addClass('is-open');
menuOpen = true;
} else {
menu.removeClass('is-open');
header.removeClass('is-open');
menuItems.removeClass('is-open');
menuOpen = false;
}
});
}
- $(document).ready(function () {
//Nav
initNavigationSetup();
});
- <nav>
<div id="menu">
<!-- Menu stuff -->
</div>
</nav>
- <header>
<button id="brgr">
<span></span>
<span></span>
<span></span>
</button>
<nav>
<!-- Header menu stuff -->
</nav>
</header>
header {
padding: 55px 43px;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
}
#brgr {
display: block;
width: 15px;
height: 15px;
position: relative;
float: right;
padding: 0;
margin-top: -2px;
}
#brgr > span {
margin-bottom: 3px;
background-color: #000;
display: block;
height: 2px;
width: 100%;
}
#menu {
position: fixed;
top: 0;
width: 100vw;
height: 100vh;
overflow: hidden;
right: -100vw;
background-color: #ebeae6;
z-index: 10;
transition: 1s all
}
#menu.is-open {
right: 0;
}
I must admit I didn't have 'touchstart click' before, only 'click', but adding it has not made a difference for me.
Have I missed anything?
Thank youu :D