-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
95 lines (82 loc) · 2.9 KB
/
Copy pathscript.js
File metadata and controls
95 lines (82 loc) · 2.9 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Mobile Navigation Toggle
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
const navLinks = document.querySelectorAll('.nav-link');
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navMenu.classList.toggle('active');
});
// Close mobile menu when clicking on a nav link
navLinks.forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
});
});
// Smooth Scrolling
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
const offsetTop = target.offsetTop - 70;
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
});
});
// Combined scroll event handler for better performance
window.addEventListener('scroll', () => {
const navbar = document.querySelector('.navbar');
// Navbar background change on scroll
if (window.scrollY > 50) {
navbar.style.background = 'rgba(255, 255, 255, 0.95)';
navbar.style.backdropFilter = 'blur(10px)';
} else {
navbar.style.background = '#ffffff';
navbar.style.backdropFilter = 'none';
}
// Add active class to navigation based on scroll position
let current = '';
const sections = document.querySelectorAll('section');
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (window.pageYOffset >= (sectionTop - 100)) {
current = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href').slice(1) === current) {
link.classList.add('active');
}
});
});
// Scroll Reveal Animation
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
}
});
}, observerOptions);
// Observe skill cards
document.querySelectorAll('.skill-card').forEach((card, index) => {
card.style.transitionDelay = `${index * 0.1}s`;
observer.observe(card);
});
// Observe project cards
document.querySelectorAll('.project-card').forEach((card, index) => {
card.style.transitionDelay = `${index * 0.1}s`;
observer.observe(card);
});
// Console welcome message
console.log('%cWelcome to my Portfolio!', 'color: #4f46e5; font-size: 20px; font-weight: bold;');
console.log('%cInterested in the code? Check out the repository!', 'color: #06b6d4; font-size: 14px;');