-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
96 lines (86 loc) · 3.52 KB
/
script.js
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
93
94
95
96
document.addEventListener("DOMContentLoaded", (e) => {
const menuLinks = document.querySelectorAll(".menu a");
menuLinks.forEach((link) => {
link.addEventListener("click", function (e) {
e.preventDefault();
const targetId = this.getAttribute("href");
document.querySelector(targetId).scrollIntoView({
behavior: "smooth",
});
});
});
const nextButton = document.querySelector(".next-button");
const backgroundInfo = document.getElementById("background");
const skillsInfo = document.getElementById("skills-info");
nextButton.addEventListener("click", function () {
if (backgroundInfo.style.display === "none") {
backgroundInfo.style.display = "block";
skillsInfo.style.display = "none";
document.querySelector('.background-box').classList.add('active');
document.querySelector('.skills-box').classList.remove('active');
skillsInfo.style.opacity = 0;
setTimeout(() => {
backgroundInfo.style.opacity = 1;
},0);
} else {
skillsInfo.style.display = "block";
backgroundInfo.style.display = "none";
document.querySelector('.background-box').classList.remove('active');
document.querySelector('.skills-box').classList.add('active');
backgroundInfo.style.opacity = 0;
setTimeout(() => {
skillsInfo.style.opacity = 1;
},0);
}
});
const thumbnails = document.querySelectorAll(".project-thumbnail");
const projectDefault = document.querySelector(".project-detail-default");
const projects = document.querySelectorAll(".project-detail");
thumbnails.forEach((thumbnail) => {
thumbnail.addEventListener("click", function (e) {
e.preventDefault(); // Stop the default anchor behavior
e.stopPropagation(); // Stop the click event from bubbling up or down
// Hide all project details
projects.forEach((project) => {
project.style.display = "none";
project.style.opacity = 0;
});
// Hide the default project detail view
projectDefault.style.display = "none";
// Get the id of the project detail to show
const targetId = this.getAttribute("data-target");
const targetProject = document.getElementById(targetId);
// Show the targeted project detail
setTimeout(() => {
targetProject.style.display = "flex"; // Use 'flex' if that's the desired display type
void targetProject.offsetWidth; // Trigger a reflow
targetProject.style.opacity = 1; // Fade in the project detail
document.querySelector("#projects").scrollIntoView({
behavior: "smooth",
});
}, 0);
});
});
const contactExpand = document.getElementById("contact-expand");
const contactContainer = document.getElementById("contact");
contactExpand.style.display = "none";
// Show the contact container when the user clicks on the toggle
contactExpand.addEventListener("click", function () {
contactContainer.style.right = "-20px";
contactExpand.style.display = "none";
});
// Hide the contact container when the user clicks on it
contactContainer.addEventListener("click", function (e) {
setTimeout(() => {
contactExpand.style.display = "block";
}, 280);
contactContainer.style.right = "-250px";
contactExpand.querySelector("img").src = "./images/contact-bar-expand.png";
});
document.querySelector(".btn").addEventListener("click", function (e) {
e.preventDefault();
document.querySelector("#projects").scrollIntoView({
behavior: "smooth",
});
});
});