forked from vcellmike/sbgnbricks.github.io
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
46 lines (31 loc) · 1.26 KB
/
script.js
File metadata and controls
46 lines (31 loc) · 1.26 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
$(document).ready(function(){
$(".nav-link.active").css("background-color","green");
//$(".nav-pills.nav-link.active, .nav-pills.show>.nav-link").css("background-color","green")
$(window).scroll(function(){
if($(document).scrollTop()> 50){
$(".navbar").css("background-color","black");
$(".nav-link.active").css("background-color","white");
$(".nav-link").css("background-color","transparent")
}
else{
$(".navbar").css("background-color","transparent");
$(".nav-link.active").css("background-color","green");
}
})
})
// Add smooth scrolling on all links inside the navbar
$("#navbar-menu a").on('click',function(event){
if(this.hash!==""){
event.preventDefault();
var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html,body').animate({
scrollTop:$(hash).offset().top
},800,function(){
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash=hash;
});
}
}
);