-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
58 lines (51 loc) · 1.61 KB
/
Copy pathscript.js
File metadata and controls
58 lines (51 loc) · 1.61 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
function toggleMenu() {
const menu = document.querySelector(".mobile-nav-links");
const icon = document.querySelector(".mobile-nav-icon");
menu.classList.toggle("open");
icon.classList.toggle("open");
}
function initializeTyped(selector, delay, strings) {
return new Typed(selector, {
startDelay: delay,
strings: strings,
typeSpeed: 100,
loop: false,
preStringTyped: function(arrayPos, self) {
showCursor(selector);
},
onComplete: function(self) {
hideCursor(selector);
}
});
}
function showCursor(selector) {
const cursor = document.querySelector(selector + ' + .typed-cursor');
if (cursor) {
cursor.style.opacity = 1;
}
}
function hideCursor(selector) {
const cursor = document.querySelector(selector + ' + .typed-cursor');
if (cursor) {
cursor.style.display = 'none';
}
}
initializeTyped(".typing-name", 1500, ["Eric Fan"]);
initializeTyped(".typing-photographer", 3000, ["Photographer"]);
initializeTyped(".typing-swe", 4700, ["Software Engineer"]);
function expandPhoto(src) {
const overlay = document.getElementById("photo-overlay");
const expandedPhoto = document.getElementById("expanded-photo");
expandedPhoto.src = src;
overlay.style.display = "block";
}
function closeExpandedPhoto(event) {
if (event.target.id === "photo-overlay") {
document.getElementById("photo-overlay").style.display = "none";
}
}
document.querySelectorAll(".photo").forEach(photo => {
photo.addEventListener("click", function() {
expandPhoto(this.src);
});
});