Hej, użytkownik mi podaje pozycje scrolla (góra/dół) kiedy ma się odpalić animacja oraz po ilu px w górę ma animacja wrocic do swojej pierwotnej postaci. Niestety scrollując w górę animacja mi nie działa. Prosze o pomoc
np attribute1 - 500 ( scroll w dół o 500 odpala się animacja)
attribute2 - 200 ( scroll w górę o 200 odpala się animacja)
let isScrolledUnderAttribute1 = false
window.addEventListener(scroll , function () {
let st = window.pageYOffset || document.documentElement.scrollTop;
if (st > Number(attribute1)){
hat2.style.maxHeight='0'
hat2.style.marginBottom='0'
hat2.style.overflow='hidden'
hat2.style.transition='max-height .3s ease'
isScrolledUnderAttribute1= true;
}
if(isScrolledUnderAttribute1 && st <= st - Number(attribute2)) {
hat2.style.maxHeight='50px'
hat2.style.marginBottom='6px'
hat2.style.transition='max-height .3s ease'
}
})
```