-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
79 lines (72 loc) · 3.06 KB
/
Copy pathscript.js
File metadata and controls
79 lines (72 loc) · 3.06 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
document.addEventListener("DOMContentLoaded", () => {
const toggle = document.querySelector(".nav-toggle");
const navLinks = document.querySelector(".nav-links");
toggle.addEventListener("click", () => navLinks.classList.toggle("open"));
navLinks.querySelectorAll("a").forEach(link =>
link.addEventListener("click", () => navLinks.classList.remove("open"))
);
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add("visible");
observer.unobserve(entry.target);
}
});
}, { threshold: 0.15 });
document.querySelectorAll("section, .project-card, .skill-card, .stat-card").forEach(el => {
el.classList.add("fade-in");
observer.observe(el);
});
const skillObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.querySelectorAll(".skill-fill").forEach(bar => {
bar.style.width = bar.dataset.width;
});
skillObserver.unobserve(entry.target);
}
});
}, { threshold: 0.3 });
document.querySelectorAll(".skills").forEach(s => skillObserver.observe(s));
const statObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.querySelectorAll(".stat-number").forEach(num => {
animateCount(num, parseInt(num.dataset.target));
});
statObserver.unobserve(entry.target);
}
});
}, { threshold: 0.3 });
document.querySelectorAll(".about-stats").forEach(s => statObserver.observe(s));
function animateCount(el, target) {
let current = 0;
const step = Math.max(1, Math.floor(target / 60));
const timer = setInterval(() => {
current += step;
if (current >= target) { current = target; clearInterval(timer); }
el.textContent = current.toLocaleString() + (target >= 100 ? "+" : "+");
}, 20);
}
document.querySelectorAll(".filter-btn").forEach(btn => {
btn.addEventListener("click", () => {
document.querySelectorAll(".filter-btn").forEach(b => b.classList.remove("active"));
btn.classList.add("active");
const filter = btn.dataset.filter;
document.querySelectorAll(".project-card").forEach(card => {
card.classList.toggle("hidden", filter !== "all" && card.dataset.category !== filter);
});
});
});
document.getElementById("contactForm").addEventListener("submit", e => {
e.preventDefault();
const btn = e.target.querySelector("button");
btn.textContent = "Sent!";
btn.style.background = "#34d399";
setTimeout(() => {
btn.textContent = "Send Message";
btn.style.background = "";
e.target.reset();
}, 2000);
});
});