don't mess up with scroll if page not long enough...

This commit is contained in:
Marcell Mars 2020-09-13 04:04:27 +02:00
parent 10c67230a6
commit 4c7af733c6
1 changed files with 5 additions and 1 deletions

View File

@ -9,12 +9,16 @@ window.addEventListener('scroll', function(e) {
let grid = document.querySelector('.grid')
let gridrect = mantletitle.getBoundingClientRect();
if ((document.querySelector('body').clientHeight - (grid.clientHeight + mantle.clientHeight + 32)) < window.innerHeight) {
return
}
if (gridrect.top < 20 && !grid.classList.contains('moved')) {
grid.classList.add('moved');
mantlebar.style.display = "inline";
mantletitle.style.visibility = "hidden";
grid.style.display = "none";
window.scrollBy({top: grid.clientHeight + mantletitle.clientHeight, behavior: 'smooth'})
window.scrollBy({top: mantletitle.clientHeight, behavior: 'smooth'})
} else if (gridrect.top > 21 && grid.classList.contains('moved')) {
grid.classList.remove('moved');
mantletitle.style.visibility = "visible";