-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.js
More file actions
31 lines (31 loc) · 1.01 KB
/
header.js
File metadata and controls
31 lines (31 loc) · 1.01 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
document.querySelector('header nav .hamburg span').onclick = function () {
document.querySelector('header nav ul').classList.toggle('show');
refresh();
}
function refresh () {
document.querySelector('header nav .hamburg span').innerHTML = document.querySelector('header nav ul').classList.contains('show') ? 'close' : 'menu';
}
window.onload = function () {
document.body.querySelector('main').onclick = hide;
document.body.querySelector('footer').onclick = hide;
}
function hide() {
document.querySelector('header nav ul').classList.remove('show');
refresh();
}
window.onscroll = scroll;
function scroll() {
hide();
if (window.scrollY != 0) {
document.querySelector('header nav').classList.add('scroll');
}
else {
document.querySelector('header nav').classList.remove('scroll');
}
if (window.scrollY >= 300) {
document.querySelector('.goup').classList.remove('hide');
}
else {
document.querySelector('.goup').classList.add('hide');
}
}