-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
81 lines (68 loc) · 2.21 KB
/
app.js
File metadata and controls
81 lines (68 loc) · 2.21 KB
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
72
73
74
75
76
77
78
79
80
81
console.log("top of page")
console.log("load external html");
//$(document).ready(function(){
// $("#footer-placeholder").load("assets/footer.html");
// console.log("nav load");
//});
//$(document).ready(function(){
// $("#nav-placeholder").load("assets/nav.html");
// console.log("nav load");
//});
function disableScroll() {
console.log("disable scroll");
document.body.style.overflow = 'hidden';
document.querySelector('html').scrollTop = window.scrollY;
}
function enableScroll() {
console.log("enable scroll");
document.body.style.overflow = null;
}
//$('#nav-placeholder').load('assets/nav.html', function() {
const ham = document.getElementById('ham');
var nlinks = document.getElementById('nlinks');
var navstate = true;
var firstclick = true;
console.log("ham = "+ham);
ham.addEventListener('click', () => {
console.log("ham EL");
if (firstclick) {
nlinks.classList.add('nav-on');
firstclick = false
ham.classList.toggle('burg-on')
disableScroll();
} else{
if (navstate == false) {
//nav-on
nlinks.classList.add('nav-on');
nlinks.classList.remove('nav-off');
disableScroll();
navstate = true;
ham.classList.toggle('burg-on');
ham.classList.toggle('burg-off');
} else{
//nav-off
nlinks.classList.remove('nav-on');
nlinks.classList.add('nav-off');
enableScroll();
navstate = false;
ham.classList.toggle('burg-off');
ham.classList.toggle('burg-on');
}
}
});
var width = 0;
$(window).resize(function() {
width = $(window).width();
$("#status").text(width);
console.log(width);
if (width>900 && navstate && !(firstclick)){
nlinks.classList.remove('nav-on');
nlinks.classList.add('nav-off');
enableScroll();
navstate = false;
ham.classList.toggle('burg-off');
ham.classList.toggle('burg-on');
}
});
console.log("end of page")
//});