This repository has been archived by the owner on Sep 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
60 lines (54 loc) · 1.68 KB
/
index.html
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
54
55
56
57
58
59
60
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Main</title>
<link rel="stylesheet" href="src/assets/styles/index.css" />
<script src="elm.js"></script>
</head>
<body>
<script>
var app = Elm.Main.init();
// When the user scrolls the page, execute myFunction
window.onscroll = function () {
myFunction();
};
// Get the header
var header = document.getElementById("header");
// Get the offset position of the navbar
var landing = document.getElementById("landing-container");
if (landing !== null) {
var sticky = (85 / 100) * landing.getBoundingClientRect().height;
console.log(sticky);
// Add the sticky class to the header when you reach its scroll position. Remove "sticky" when you leave the scroll position
function myFunction() {
if (window.scrollY > sticky) {
header.classList.add("sticky");
document
.getElementById("landing-container")
.classList.add("landing-no-header");
} else {
header.classList.remove("sticky");
document
.getElementById("landing-container")
.classList.remove("landing-no-header");
}
}
}
// Scroll lol
document.getElementById("about-button").onclick = () => {
document.getElementById("about").scrollIntoView({
behavior: "smooth",
block: "end",
});
};
// Scroll lol
document.getElementById("home").onclick = () => {
window.scrollTo({
top: 0,
behavior: "smooth",
});
};
</script>
</body>
</html>