-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
40 lines (35 loc) · 1.02 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
/**
*
scroll to top button
*/
const toTop = document.getElementById('to-top')
toTop.addEventListener('click', e => {
e.preventDefault();
window.scrollTo({
top: 0,
behavior: 'smooth'
})
});
/**
* Adding border on nav links depending on what section we're on.
*/
const home = document.getElementById('home');
const projects = document.getElementById('projects');
const skills = document.getElementById('skills');
const interests = document.getElementById('interests');
const resume = document.getElementById('resume')
const test = [
home, projects, skills, interests, resume
];
const sectionObserver = new IntersectionObserver(function (entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
document.getElementById(`a_${entry.target.id}`).classList.add("active");
} else {
document.getElementById(`a_${entry.target.id}`).classList.remove("active");
}
})
}, { threshold: 0.6 });
test.forEach(i => {
sectionObserver.observe(i);
});