Files
watchparty/website/scripts/Stickied.js
T
2020-06-29 01:02:08 -04:00

22 lines
684 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) {
logo.classList.add('stickied');
} else {
logo.classList.remove('stickied');
}
if (window.scrollY >= GET_INIT + get.offsetHeight) {
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);
};