// window.onbeforeunload = function () { // $(window).scrolltop(0) // } var mousex = null; var mousey = null; var ismenu = false; document.addeventlistener('mousemove', function (e) { if (e.pagex != mousex || e.pagey != mousey) { if (mousex && mousey) { ismenu = true; } mousex = e.pagex; mousey = e.pagey; } }); $(function () { $('header').addclass('play'); settimeout(function () { $('header').removeclass('play'); }, 2000) $(window).scroll(function () { updateheader(); }) updateheader(); $(document).on('click', '.section-down-arrow', function () { $('html,body').animate({ 'scrolltop': $(window).height() - $('header').height() + 1 }) }) var scrolly = 0; $(window).on('scroll', function () { // 获取当前页面 url 中的 hash 值 var hash = window.location.hash; // 去掉可能存在的查询参数部分(以 ? 开头) var hashwithoutquery = hash.split('?')[0]; // 去掉开头的 # var hashvalue = hashwithoutquery.slice(1); if ($(document).scrolltop() >= scrolly) { // 向下滑动 if (scrolly == 0 && $(window).width() > 768 && !hashvalue) { $('html,body').animate({ 'scrolltop': $(window).height() - $('header').height() + 1 }) } $('header .right .item').removeclass('on'); updateheader(); } scrolly = $(document).scrolltop() }) // 动画 new wow({ offset: 100, }).init(); $('header .right .feature .search-box').click(function (event) { $(this).addclass('on') event.stoppropagation(); }) $(document).on('click', function () { $('header .right .feature .search-box').removeclass('on') }) if ($(window).width() <= 768) { $('header .right .feature .search-box .search input').click(function (event) { event.stoppropagation(); }) $('header .right .feature .search-box .search').click(function (event) { $('header .right .feature .search-box').removeclass('on') event.stoppropagation(); }) $('header .right .nav .item').each(function (index, item) { if ($(item).find('.sub-nav').length > 0) { // $(item).find('.sub-nav').prepend('返回') $(item).find('.sub-nav').find('.back').click(function () { $(this).parents('.item').removeclass('active'); }); $(item).children('a').append('') $(item).children('a').attr('href', 'javascript:void(0);') $(item).children('a').click(function (event) { if ($(item).hasclass('active')) { $(item).removeclass('active').find('.sub-nav').stop().slideup() } else { $(item).addclass('active').find('.sub-nav').stop().slidedown() } event.stoppropagation(); event.preventdefault(); }) $(item).children('a').find('i').click(function (event) { window.open($(this).attr('href'), '_self'); event.stoppropagation(); event.preventdefault(); }); $(item).children('a').attr('target', '_self'); } else { // 设置没有右箭头 $(item).addclass('no-arrow'); } }) $(document).on('click', 'header .language', function (event) { $('header .language').toggleclass('hover') event.stoppropagation(); }) $(document).on('click', function () { $('header .language').removeclass('hover') }) } else { $('header .right .nav .item .sub-nav').hover(function (event) { event.stoppropagation(); }, function () { }) $('header .right .nav .item').hover(function (event) { if (ismenu && $(this).find('.sub-nav .midden-box .rr a').length > 0) { $(this).parent().attr('style', '--width:' + $(this).width() + 'px;' + '--left:' + $(this).position().left + 'px;') $('header .right .nav .item').addclass('on'); $(this).addclass('up').siblings().removeclass('up'); updateheader() } event.stoppropagation(); }, function () { $('header .right .nav .item').removeclass('up'); $('header .right .nav .item').removeclass('on'); initnav() updateheader() }) initnav() $('header .language').hover(function () { $('header .language').addclass('hover') }, function () { $('header .language').removeclass('hover') }) } $(document).on('click', 'button.navbar-toggle', function () { $(this).parents('header').toggleclass('collapsed') $('header .right .nav .item').removeclass('active') }) function initnav () { if ($('header .right .nav .item.active').length > 0) { $('header .right .nav').attr('style', '--width:' + $('header .right .nav .item.active').width() + 'px;' + '--left:' + $('header .right .nav .item.active').position().left + 'px;') } else { $('header .right .nav').attr('style', '--width: 0px;' + '--left: 0px;') } } }) function updateheader () { var navshow = false; $('header .right .item').each(function (index, item) { if ($('header .right .item').hasclass('on')) { navshow = true; } }) if ($(window).scrolltop() >= 100 || $(window).width() <= 768 || navshow) { if (!$('header').hasclass('none')) { $('header').addclass('play').addclass('none'); settimeout(function () { $('header').addclass('show-white'); $('header').removeclass('play').find('.header-logo').addclass('blue'); }, 500) } } else { if ($('header').hasclass('none')) { $('header').addclass('play').removeclass('none'); settimeout(function () { $('header').removeclass('show-white'); $('header').removeclass('play').find('.header-logo').removeclass('blue'); }, 500) } } }