首页 > 代码库 > 鼠标滚动效果

鼠标滚动效果

 var $navFun = function() {
       
        var st = $(document).scrollTop(),
            headh = $("div.head").height()+$("div.jiu-nav-main ").height()+$("div.act-bg").height();
            headh01 = $("div.head").height()+$("div.jiu-nav-main ").height()+$("div.act-bg").height()+$(‘div.act-one‘).height();          
            $nav_classify = $("div.silde-act-nav");
            $dd = $(‘div.silde-act-nav a‘)
            $back = $(‘.back-act‘)

        if(st > headh){
            $nav_classify.addClass("fixed");
            $dd.eq(0).addClass(‘active‘);
        } else {
            $nav_classify.removeClass("fixed");
            $dd.eq(0).removeClass(‘active‘);
        }
            if(st >headh01){
                 $dd.eq(0).removeClass(‘active‘);
                 $dd.eq(1).addClass(‘active‘);
            } else{       
                 $dd.eq(0).addClass(‘active‘);
                 $dd.eq(1).removeClass(‘active‘);
            }
        $back.on(‘click‘,function()
        {
            $(document).animate({ scrollTop: 0 }, 300);
            return false;
        })   

    };


    var F_nav_scroll = function () {
       
        if (!window.XMLHttpRequest) {
           return;         
        }else{
            //默认执行一次
            $navFun();
            $(window).bind("scroll", $navFun);
        }
    }
    F_nav_scroll();