forked from J4502-SS18/Push-Mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
44 lines (39 loc) · 1.13 KB
/
script.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
36
37
38
39
40
41
42
43
44
window.onscroll = function() {sticky_nav()};
nav = document.querySelector('#navigation');
navTop = nav.offsetTop;
sidenav = document.querySelector('.nav');
text = document.querySelector('#text');
homepageimg = document.querySelector('.homepageimg');
function sticky_nav() {
if (window.pageYOffset >= navTop) {
document.body.style.paddingTop = nav.offsetHeight + 'px';
nav.classList.add("sticky");
if (window.innerWidth >= 1250) {
nav.style.width = "80%";
}
}
else {
document.body.style.paddingTop = 0;
nav.classList.remove("sticky");
if (window.innerWidth >= 1250) {
nav.style.width = "100%";
}
}
}
function myFunction(x) {
if (x.matches) {
text.style.marginLeft = "200px";
homepageimg.style.marginLeft = "200px";
sidenav.classList.add("sidenav");
sidenav.classList.remove("nav");
}
else {
text.style.marginLeft = "0";
homepageimg.style.marginLeft = "0";
sidenav.classList.remove("sidenav");
sidenav.classList.add("nav");
}
}
var x = window.matchMedia("(min-width: 800px)");
myFunction(x);
x.addListener(myFunction);