-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
62 lines (49 loc) · 1.6 KB
/
script.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const sections = document.querySelectorAll("section");
sections.forEach((section) => {
window.addEventListener("load", eventListener);
window.addEventListener("scroll", eventListener);
function eventListener() {
let windowHeight = window.innerHeight;
let sectionRectTop = section.getBoundingClientRect().top;
if (sectionRectTop < windowHeight) {
section.classList.add("active");
}
}
window.addEventListener("scroll", () => {
let reveals = section.querySelectorAll(".reveal");
reveals.forEach((reveal, index) => {
if (section.classList.contains("active")) {
const delay = 600;
setTimeout(() => {
reveal.classList.add("active");
}, index * delay);
}
});
});
window.addEventListener("scroll", () => {
reveals.forEach((reveal, index) => {
let windowHeight = window.innerHeight;
let revealRectTop = reveal.getBoundingClientRect().top;
let revealPoint = -250;
if (revealRectTop < windowHeight - revealPoint) {
const delay = 600;
setTimeout(() => {
reveal.classList.add("active");
}, index * delay);
}
});
});
window.addEventListener("load", () => {
let reveals = section.querySelectorAll(".reveal");
reveals.forEach((reveal, index) => {
let windowHeight = window.innerHeight;
let revealRectTop = reveal.getBoundingClientRect().top;
if (revealRectTop < windowHeight) {
const delay = 600;
setTimeout(() => {
reveal.classList.add("active");
}, index * delay);
}
});
});
});