-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
28 lines (24 loc) · 813 Bytes
/
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
// Inside your script.js file
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// progress
// Add the class to elements when they come into view
function addFadeInClass() {
var elements = document.querySelectorAll('.bar .level');
elements.forEach(function (elem) {
if (!elem.classList.contains('fade-in-element')) {
var rect = elem.getBoundingClientRect();
if (rect.top < window.innerHeight) {
elem.classList.add('fade-in-element');
}
}
});
}
// Capture scroll events
window.addEventListener('scroll', addFadeInClass);