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()});
But this doesn't toggle within the click event. How would I achieve it, so that it toggles? When clicked again scrolling should be possible again. The full script;
$(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");
});
});