-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
24 lines (24 loc) · 925 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
/* ADD TO FAVORITE */
function add_to_fav(element){
if(element.classList.contains("faved")){
$(element).removeClass('faved');
$(element).addClass('not-fav');
}else{
$(element).removeClass('not-fav');
$(element).addClass('faved');
}
}
/* TOGGLE NAVBAR LINKS 'active' CLASS */
window.addEventListener('scroll', function() {
var check_points = document.getElementsByClassName('check-point');
var nav_links = document.getElementsByClassName('nav-link');
for(var i = 0; i < check_points.length; i++){
var position = check_points[i].getBoundingClientRect();
if(position.top < window.innerHeight - 200 && position.bottom >= 0) {
for(var a = 0; a < nav_links.length; a++){
nav_links[a].classList.remove("active");
}
nav_links[i].classList.add("active");
}
}
});