-
Notifications
You must be signed in to change notification settings - Fork 1
/
menuscroll.js
32 lines (30 loc) · 1.02 KB
/
menuscroll.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
function scrollToPart1() {
var menuHeight = document.querySelector(".menuBar").offsetHeight;
var location = document.querySelector(".menuBar").offsetTop;
window.scrollTo({ top: location - menuHeight, behavior: "smooth" });
}
function scrollToPart2() {
var menuHeight = document.querySelector(".menuBar").offsetHeight;
var location = document.querySelector(".part-2 .part-title").offsetTop;
window.scrollTo({ top: location - menuHeight + 100, behavior: "smooth" });
}
function scrollToPart3() {
var menuHeight = document.querySelector(".menuBar").offsetHeight;
var location = document.querySelector(".projects .part-title").offsetTop;
window.scrollTo({ top: location - menuHeight + 100, behavior: "smooth" });
}
window.addEventListener("load", function () {
if (window.location.hash) {
switch (window.location.hash) {
case "#home":
scrollToPart1();
break;
case "#members":
scrollToPart2();
break;
case "#projects":
scrollToPart3();
break;
}
}
});