-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (27 loc) · 906 Bytes
/
script.js
File metadata and controls
28 lines (27 loc) · 906 Bytes
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
// Reveal sections on scroll animation
function revealOnScroll() {
const reveals = document.querySelectorAll('.reveal');
const windowHeight = window.innerHeight;
reveals.forEach(section => {
const sectionTop = section.getBoundingClientRect().top;
if (sectionTop < windowHeight - 80) {
section.classList.add('visible');
}
});
}
window.addEventListener('scroll', revealOnScroll);
window.addEventListener('DOMContentLoaded', revealOnScroll);
// Optional: Smooth scroll for anchor links (for older browsers)
document.querySelectorAll('a[href^="#"]').forEach(link => {
link.addEventListener('click', function(e) {
const targetId = this.getAttribute('href').slice(1);
const target = document.getElementById(targetId);
if (target) {
e.preventDefault();
window.scrollTo({
top: target.offsetTop - 62,
behavior: 'smooth'
});
}
});
});