-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (60 loc) · 2.18 KB
/
script.js
File metadata and controls
67 lines (60 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
// Toggle menu for mobile
function toggleMenu() {
const nav = document.querySelector("nav ul");
nav.classList.toggle("open");
}
// Add event listener for hamburger icon
document.addEventListener("DOMContentLoaded", () => {
const hamburger = document.getElementById("hamburger");
if (hamburger) {
hamburger.addEventListener("click", toggleMenu);
}
// Smooth scroll for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener("click", function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute("href"));
if (target) {
target.scrollIntoView({ behavior: "smooth" });
}
});
});
// Simple form validation
const form = document.querySelector("form");
if (form) {
form.addEventListener("submit", function (e) {
const name = document.getElementById("name");
const email = document.getElementById("email");
const message = document.getElementById("message");
if (!name.value || !email.value || !message.value) {
e.preventDefault();
alert("Please fill out all fields.");
}
});
}
// Optional: Lightbox placeholder functionality
const projectImages = document.querySelectorAll("#projects img");
projectImages.forEach(img => {
img.style.cursor = "pointer";
img.addEventListener("click", () => {
const modal = document.createElement("div");
modal.style.position = "fixed";
modal.style.top = 0;
modal.style.left = 0;
modal.style.width = "100vw";
modal.style.height = "100vh";
modal.style.background = "rgba(0, 0, 0, 0.8)";
modal.style.display = "flex";
modal.style.alignItems = "center";
modal.style.justifyContent = "center";
modal.style.zIndex = "1000";
const enlarged = document.createElement("img");
enlarged.src = img.src;
enlarged.style.maxWidth = "80%";
enlarged.style.maxHeight = "80%";
modal.appendChild(enlarged);
modal.addEventListener("click", () => document.body.removeChild(modal));
document.body.appendChild(modal);
});
});
});