v1.6.0/header fix and website optimization
This commit is contained in:
@@ -13,25 +13,33 @@ COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
|
||||
var LOGO_INIT = 0;
|
||||
var GET_INIT = 0;
|
||||
function handleSticky() {
|
||||
const logo = document.querySelector('.logo');
|
||||
const get = document.querySelector('.landing .link-button');
|
||||
if (window.scrollY >= LOGO_INIT + logo.offsetHeight * 2) {
|
||||
const logo = document.querySelector('.logo.duplicate');
|
||||
const get = document.querySelector('.landing .link-button.duplicate');
|
||||
if (window.scrollY >= LOGO_INIT + logo.offsetHeight) {
|
||||
logo.classList.add('stickied');
|
||||
} else {
|
||||
logo.classList.remove('stickied');
|
||||
}
|
||||
if (get) {
|
||||
if (window.scrollY >= GET_INIT + get.offsetHeight * 2) {
|
||||
if (window.scrollY >= GET_INIT + get.offsetHeight) {
|
||||
get.classList.add('stickied');
|
||||
} else {
|
||||
get.classList.remove('stickied');
|
||||
}
|
||||
}
|
||||
}
|
||||
function handleLogoMargin () {
|
||||
const logo = document.querySelector('.logo.duplicate');
|
||||
if (logo) document.documentElement.style.setProperty('--logo-offset', '-' + logo.offsetHeight + 'px');
|
||||
const linkButton = document.querySelector('.link-button.duplicate');
|
||||
if (linkButton) document.documentElement.style.setProperty('--link-button-offset', '-' + linkButton.offsetHeight + 'px');
|
||||
}
|
||||
window.onload = function () {
|
||||
LOGO_INIT = document.querySelector('.logo').offsetTop;
|
||||
GET_INIT = document.querySelector('.landing .link-button')
|
||||
? document.querySelector('.landing .link-button').offsetTop
|
||||
: 0;
|
||||
this.handleLogoMargin();
|
||||
window.addEventListener('scroll', this.handleSticky);
|
||||
window.addEventListener('resize', this.handleLogoMargin);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user