-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
91 lines (73 loc) · 2.89 KB
/
script.js
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
target.scrollIntoView({
behavior: 'smooth'
});
});
});
window.addEventListener('scroll', () => {
const navbar = document.querySelector('.navbar');
if (window.scrollY > 50) {
navbar.classList.add('navbar-scrolled');
} else {
navbar.classList.remove('navbar-scrolled');
}
});
const filterButtons = document.querySelectorAll('.filter-btn');
const projectItems = document.querySelectorAll('.project-item');
filterButtons.forEach(btn => {
btn.addEventListener('click', () => {
const filterValue = btn.getAttribute('data-filter');
filterButtons.forEach(button => button.classList.remove('active'));
btn.classList.add('active');
projectItems.forEach(item => {
if (filterValue === 'all' || item.getAttribute('data-category') === filterValue) {
item.style.display = 'block';
} else {
item.style.display = 'none';
}
});
});
});
const skillBars = document.querySelectorAll('.skill-progress');
const animateSkills = () => {
skillBars.forEach(skill => {
const percentage = skill.getAttribute('data-progress');
skill.style.width = percentage + '%';
});
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
animateSkills();
}
});
});
document.querySelectorAll('.skills-section').forEach(section => {
observer.observe(section);
});
const contactForm = document.querySelector('#contact-form');
if (contactForm) {
contactForm.addEventListener('submit', (e) => {
e.preventDefault();
const name = contactForm.querySelector('#name').value;
const email = contactForm.querySelector('#email').value;
const message = contactForm.querySelector('#message').value;
if (!name || !email || !message) {
alert('Please fill in all fields');
return;
}
console.log('Form submitted:', { name, email, message });
contactForm.reset();
});
}
window.addEventListener('load', () => {
const loader = document.querySelector('.loader');
if (loader) {
loader.style.display = 'none';
}
});
});