blob: b5d3d976d4ca71a66a92ef68fe456ae5c7efe242 (
plain)
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
70
71
|
---
version: 5
---
var landingHeaderBar = document.getElementById('landing-header-bar');
var headerLinks = document.getElementsByClassName('header-link');
if (landingHeaderBar) {
window.addEventListener('scroll', function() {
if (window.scrollY >= 100) {
landingHeaderBar.classList.add('scrolling-header');
for (var i = 0; i < headerLinks.length; i++) {
headerLinks[i].classList.add('scrolling-header-links');
}
} else {
landingHeaderBar.classList.remove('scrolling-header');
for (var i = 0; i < headerLinks.length; i++) {
headerLinks[i].classList.remove('scrolling-header-links');
}
}
});
}
// move document nav to sidebar
(function() {
var timeofday = document.getElementById('timeofday');
var main = document.querySelector('.js-main-wrapper');
// Set timeofday var depending on the time //
if (timeofday) {
var date = new Date();
var hour = date.getHours();
if (hour < 11) {
timeofday.innerHTML = 'morning';
}
if (hour >= 11 && hour < 16) {
timeofday.innerHTML = 'afternoon';
}
if (hour >= 16) {
timeofday.innerHTML = 'evening';
}
}
document.addEventListener('DOMContentLoaded', function() {
var globalNav = document.getElementById('global-nav');
var media = window.matchMedia('(max-width: 1099px)');
window.addEventListener('scroll', function(e) {
var isTouchingBottom = false;
if (!media.matches) {
isTouchingBottom =
window.scrollY + window.innerHeight >=
document.querySelector('.footer').offsetTop;
}
if (isTouchingBottom) {
globalNav.style.top =
main.offsetHeight -
(window.scrollY + globalNav.offsetHeight) +
80 +
'px';
} else {
globalNav.style.top = '';
}
});
});
})();
|