-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
27 lines (23 loc) · 876 Bytes
/
app.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
import { insertComponent, getElementById } from "./utils/common.js";
import router from "./js/router.js";
let contentDiv = getElementById("content");
window.animationStart = false;
// init router function and pass contentDiv element in which we want to append our pages. ================
router(contentDiv);
// scroll event to
document.addEventListener("scroll", function(e) {
let scrollTop = e.target.scrollingElement.scrollTop;
let scrollHeight = e.target.scrollingElement.scrollHeight;
let navbar = document.getElementsByTagName("nav")[0];
if (scrollHeight - window.innerHeight > scrollTop) {
if (scrollTop > 110) {
if (!navbar.classList.contains("nav-scroll")) {
navbar.classList.add("nav-scroll");
}
} else {
if (navbar.classList.contains("nav-scroll")) {
navbar.classList.remove("nav-scroll");
}
}
}
});