21 lines
787 B
JavaScript
21 lines
787 B
JavaScript
window.onload = function () {
|
|
let originalTitlePosition = null;
|
|
window.addEventListener('scroll', function (ev) {
|
|
const title = document.getElementsByClassName('title')[0];
|
|
const support = document.getElementsByClassName('support')[0];
|
|
const request = document.getElementsByClassName('request')[0];
|
|
|
|
if (originalTitlePosition === null) originalTitlePosition = title.offsetTop;
|
|
if (window.scrollY > originalTitlePosition) {
|
|
support.classList.add('stickied');
|
|
title.classList.add('stickied');
|
|
request.classList.add('stickied');
|
|
request.style.right = support.clientWidth + 64 + 'px';
|
|
} else {
|
|
support.classList.remove('stickied');
|
|
title.classList.remove('stickied');
|
|
request.classList.remove('stickied');
|
|
}
|
|
});
|
|
};
|