$(function(){ var oldV = 0; let head = $('#header') let height = $('#header_ct').height(); if($(this).scrollTop()==0) head.addClass('scroll-top'); if(!head.hasClass('fixed')) head.css({height:height}); $(window).scroll(function(){ if(head.is('.hover,.menu_expand')) return;//侧边展开 var newV = $(this).scrollTop(); var is_up = newVheight){ if (is_up){ head.addClass('scroll-up').removeClass('scroll-down') } else { head.addClass('scroll-down').removeClass('scroll-up') } }else{ head.removeClass('scroll-up scroll-down') } oldV = newV <= 0 ? 0 : newV; // 置顶 if(newV <= 0){ head.addClass('scroll-top').removeClass('scroll-center') console.log(1); }else{ head.addClass('scroll-center').removeClass('scroll-top'); } }); $(window).resize(()=>{ height = $('#header_ct').height() if(!head.hasClass('fixed')) head.css({height:height}); }) // 鼠标进入头部 $(head).mouseenter(function(){ $(this).addClass('hover') }); // 鼠标移出头部 $(head).mouseleave(function(){ $(this).removeClass('hover') }); $.task.unshift(function(){ _('[data-xheader-class]').each(function(){ head.removeClass('opacity_black fixed').addClass($('[data-xheader-class]').attr('data-xheader-class')); }); // head.removeClass('opacity_black fixed').addClass($('[data-xheader-class]').attr('data-xheader-class')); }); }); $$My.after(document.head,`
`);