-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
38 lines (31 loc) · 1.03 KB
/
main.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
$(document).ready(function () {
$(window).scroll(function () {
// change the header styling when scrolled
if (this.scrollY > 20) {
$("header").addClass("header--scrolled");
}
else {
$("header").removeClass("header--scrolled");
}
if (this.scrollY > 500) {
$(".scroll__to__top").css("display", "block");
}
else {
$(".scroll__to__top").css({ 'display': 'none' });
}
});
// to show or hide the side nav bar
$(".header__bars").click(function () {
$(".header__right").toggleClass("nav--show");
$(".header__bars").toggleClass("close--btn");
});
// to close the side nav when clicked on the link
$(".header__nav__link").click(function () {
$(".header__right").removeClass("nav--show");
$(".header__bars").removeClass("close--btn");
});
// scroll to top button
$(".scroll__to__top").click(function () {
$('html').animate({ scrollTop: 0 });
});
});