2020-04-01 10:14:18 +08:00
|
|
|
let isHeaderShrink = false;
|
2020-04-01 15:28:01 +08:00
|
|
|
const header = document.querySelector('.header-wrapper');
|
|
|
|
const pageTemplateContainer = document.querySelector('.page-template');
|
|
|
|
const menuBar = document.querySelector('.menu-bar');
|
|
|
|
const windowMask = document.querySelector('.window-mask');
|
|
|
|
const headerHeight = header.getBoundingClientRect().height;
|
2020-04-01 10:14:18 +08:00
|
|
|
|
|
|
|
window.addEventListener('scroll', function (e) {
|
|
|
|
|
2020-04-01 15:28:01 +08:00
|
|
|
const scrollTop = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
|
|
|
|
|
|
|
|
if (!isHeaderShrink && scrollTop > headerHeight) {
|
2020-04-01 10:14:18 +08:00
|
|
|
isHeaderShrink = true;
|
|
|
|
header.classList.add('header-wrapper-shrink');
|
|
|
|
pageTemplateContainer.classList.add('page-top-shrink');
|
2020-04-01 15:28:01 +08:00
|
|
|
} else if (isHeaderShrink && scrollTop <= headerHeight) {
|
2020-04-01 10:14:18 +08:00
|
|
|
isHeaderShrink = false;
|
|
|
|
header.classList.remove('header-wrapper-shrink');
|
|
|
|
pageTemplateContainer.classList.remove('page-top-shrink');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
menuBar.addEventListener('click', function (e) {
|
|
|
|
header.classList.toggle('header-drawer-show');
|
|
|
|
});
|
|
|
|
|
|
|
|
windowMask.addEventListener('click', function (e) {
|
|
|
|
header.classList.toggle('header-drawer-show');
|
|
|
|
});
|
|
|
|
|
2020-04-02 11:01:24 +08:00
|
|
|
|
|
|
|
const searchBtn = document.querySelector('.search-btn');
|
|
|
|
searchBtn.addEventListener('click', function (e) {
|
|
|
|
});
|