blob: 64a0ea58a0d7c7578c2854d15f97b4260b8247f9 (
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
|
(function() {
var $ = document.querySelector.bind(document),
$$ = document.querySelectorAll.bind(document),
menuActive = false
// Nav is fixed to top
$('nav').classList.add('nav-fixed')
$$('nav > .logo, nav > .nav-toggle').forEach(function(el) {
el.style.visibility = 'visible'
el.classList.add('show')
el.classList.remove('hide')
})
// Full screen nav open on click
$('.nav-icon').addEventListener('click', function() {
$$('.nav-full, main').forEach(function(el) {
el.classList.toggle('active')
})
if (menuActive) {
this.querySelector('img:nth-of-type(1)').style.display = 'block'
this.querySelector('img:nth-of-type(2)').style.display = 'none'
menuActive = false
} else {
this.querySelector('img:nth-of-type(1)').style.display = 'none'
this.querySelector('img:nth-of-type(2)').style.display = 'block'
menuActive = true
}
})
// Full screen nav close on click
$$('.nav-full a').forEach(function(links) {
links.addEventListener('click', function() {
$$('.nav-full, main').forEach(function(el) {
el.classList.toggle('active')
})
})
})
// Fix logoBig drawing over nav when click on logoSmall while nav open
$('.logo').addEventListener('click', function() {
if ($('.nav-full').classList.contains('active')) {
$$('.nav-full, main').forEach(function(el) {
el.classList.toggle('active')
})
}
})
// Disable scroll when full screen nav is open
$('body').addEventListener('click', function() {
if ($('.nav-full').classList.contains('active')) {
$('html').style.overflowY = 'hidden'
} else {
$('html').style.overflowY = 'scroll'
}
})
})()
|