// banner fixed window.addeventlistener('scroll', function() { var bannerfixed = document.queryselector('.banner_fixed'); var bannerfixedheight = bannerfixed.offsetheight; var scrollpos = window.scrolly; if (scrollpos <= bannerfixedheight) { var transformvalue = 'translatey(' + (-scrollpos / 1.5) + 'px)'; bannerfixed.style.transform = transformvalue; } }); $(document).ready(function() { applyheight(); }); $(window).on('resize', function() { applyheight(); }); function applyheight() { // .b_full_header height var b_height = $(".banner_fixed").height(); $(".b_full_header").css("height", b_height); // .in_nav margin-top var in_nav_height = $(".in_nav").height(); $(".in_nav").css("margin-top", -in_nav_height); }; // in nav click if(screen.width < 1025){ $(document).on("click", ".in_nav_tit", function() { $(this).toggleclass("on"); $(".in_nav_list").stop().slidetoggle(); }); // $(document).on("click", ".in_nav_list", function() { // $(".in_nav_tit").toggleclass("on"); // $(this).stop().slidetoggle(); // }); }; if(screen.width < 1025){ $(document).ready(function() { var navh = $(".in_nav").offset().top; var headerheight = $("header").outerheight(); var offsettop = navh - headerheight; var updatenavfixstate = function() { var sorh = $(window).scrolltop(); if (sorh >= offsettop) { $(".in_nav").addclass("navfix"); } else { $(".in_nav").removeclass("navfix"); } }; updatenavfixstate(); // 初始化状态 $(window).scroll(function() { updatenavfixstate(); // 监听滚动事件,根据当前滚动位置更新状态 }); }); };