-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
53 lines (46 loc) · 1.37 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(function ($) {
("use strict");
$(".menu-toggle").click(function (e) {
e.preventDefault();
$("#sidebar-wrapper").toggleClass("active");
$(".menu-toggle > .fa-bars, .menu-toggle > .fa-times").toggleClass(
"fa-bars fa-times"
);
$(this).toggleClass("active");
});
$('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function () {
if (
location.pathname.replace(/^\//, "") ==
this.pathname.replace(/^\//, "") &&
location.hostname == this.hostname
) {
let target = $(this.hash);
target = target.length ? target : $("[name=" + this.hash.slice(1) + "]");
if (target.length) {
$("html, body").animate(
{
scrollTop: target.offset().top,
},
1000,
"easeInOutExpo"
);
return false;
}
}
});
$("#sidebar-wrapper .js-scroll-trigger").click(function () {
$("#sidebar-wrapper").removeClass("active");
$("menu-toggle").removeClass("active");
$(".menu-toggle > fa.bars, .menu-toggle > .fa-times").toggleClass(
"fa-bars fa-times"
);
});
$(document).scroll(function () {
let scrollDistance = $(this).scrollTop();
if (scrollDistance > 100) {
$(".scroll-to-top").fadeIn();
} else {
$(".scroll-to-top").fadeOut();
}
});
})(jQuery);