-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
46 lines (38 loc) · 1.4 KB
/
app.js
File metadata and controls
46 lines (38 loc) · 1.4 KB
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
const home_button = document.querySelector('.home')
home_button.addEventListener("click", () => {
scroll({top: 55, behavior: "smooth"})
});
const books_button = document.querySelector('.books')
books_button.addEventListener("click", () => {
scroll({top: 760, behavior: "smooth"})
});
const contact_button = document.querySelector('.contact3')
contact_button.addEventListener("click", () => {
scroll({top: 1400, behavior: "smooth"})
});
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add('show');
if (entry.target.id === "nowline") {
entry.target.classList.add('expand')
}
else if (entry.target.id === "slide_right") {
entry.target.classList.add('slide_right')
}
else if (entry.target.id === "slide_left") {
entry.target.classList.add('slide_left')
}
}
// else {
// entry.target.classList.remove('show');
// }
else {
entry.target.classList.remove('expand')
entry.target.classList.remove('slide_right')
entry.target.classList.remove('slide_left')
}
});
});
const hiddenElements = window.document.querySelectorAll('.hidden');
hiddenElements.forEach((el) => observer.observe(el));