Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery addClass removeClass animation when div is display none

Its possible to combine jQuery addClass with animation when the div is display:none ?

jQuery

 $(window).scroll(function() {
        $(this).scrollTop() > 100 ? $(".nav-current").addClass("hide") : $(".nav-current").removeClass("hide");
        $(this).scrollTop() > 100 ? $(".nav-affix").addClass("show") : $(".nav-affix").removeClass("show");
        $(this).scrollTop() > 50 ? $(".navbar").addClass("go-top navbar-fixed-top") : $(".navbar").removeClass("go-top navbar-fixed-top");
    });

CSS

.show {
    display: block;
}

.hide {
    display: none;
}

.nav-affix {
    display: none;
    > li {
        > a {
            font-size: 12px !important;
            transition: all 0.3s;
        }
    }
 }
like image 404
Booster Avatar asked Dec 27 '25 23:12

Booster


1 Answers

Agree with fauxserious - you can use fadeIn and fadeOut jQuery functions to achieve your goal.

One more option is using width(1000) and height(1000) where argument (1000) is a duration in milliseconds, thus you could get some animation.

Let me know if you still have an issue.

like image 178
Vnuuk Avatar answered Dec 30 '25 11:12

Vnuuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!