js 滚动调整nav 效果代码及返回顶部效果

jQuery(document).ready(function ($) {

    //What happen on window scroll
    function back_to_top(){
        var scrollTop = $(window).scrollTop();
        var offset = 500;
        if (scrollTop < offset) {
            $('.evision-back-to-top').hide();
        } else {
            $('.evision-back-to-top').show();
        }
    }
    $(window).on("scroll", function (e) {
        back_to_top();
    });
    back_to_top();
    $('a[href*="#"]').on('click', function(event){
        if ($(this.hash).length){
            event.preventDefault();
            $("html, body").stop().animate({scrollTop: $(this.hash).offset().top - 70}, 2e3, "easeInOutExpo");
        }
    });

    
    // fixed navigation
    jQuery(window).on('scroll', function(){

     var stickyHeaderTop = $(this).scrollTop();

       if(stickyHeaderTop>=30){
        if(!$('.navbar-fixed-top').hasClass("navbar-fixed-active"))
        {
            $('.navbar-fixed-top').addClass("navbar-fixed-active").css('paddingBottom', '0');
        }
       }else{
            $('.navbar-fixed-top').removeClass("navbar-fixed-active").css('paddingBottom', '15px');;
       }
    });


});

 

赞(0)
未经允许不得转载:TaKaSa » js 滚动调整nav 效果代码及返回顶部效果