I'm currently encountering issues with a mobile navigation I have created. It's a simple hamburger icon and when you click it, it opens a fullscreen menu. The problem is I'm trying to disable scrolling when the overlay is visible. Now I figured I could achieve this by adding;
$('body').bind('touchmove', function(e){e.preventDefault()});
This works once, but when you close the menu again preventDefault remains active and I have no clue how to unbind this because the hamburger icon is used for both opening and closing the menu.
I have added the full js script I use below;
$(document).ready(function () {
$(".icon").click(function () {
$('body').bind('touchmove', function(e){e.preventDefault()});
$(".mobilenav").fadeToggle(500);
$(".top-menu").toggleClass("top-animate");
$(".mid-menu").toggleClass("mid-animate");
$(".bottom-menu").toggleClass("bottom-animate");
});
});
Thanks for the help!