-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom.js
More file actions
92 lines (75 loc) · 2.18 KB
/
custom.js
File metadata and controls
92 lines (75 loc) · 2.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
const tooltipTriggerList = document.querySelectorAll(
'[data-bs-toggle="tooltip"]',
);
const tooltipList = [...tooltipTriggerList].map(
(tooltipTriggerEl) =>
new bootstrap.Tooltip(tooltipTriggerEl, {
offset: [0, 15],
}),
);
let vantaEffect = VANTA.TOPOLOGY({
el: document.body,
mouseControls: false,
touchControls: false,
gyroControls: false,
minHeight: 200.0,
minWidth: 200.0,
scale: 1.0,
scaleMobile: 1.0,
backgroundColor: 0x212529,
color: 0x017FC0
});
function ensureVanta() {
if (!vantaEffect) {
vantaEffect = VANTA.TOPOLOGY({
el: document.body,
mouseControls: false,
touchControls: false,
gyroControls: false,
minHeight: 200.0,
minWidth: 200.0,
scale: 1.0,
scaleMobile: 1.0,
backgroundColor: 0x212529,
color: 0x017FC0
});
}
}
window.addEventListener('resize', () => {
if (vantaEffect) {
vantaEffect.destroy();
vantaEffect = null;
}
ensureVanta();
});
document.addEventListener('visibilitychange', () => {
if (!document.hidden) ensureVanta();
});
window.addEventListener('focus', ensureVanta);
const sectionOrder = ["home", "experience", "education", "projects", "skills"];
let currentSection = "home";
let isAnimating = false;
const navLinks = document.querySelectorAll("#main-nav .nav-link");
navLinks.forEach((link) => {
link.addEventListener("click", function () {
const target = this.getAttribute("data-section");
if (target === currentSection || isAnimating) return;
isAnimating = true;
navLinks.forEach((l) => l.classList.remove("active"));
this.classList.add("active");
const currentEl = document.getElementById(currentSection);
const targetEl = document.getElementById(target);
currentEl.classList.add("fade-out");
setTimeout(() => {
currentEl.classList.remove("active-section", "fade-out");
targetEl.classList.add("active-section", "fade-in");
setTimeout(() => {
targetEl.classList.remove("fade-in");
isAnimating = false;
}, 350);
currentSection = target;
}, 300);
});
});
document.querySelector("footer .text-body-secondary").textContent =
`© ${new Date().getFullYear()} Danny Pham`;