-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
39 lines (34 loc) · 1.18 KB
/
script.js
File metadata and controls
39 lines (34 loc) · 1.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
// Mobile Menu Toggle
const menuToggle = document.getElementById('menu-toggle');
const navbar = document.getElementById('navbar');
menuToggle.addEventListener('click', () => {
navbar.style.display = navbar.style.display === 'flex' ? 'none' : 'flex';
});
// Smooth Scrolling
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
if (window.innerWidth <= 768) {
navbar.style.display = 'none';
}
});
});
// Form Validation
document.getElementById('contactForm').addEventListener('submit', function(e) {
e.preventDefault();
document.getElementById('formMessage').textContent = 'Message Sent Successfully!';
this.reset();
});
// Fade-in on Scroll
const fadeIns = document.querySelectorAll('.fade-in');
window.addEventListener('scroll', () => {
fadeIns.forEach(section => {
const sectionTop = section.getBoundingClientRect().top;
if (sectionTop < window.innerHeight - 100) {
section.classList.add('show');
}
});
});