-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
44 lines (38 loc) · 1.13 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
$(document).ready(function () {
console.log("Helloe");
$("a[href*=#]").bind("click", function (e) {
e.preventDefault(); // prevent hard jump, the default behavior
var target = $(this).attr("href"); // Set the target as variable
// perform animated scrolling by getting top-position of target-element and set it as scroll target
$("html, body")
.stop()
.animate(
{
scrollTop: $(target).offset().top,
},
600,
function () {
location.hash = target; //attach the hash (#jumptarget) to the pageurl
}
);
return false;
});
});
$(window)
.scroll(function () {
var scrollDistance = $(window).scrollTop();
// Show/hide menu on scroll
//if (scrollDistance >= 850) {
// $('nav').fadeIn("fast");
//} else {
// $('nav').fadeOut("fast");
//}
// Assign active class to nav links while scolling
$(".sections").each(function (i) {
if ($(this).position().top <= scrollDistance) {
$(".side-nav a.active").removeClass("active");
$(".side-nav a").eq(i).addClass("active");
}
});
})
.scroll();