$(window).on('load', function() { new WOW().init(); }); if($(window).width()>998){ $('footer .btm_bottom .btm_l .select').on('click',function(){ $(this).children('ul').slideToggle() }) $(document).bind("click", function(e) { //console.log('111') var target = $(e.target); if (target.closest("footer .btm_bottom .btm_l .select").length == 0) { //点击id为parentId之外的地方触发 $('footer .btm_bottom .btm_l .select').children('ul').stop().slideUp() } }) $('.header .h_top .m_nav li').hover(function(){ $(this).children('.sub_nav').stop().slideDown() },function(){ $(this).children('.sub_nav').stop().slideUp() }) }else{ $('.header .h_top .m_nav .nav_icon').on('click',function(){ if($(this).parent('li').hasClass('on')){ $(this).parent('li').removeClass('on') $(this).siblings('.sub_nav').stop().slideUp() $(this).find("svg").css('transform','rotate(0deg)') }else{ $(this).parent('li').addClass('on') $(this).parent('li').siblings().removeClass('on') $(this).parent('li').siblings().children('.sub_nav').stop().slideUp() $(this).siblings(".sub_nav").slideDown() $(this).find("svg").css('transform','rotate(180deg)') $(this).parent('li').siblings().find("svg").css('transform','rotate(0deg)') } }) } if($(window).width()>998){ $('.header .h_top .language').hover(function(){ $(this).children('.other').stop().slideDown() },function(){ $(this).children('.other').stop().slideUp() }) }else{ $('.header .h_top .language').on('click',function(){ $(this).children('.other').slideToggle() }) } $('.header .u-menu').on('click',function () { if($('.header').hasClass('on')){ if(scrollTop2<10){ console.log(scrollTop2) $('.header').removeClass('on') } }else{ $('.header').addClass('on') } $(this).toggleClass('on') $('.header .h_top .m_nav').slideToggle() }) var scrollTop2 $(window).scroll(function() { scrollTop2 = document.documentElement.scrollTop || document.body.scrollTop; if(scrollTop2>10){ $('.header').addClass('on') }else{ if(!$('.header .u-menu').hasClass('on')){ $('.header').removeClass('on') } } }) $(window).scroll(function () { var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; scrollTop > 500 ? $('.top_btn').css('right','30px') : $('.top_btn').css('right','-50px') }) function scrollToTop(duration = 750) { console.log(duration) let easeingFunction = t => t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1; let originScrollY = pageYOffset; let originScrollX = pageXOffset; let originTime = Date.now(); let passedTime = 0; let _scrollToTop = () => { if (passedTime < duration) { passedTime = Date.now() - originTime; requestAnimationFrame(_scrollToTop); scrollTo(originScrollX, originScrollY * (1 - easeingFunction(passedTime / duration))); } }; _scrollToTop(); } $('.top_btn').on('click', function () { scrollToTop() })