-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (50 loc) · 1.64 KB
/
index.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
const btn = document.querySelector(".btn");
const btn_line = document.querySelector(".btn-line")
const body = document.querySelector('html body');
const nav_list = document.querySelector('.nav-list');
const onClick = () => {
const is_open = document.querySelector(".open");
if (!is_open) {
nav_list.style.right = 0;
} else {
nav_list.style.right = -150 + "px";
console.log(nav_list.style)
}
btn_line.classList.toggle("open")
}
btn.addEventListener("click", onClick);
document.querySelectorAll(".nav-list-item").forEach((item) => {
item.addEventListener("click", () => {
nav_list.style.right = -150 + "px";
btn_line.classList.remove("open")
})
})
const elements = document.querySelectorAll(".sc")
window.addEventListener('scroll', () => {
elements.forEach((ele) => {
const target_position = ele.getBoundingClientRect().top;
if (window.pageYOffset > ((target_position + window.pageYOffset) - window.innerHeight) + 100) {
ele.classList.add("show")
}
if (window.pageYOffset === 0) {
ele.classList.remove("show")
}
})
});
let current = 1
const slideshow = () => {
const header_images = document.querySelectorAll(".header-image");
if (current === 2) {
current = 0;
header_images[current].classList.add("active");
header_images[2].classList.remove("active");
} else {
current++;
header_images[current].classList.add("active");
header_images[current - 1].classList.remove("active");
}
}
window.addEventListener('load', () => {
slideshow();
setInterval(slideshow, 5000)
})