Cannot read property 'remove' of undefined
Ошибку выкидывает именно эта строчка.
sliderImages.classList.remove('active')
Вся функция:
const sliderImages = document.querySelectorAll('.slide-in');
function checkSlide(e) {
sliderImages.forEach(slideImage => {
const slideInAt = (window.scrollY + window.innerHeight) - sliderImages.height / 2;
const imageBottom = sliderImages.offsetTop + sliderImages.height;
const isHalfShown = slideInAt > sliderImages.offsetTop;
const isNotScrolledPast = window.scrollY < imageBottom;
if(isHalfShown && isNotScrolledPast) {
sliderImages.classList.add('active');
} else {
sliderImages.classList.remove('active')
}
});
}