blob: a7323f3f94785e8a7f5626a3c09f5a9855ce5a0c (
plain) (
blame)
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
|
function stickyTopNav() {
var nav = document.querySelector('.nav');
var header = document.querySelector('.header');
if (document.body.scrollTop > 194 || document.documentElement.scrollTop > 194) {
if (document.querySelector('.sticky') == null) {
nav.classList.toggle('sticky');
header.classList.toggle('sticky');
}
} else {
if (document.querySelector('.sticky') != null) {
nav.classList.toggle('sticky');
header.classList.toggle('sticky');
}
}
};
window.onscroll = function() {
stickyTopNav();
};
window.onload = function() {
stickyTopNav();
};
function actionToggle() {
var action = document.querySelector('.action');
action.classList.toggle('active')
}
/*// https://stackoverflow.com/questions/17534661/make-anchor-link-go-some-pixels-above-where-its-linked-to
// The function actually applying the offset
function offsetAnchor() {
if (location.hash.length !== 0) {
window.scrollTo(window.scrollX, window.scrollY - 69);
}
}
// Captures click events of all <a> elements with href starting with #
document.addEventListener('click', 'a[href^="#"]', function(event) {
// Click events are captured before hashchanges. Timeout
// causes offsetAnchor to be called after the page jump.
window.setTimeout(function() {
offsetAnchor();
}, 0);
});
// Set the offset when entering page with hash present in the url
window.setTimeout(offsetAnchor, 0);*/
|