I have a simple menu that is opening on click.
What I would need is to:
- open menu/hamburger on click top left
- user read all text and scrolling down 3.3rd step - close/hide the pop up menu when user reach the end of the page
I kindly ask for a snippet of code to add at my js code
$(document).ready(function() {
$(".toggle-nav").click(function(e) {
e.stopPropagation();
e.preventDefault();
$(this).toggleClass("active");
$(".menu ul").toggleClass("active");
});
$(document).click(function(e){
if(!e.target.closest("ul") && $(".menu a").hasClass("active")){
$(".menu ul").toggleClass("active");
$(".toggle-nav").toggleClass("active");
}
})
});
Here is my codepen to test the function
great solution?
p.s. obviously the action need to work every time the user toggle the hamburger button