-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (34 loc) · 1.18 KB
/
Copy pathscript.js
File metadata and controls
45 lines (34 loc) · 1.18 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
// ================= NAVBAR TOGGLE =================
const hamburger = document.querySelector(".hamburger");
const navLinks = document.querySelector(".nav-links");
hamburger.addEventListener("click", () => {
navLinks.classList.toggle("active");
});
// ================= CLOSE MENU ON CLICK =================
document.querySelectorAll(".nav-links a").forEach(link => {
link.addEventListener("click", () => {
navLinks.classList.remove("active");
});
});
// ================= SMOOTH SCROLL =================
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener("click", function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute("href"));
target.scrollIntoView({
behavior: "smooth"
});
});
});
// ================= SIMPLE SCROLL ANIMATION =================
const cards = document.querySelectorAll(".project-card");
window.addEventListener("scroll", () => {
const trigger = window.innerHeight * 0.85;
cards.forEach(card => {
const top = card.getBoundingClientRect().top;
if (top < trigger) {
card.style.opacity = "1";
card.style.transform = "translateY(0)";
}
});
});