zxf/js/main.js

61 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-10-08 21:48:47 +08:00
window.Config = {
2023-10-09 17:23:49 +08:00
staticDir: '.'
2023-10-08 21:48:47 +08:00
};
2023-10-09 17:23:49 +08:00
2023-10-08 21:48:47 +08:00
let isClose = true,
header = $('.header'),
heaerMenuGroup = $('.menu-group'),
headerMask = $('.menu-mask'),
2023-10-09 17:23:49 +08:00
headerMenuBtn = $('.btn-img');
2023-10-04 17:06:26 +08:00
function showMenu() {
2023-10-08 21:48:47 +08:00
heaerMenuGroup.show().addClass('fadeIn');
headerMask.show().addClass('fadeIn');
headerMenuBtn.attr('src', window.Config.staticDir + '/images/guanbi.png');
2023-10-04 17:06:26 +08:00
isClose = false;
}
function hideMenu() {
2023-10-08 21:48:47 +08:00
heaerMenuGroup.removeClass('fadeIn').hide();
headerMask.removeClass('fadeIn').hide();
headerMenuBtn.attr('src', window.Config.staticDir + '/images/menu.png');
2023-10-04 17:06:26 +08:00
isClose = true;
}
2023-09-26 17:55:52 +08:00
$(function () {
2023-10-09 17:23:49 +08:00
$('.header .menu-group').load('../common/header.html');
$('.footer').load('../common/footer.html');
$(window).scroll(function () {
let t = $(document).scrollTop(), flag;
if ($(window).width() > 768) {
flag = t > 400;
} else {
flag = t > 60;
}
if (flag) {
header.removeClass('style1').addClass('style2');
} else {
header.removeClass('style2').addClass('style1');
}
});
2023-10-08 21:48:47 +08:00
header.on('click', '.menu-btn', function () {
2023-10-04 17:06:26 +08:00
(isClose == true) ? showMenu() : hideMenu();
});
2023-10-08 21:48:47 +08:00
header.on('click', '.menu-mask', function () {
2023-10-04 17:06:26 +08:00
hideMenu();
});
2023-10-08 21:48:47 +08:00
$('.business-nav a').click(function (event) {
$('.business-nav a').removeClass('active');
$(this).addClass('active');
event.preventDefault();
let id = $(this).attr('href');
let ot = $(id)[0].offsetTop;
window.scrollTo({
top: ot - 90,
behavior: "smooth",
});
});
2023-10-04 17:06:26 +08:00
2023-09-27 00:33:44 +08:00
new WOW().init();
2023-10-09 17:23:49 +08:00
});