-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
69 lines (51 loc) · 1.25 KB
/
index.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
let showDead = document.getElementById('dead')
dead.onchange = function(e)
{
if(dead.checked)
{
document.body.classList.add('show_dead')
}
else
{
document.body.classList.remove("show_dead");
}
}
let tocToggle = document.getElementsByClassName('mobile-nav-bar')[0];
let nav = document.getElementsByTagName('nav')[0];
let main = document.getElementsByTagName('main')[0];
let htmlTag = document.getElementsByTagName('html')[0];
let oldScrollPosition = 0;
tocToggle.onclick = function()
{
if(nav.classList.contains("show"))
{
main.style.display = "block";
setTimeout(() => {
nav.classList.remove("show");
htmlTag.scrollTop = oldScrollPosition;
}, 0)
}
else {
oldScrollPosition = htmlTag.scrollTop;
console.log(oldScrollPosition);
htmlTag.scrollTop = 0;
nav.classList.add("show");
main.style.display = "none";
}
}
let links = document.getElementsByTagName('a')
for (let i =0; i< links.length; i++)
{
links[i].onclick = function(){
if(nav.classList.contains("show"))
{
main.style.display = "block";
setTimeout(() => {
//mainScroll.scrollTop = mainScroll.scrollTop + 60
htmlTag.scrollTop = htmlTag.scrollTop - 60;
oldScrollPosition = 0;
nav.classList.remove("show");
},10);
}
}
}