Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
63 lines (51 loc) · 1.69 KB
/
Copy pathscript.js
File metadata and controls
63 lines (51 loc) · 1.69 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
// Make the ball move to a certain position:
/*
const f = document.getElementById("ball");
document.addEventListener("click", (ev) => {
f.style.transform = `translateY(${ev.clientY - 25}px)`;
f.style.transform += `translateX(${ev.clientX - 25}px)`;
});
*/
// Get references to elements
const soft = document.getElementById("software-btn");
const elec = document.getElementById("electronics-btn");
const mech = document.getElementById("mechanical-btn");
const soft_tab = document.getElementById("software");
const elec_tab = document.getElementById("electronics");
const mech_tab = document.getElementById("mechanical");
//if project_types gets too big,
//loop over all for click event,
//then project_types[i] += "active"
//then loop over again
//then if (p_t[i] != p_t[j]) p_t[j] -= "active"
// Function for showing a tab
function showTab(nav, tab) {
soft.classList.remove("active");
elec.classList.remove("active");
mech.classList.remove("active");
soft_tab.classList.remove("vis");
elec_tab.classList.remove("vis");
mech_tab.classList.remove("vis");
nav.classList.add("active");
tab.classList.add("vis");
}
// Default project type open
showTab(soft, soft_tab);
soft.addEventListener("click", () => {
showTab(soft, soft_tab);
});
elec.addEventListener("click", () => {
showTab(elec, elec_tab);
});
mech.addEventListener("click", () => {
showTab(mech, mech_tab);
});
// Scroll event listener to add/remove topnav border radius based on scroll position
const topnav = document.querySelector('.topnav');
window.addEventListener('scroll', () => {
if (window.scrollY > 12.5) {
topnav.classList.add('scrolled');
} else {
topnav.classList.remove('scrolled');
}
});