Files
watchparty/website/scripts/Stickied.js
T

33 lines
1.1 KiB
JavaScript

/************************************************************************
Copyright (C) Ayushya Amitabh - All Rights Reserved
Unauthorized copying of this file, via any medium is strictly prohibited
Proprietary and confidential
Written by Ayushya Amitabh <admin@chromewatchparty.com>, 2020
************************************************************************/
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) {
logo.classList.add('stickied');
} else {
logo.classList.remove('stickied');
}
if (get) {
if (window.scrollY >= GET_INIT + get.offsetHeight * 2) {
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')
? document.querySelector('.landing .link-button').offsetTop
: 0;
window.addEventListener('scroll', this.handleSticky);
};