-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
52 lines (44 loc) · 1.54 KB
/
index.js
File metadata and controls
52 lines (44 loc) · 1.54 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
let isModalOpen = false;
let isContrastOn = false;
const scaleFactor = 1 / 28;
const yearElement = document.getElementById("year");
if (yearElement) {
yearElement.textContent = new Date().getFullYear();
}
function moveBackground(event) {
const shapes = document.querySelectorAll(".shape");
const x = event.clientX * scaleFactor;
const y = event.clientY * scaleFactor;
shapes.forEach((shape, index) => {
const direction = index % 2 === 0 ? 1 : -1;
shape.style.transform = `translate(${x * direction}px, ${y * direction}px)`;
});
}
function toggleContrast() {
isContrastOn = !isContrastOn;
document.body.classList.toggle("dark-theme", isContrastOn);
}
function contact(event) {
event.preventDefault();
const loading = document.querySelector(".modal__overlay--loading");
const success = document.querySelector(".modal__overlay--success");
loading.classList.add("modal__overlay--visible");
emailjs
.sendForm("service_mgbw47z", "template_cu21ivk", event.target, "i4Ysn7FwxaL2UqEMV")
.then(() => {
loading.classList.remove("modal__overlay--visible");
success.classList.add("modal__overlay--visible");
event.target.reset();
})
.catch(() => {
loading.classList.remove("modal__overlay--visible");
alert("The email service is temporarily unavailable. Please contact me directly on LinkedIn.");
});
}
function toggleModal() {
isModalOpen = !isModalOpen;
document.body.classList.toggle("modal--open", isModalOpen);
}
function scrollToTop() {
window.scrollTo({ top: 0, behavior: "smooth" });
}