-
Notifications
You must be signed in to change notification settings - Fork 0
/
observer.js
37 lines (31 loc) · 868 Bytes
/
observer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const faders = document.querySelectorAll(".fade-in");
const sliders = document.querySelectorAll(".slide-in");
const borderBottoms = document.querySelectorAll('.border-bottom');
const appearOptions = {
threshold: 0,
rootMargin: "0px 0px 0px 0px"
};
const appearOnScroll = new IntersectionObserver(function(
entries,
appearOnScroll
) {
entries.forEach(entry => {
if (!entry.isIntersecting && !entry.target.classList.contains('slide')) {
// entry.target.classList.remove("appear");
return;
} else {
entry.target.classList.add("appear");
appearOnScroll.unobserve(entry.target);
}
});
},
appearOptions);
faders.forEach(fader => {
appearOnScroll.observe(fader);
});
sliders.forEach(slider => {
appearOnScroll.observe(slider);
});
borderBottoms.forEach(borderBottom => {
appearOnScroll.observe(borderBottom);
});