-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
46 lines (37 loc) · 1.41 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
41
42
43
44
45
46
// Get the current year for the copyright
$('#year').text(new Date().getFullYear());
//Init Scrollspy
$('body').scrollspy({target: '#main-nav'});
//add smooth scrolling
$('#main-nav a').on('click', function(e) {
//check for a hash value
if(this.hash !== '') {
//prevent default behavior
e.preventDefault();
//store hash
const hash = this.hash;
//animate smooth scroll
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 900, function() {
//add hash to url after scroll
window.location.hash = hash;
});
}
});
$('#home-section a').on('click', function(e) {
//check for a hash value
if(this.hash !== '') {
//prevent default behavior
e.preventDefault();
//store hash
const hash = this.hash;
//animate smooth scroll
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 900, function() {
//add hash to url after scroll
window.location.hash = hash;
});
}
});