-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
61 lines (56 loc) · 2.21 KB
/
scripts.js
File metadata and controls
61 lines (56 loc) · 2.21 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
// Scroll to section on nav link click
document.querySelectorAll('nav ul li a').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
document.getElementById(targetId).scrollIntoView({
behavior: 'smooth'
});
});
});
// Simple fade-in effect on sections
window.addEventListener('scroll', () => {
document.querySelectorAll('section').forEach(section => {
const rect = section.getBoundingClientRect();
if (rect.top <= window.innerHeight * 0.8 && rect.bottom >= 0) {
section.classList.add('visible');
}
});
});
// Mobile Menu Toggle
const mobileMenu = document.getElementById('mobile-menu');
const navList = document.querySelector('header nav ul');
mobileMenu.addEventListener('click', () => {
navList.classList.toggle('show');
});
// Fade-in effect for service and project items
window.addEventListener('scroll', () => {
document.querySelectorAll('.service-item, .project-item').forEach(item => {
const rect = item.getBoundingClientRect();
if (rect.top <= window.innerHeight * 0.9 && rect.bottom >= 0) {
item.classList.add('visible');
}
});
});
// Animate elements on page load
window.addEventListener('load', () => {
document.querySelector('#header').classList.add('animated');
document.querySelector('.logo a').classList.add('animated');
document.querySelectorAll('nav ul li').forEach((item, index) => {
item.style.animationDelay = `${index * 0.2}s`;
item.classList.add('animated');
});
document.querySelectorAll('.section').forEach((section, index) => {
section.style.animationDelay = `${index * 0.3}s`;
section.classList.add('animated');
});
document.querySelectorAll('.service-item').forEach((item, index) => {
item.style.animationDelay = `${index * 0.3}s`;
item.classList.add('animated');
});
document.querySelectorAll('.project-item').forEach((item, index) => {
item.style.animationDelay = `${index * 0.3}s`;
item.classList.add('animated');
});
document.querySelector('footer').classList.add('animated');
});