38 lines
1.5 KiB
JavaScript
38 lines
1.5 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
|
|
https://www.chromewatchparty.com/copyright
|
|
=========================================================================
|
|
ALL CONTENT ON WATCH PARTY'S WEBSITE OR IN WATCH PARTY'S CHROME EXTENSION APP, UNLESS OTHERWISE
|
|
CITED ARE THE SOLE INTELECTUAL PROPERTY OF AYUSHYA AMITABH, AND MAY NOT BE
|
|
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) {
|
|
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);
|
|
};
|