-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
36 lines (30 loc) · 827 Bytes
/
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
var lastScrollTop = 0;
var firstSection = window.innerHeight;
var header = $("#navbar");
$(window).scroll(function (event) {
var currentScroll = $(this).scrollTop();
if (currentScroll < firstSection) {
header.removeClass("dark");
}
if (currentScroll > lastScrollTop) {
// Scrolling down
header.slideUp();
} else {
// Scrolling up
if (currentScroll > firstSection) {
header.slideDown(); // Show header
header.addClass("dark");
} else {
header.slideDown(); // Show header
}
}
lastScrollTop = currentScroll;
});
$("#hamburger").click(function () {
$(this).toggleClass("ham-open");
$(".ham-menu").toggleClass("menu-open");
$(window).scroll(function (event) {
$("#hamburger").removeClass("ham-open");
$(".ham-menu").removeClass("menu-open");
});
});