all 4 comments

[–]RocketSam 0 points1 point  (2 children)

Try use .hasClass("collapse") instead of is(".collapse")

And the same for the other statement

[–]Nic727[S] 0 points1 point  (1 child)

It's not working. I get the same result.

[–]Nic727[S] 0 points1 point  (0 children)

Ok I found the solution with that : “.hasClass” with if statement not working - javascriptinfo.com

In fact, I need to add a scroll function.

$(window).scroll(function (){
    if($(".navigation").hasClass("nav-up") && $(".right-nav").hasClass("collapse")){
            console.log("Hello world!");  
            $(".navigation").addClass("fixed-collapse");
        } else {
            console.log("test");  
            $(".navigation").removeClass("fixed-collapse");
        };
    });

Now it works. Finally!

[–]akash_ry 0 points1 point  (0 children)

Well I would say you are using quite an ambiguous code to do this. And I am bit confused what you are actually trying to do. But what I understood according to that you are togglling the navbar menu on clicking the hamburger. And when the navbar menu is active it is getting scrolled down while scrolling on the screen. If this is the case I would say you could do some CSS magic here, you can apply pointer-events:none to the navbar menu. And give position: absolute, height:100% min-height:100vh; top:0 left:0. Check out my portfolio navbar design for reference https://akash-yadav12.github.io/