zxf/js/main.js

84 lines
2.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
2023-10-09 17:28:38 +08:00
let t1;
2023-10-04 17:06:26 +08:00
function showMenu() {
2023-10-09 17:28:38 +08:00
clearTimeout(t1);
heaerMenuGroup.show().removeClass('iFadeOut').addClass('iFadeIn');
headerMask.show().removeClass('iFadeOut').addClass('iFadeIn');
2023-10-08 21:48:47 +08:00
headerMenuBtn.attr('src', window.Config.staticDir + '/images/guanbi.png');
2023-10-09 17:28:38 +08:00
$('body').css('overflow', 'hidden');
2023-10-04 17:06:26 +08:00
isClose = false;
}
function hideMenu() {
2023-10-09 17:28:38 +08:00
heaerMenuGroup.removeClass('iFadeIn').addClass('iFadeOut');
headerMask.removeClass('iFadeIn').addClass('iFadeOut');
2023-10-08 21:48:47 +08:00
headerMenuBtn.attr('src', window.Config.staticDir + '/images/menu.png');
2023-10-09 17:28:38 +08:00
$('body').css('overflow', 'auto');
2023-10-04 17:06:26 +08:00
isClose = true;
2023-10-09 17:28:38 +08:00
clearTimeout(t1);
t1 = setTimeout(function () {
heaerMenuGroup.hide();
headerMask.hide();
}, 1200);
2023-10-04 17:06:26 +08:00
}
2023-09-26 17:55:52 +08:00
$(function () {
2023-10-11 19:46:21 +08:00
function setRem() {
var whdef = 100 / 1920;// 表示1920的设计图,使用100PX的默认值 1rem = 100px
var wH = window.innerHeight;// 当前窗口的高度
var wW = window.innerWidth;// 当前窗口的宽度
var rem = wW * whdef;// 以默认比例值乘以当前窗口宽度,得到该宽度下的相应FONT-SIZE值
$('html').css('font-size', rem + "px");
$(window).resize(function () {
var whdef = 100 / 1920;// 表示1920的设计图,使用100PX的默认值
var wH = window.innerHeight;// 当前窗口的高度
var wW = window.innerWidth;// 当前窗口的宽度
var rem = wW * whdef;// 以默认比例值乘以当前窗口宽度,得到该宽度下的相应FONT-SIZE值
$('html').css('font-size', rem + "px");
});
}
setRem();
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
$('.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
});