This commit is contained in:
Daniel Brendel
2023-03-23 00:43:02 +01:00
parent 01f9530645
commit 88c0d34409
5 changed files with 276 additions and 27 deletions

View File

@ -229,10 +229,29 @@ document.addEventListener('DOMContentLoaded', function(){
window.hljs.highlightAll();
window.onscroll = function() {
if ((document.body.scrollTop > document.getElementsByClassName('navbar')[0].offsetHeight + 100) || (document.documentElement.scrollTop > document.getElementsByClassName('navbar')[0].offsetHeight + 100)) {
if ((document.body.scrollTop > document.getElementsByClassName('navbar')[0].offsetHeight + 10) || (document.documentElement.scrollTop > document.getElementsByClassName('navbar')[0].offsetHeight + 10)) {
document.getElementsByClassName('navbar')[0].classList.add('navbar-background-show');
} else {
document.getElementsByClassName('navbar')[0].classList.remove('navbar-background-show');
}
};
const obsoptions = {
root: null,
rootMargin: '0px',
threshold: 0.7
};
const obscallback = function(entries, observer) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.replace('fade-out', 'fade-in');
}
});
};
const observer = new IntersectionObserver(obscallback, obsoptions);
let fadeElems = document.querySelectorAll('.fade');
fadeElems.forEach(elem => observer.observe(elem));
});