-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path13.js
More file actions
19 lines (19 loc) · 807 Bytes
/
13.js
File metadata and controls
19 lines (19 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function scrollIn() {
const sliderImages = document.querySelectorAll(".slide-in");
function checkSlider(e) {
sliderImages.forEach((sliderImage) => {
const slideInAt =
window.scrollY + window.innerHeight - sliderImage.height / 2;
const imageBottom = sliderImage.offsetTop + sliderImage.height;
const isHalifShown = slideInAt > sliderImage.offsetTop;
const isNotScrollPast = window.scrollY < imageBottom;
if (isHalifShown && isNotScrollPast) {
sliderImage.classList.add("active");
} else {
sliderImage.classList.remove("active");
}
});
}
document.addEventListener("scroll", checkSlider);
}
window.addEventListener("DOMContentLoaded", scrollIn);