-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
237 lines (205 loc) · 7.43 KB
/
script.js
File metadata and controls
237 lines (205 loc) · 7.43 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// Navbar scroll effect
window.addEventListener('scroll', () => {
const navbar = document.querySelector('.navbar');
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Active nav link on scroll
const sections = document.querySelectorAll('section[id]');
const navLinks = document.querySelectorAll('.nav-link');
function highlightNav() {
let current = '';
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') === `#${current}`) {
link.classList.add('active');
}
});
}
window.addEventListener('scroll', highlightNav);
// Mobile menu toggle
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
hamburger.addEventListener('click', () => {
navMenu.classList.toggle('active');
// Animate hamburger icon
const spans = hamburger.querySelectorAll('span');
if (navMenu.classList.contains('active')) {
spans[0].style.transform = 'rotate(45deg) translate(8px, 8px)';
spans[1].style.opacity = '0';
spans[2].style.transform = 'rotate(-45deg) translate(8px, -8px)';
} else {
spans[0].style.transform = '';
spans[1].style.opacity = '1';
spans[2].style.transform = '';
}
});
// Close mobile menu when clicking on nav link
navLinks.forEach(link => {
link.addEventListener('click', () => {
navMenu.classList.remove('active');
const spans = hamburger.querySelectorAll('span');
spans[0].style.transform = '';
spans[1].style.opacity = '1';
spans[2].style.transform = '';
});
});
// Smooth scroll for anchor 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',
block: 'start'
});
}
});
});
// Intersection Observer for fade-in animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Animate sections on scroll
document.querySelectorAll('.about-content, .music-card, .gallery-item, .contact-content').forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(30px)';
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(el);
});
// Music card play button interaction
const musicCards = document.querySelectorAll('.music-card');
musicCards.forEach(card => {
card.addEventListener('click', function() {
const title = this.querySelector('.music-title').textContent;
alert(`Playing: ${title}\n\nNote: Connect your music streaming service or audio files here!`);
});
});
// Gallery lightbox effect (simple version)
const galleryItems = document.querySelectorAll('.gallery-item');
galleryItems.forEach(item => {
item.addEventListener('click', function() {
const img = this.querySelector('img');
const overlay = document.createElement('div');
overlay.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.95);
z-index: 10000;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
`;
const enlargedImg = document.createElement('img');
enlargedImg.src = img.src;
enlargedImg.style.cssText = `
max-width: 90%;
max-height: 90%;
border-radius: 10px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
`;
overlay.appendChild(enlargedImg);
document.body.appendChild(overlay);
overlay.addEventListener('click', () => {
overlay.remove();
});
});
});
// Contact form handling
const contactForm = document.querySelector('.contact-form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const subject = document.getElementById('subject').value;
const message = document.getElementById('message').value;
// Simple validation
if (name && email && subject && message) {
alert(`Thank you, ${name}!\n\nYour message has been received. We'll get back to you soon at ${email}.\n\nNote: Connect this form to a backend service or email API for real functionality.`);
contactForm.reset();
} else {
alert('Please fill in all fields.');
}
});
}
// Add parallax effect to hero section (reduced movement to prevent overlap)
window.addEventListener('scroll', () => {
const hero = document.querySelector('.hero');
const scrolled = window.pageYOffset;
if (hero && scrolled < window.innerHeight) {
hero.style.transform = `translateY(${scrolled * 0.3}px)`;
hero.style.opacity = 1 - (scrolled / window.innerHeight) * 0.5;
}
});
// Animate statistics counter
const stats = document.querySelectorAll('.stat-number');
let hasAnimated = false;
const animateStats = () => {
if (hasAnimated) return;
const aboutSection = document.querySelector('.about');
const aboutPosition = aboutSection.getBoundingClientRect().top;
const screenPosition = window.innerHeight;
if (aboutPosition < screenPosition) {
stats.forEach(stat => {
const target = parseInt(stat.textContent);
let current = 0;
const increment = target / 50;
const updateCounter = () => {
if (current < target) {
current += increment;
stat.textContent = Math.floor(current) + '+';
requestAnimationFrame(updateCounter);
} else {
stat.textContent = target + '+';
}
};
updateCounter();
});
hasAnimated = true;
}
};
window.addEventListener('scroll', animateStats);
// Preload images (optional - for better performance)
window.addEventListener('load', () => {
const images = document.querySelectorAll('img');
images.forEach(img => {
if (img.complete) {
img.classList.add('loaded');
} else {
img.addEventListener('load', () => {
img.classList.add('loaded');
});
}
});
});
// Add loading state
window.addEventListener('load', () => {
document.body.classList.add('loaded');
});
console.log('Menad Harkat Website Loaded Successfully! 🎵');
console.log('Website designed for Algerian singer Menad Harkat');