-
Notifications
You must be signed in to change notification settings - Fork 0
/
functionality.js
35 lines (28 loc) · 913 Bytes
/
functionality.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
window.addEventListener('load', function()
{
var navBar = document.getElementById('top-nav'),
navOffset = navBar.offsetTop;
window.onscroll = function() { stickyNav() };
window.dispatchEvent(new CustomEvent('scroll'))
function stickyNav() {
if (window.pageYOffset >= navOffset)
{ navBar.classList.add('sticky'); }
else
{ navBar.classList.remove('sticky'); }
}
var menu = document.getElementById('menu'),
menuToggle = document.getElementById('menu-toggle')
menuToggle.addEventListener('click', function()
{
if (menu.classList.contains('is-active'))
{
menu.classList.remove('is-active');
this.setAttribute('aria-expanded', 'false');
}
else
{
menu.classList.add('is-active');
this.setAttribute('aria-expanded', 'true');
}
});
});