-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (30 loc) · 1.16 KB
/
script.js
File metadata and controls
36 lines (30 loc) · 1.16 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
const nav = document.getElementById("nav");
const homeBtn = document.getElementById("homeBtn");
const projects = document.querySelectorAll(".project");
window.addEventListener("scroll", () => {
nav.classList.toggle("visible", window.scrollY > window.innerHeight * 0.6);
projects.forEach(p => {
if (p.getBoundingClientRect().top < window.innerHeight * 0.8) {
p.classList.add("visible");
}
});
});
homeBtn.addEventListener("click", () => {
window.scrollTo({
top: 0,
behavior: "smooth"
});
});
document.querySelectorAll(".album").forEach(album => {
const track = album.querySelector(".album-track");
const images = track.children.length;
let index = 0;
album.querySelector(".next").onclick = () => {
index = (index + 1) % images;
track.style.transform = `translateX(-${index * 100}%)`;
};
album.querySelector(".prev").onclick = () => {
index = (index - 1 + images) % images;
track.style.transform = `translateX(-${index * 100}%)`;
};
});