Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
48 lines (43 loc) · 1.5 KB
/
Copy pathscript.js
File metadata and controls
48 lines (43 loc) · 1.5 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
document.addEventListener('DOMContentLoaded', () => {
// Page entrance
requestAnimationFrame(() => document.body.classList.add('loaded'));
// Header animation
const header = document.querySelector('header');
if (header) header.classList.add('header-animate');
// Reveal-on-scroll for main sections
const revealEls = document.querySelectorAll('.aboutUs, .contactUs, .content h1');
const io = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
// once visible, unobserve
io.unobserve(entry.target);
}
});
}, { threshold: 0.12 });
revealEls.forEach(el => {
el.classList.add('reveal');
io.observe(el);
});
// Smooth scrolling for internal anchors
document.querySelectorAll('a[href^="#"]').forEach(a => {
a.addEventListener('click', (e) => {
const href = a.getAttribute('href');
if (href.length > 1) {
e.preventDefault();
const target = document.querySelector(href);
if (target) target.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
});
// Form submit visual feedback (non-blocking)
const form = document.getElementById('contact');
if (form) {
form.addEventListener('submit', () => {
form.classList.add('submitting');
setTimeout(() => form.classList.remove('submitting'), 1500);
// After a short timeout mark submitted for pleasant visual feedback (doesn't prevent real submission)
setTimeout(() => form.classList.add('submitted'), 1200);
});
}
});