22 lines
696 B
JavaScript
22 lines
696 B
JavaScript
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 * 1.5) {
|
|
logo.classList.add('stickied');
|
|
} else {
|
|
logo.classList.remove('stickied');
|
|
}
|
|
if (window.scrollY >= GET_INIT + get.offsetHeight * 1.5) {
|
|
get.classList.add('stickied');
|
|
} else {
|
|
get.classList.remove('stickied');
|
|
}
|
|
}
|
|
window.onload = function () {
|
|
LOGO_INIT = document.querySelector('.logo').offsetTop;
|
|
GET_INIT = document.querySelector('.landing .link-button').offsetTop;
|
|
window.addEventListener('scroll', this.handleSticky);
|
|
};
|