-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
74 lines (73 loc) · 2.9 KB
/
main.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
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
let navBg = () => {
let flagNav = false;
let navBar = document.getElementsByClassName('navigation-bar')[0];
let sectionOne = $('.section-1');
$(window).scroll(() => {
let oTop = $('.section-1').offset().top - window.innerHeight;
if ($(window).scrollTop() >= oTop + 200) {
flagNav = true;
//Make background white
navBar.style.backgroundColor = 'whitesmoke';
document.getElementsByClassName('navbar-brand')[0].style.color = 'black';
let navLinks = document.getElementsByClassName('nav-link');
for (let i = 0; i < navLinks.length; i++) {
navLinks[i].style.color = 'black';
}
let navToggleLines = document.getElementsByClassName('lines');
for (let i = 0; i < navToggleLines.length; i++) {
navToggleLines[i].style.backgroundColor = 'black';
}
let navToggle = document.getElementsByClassName('navbar-toggler')[0];
navToggle.style.borderColor = 'black';
} else if ($(window).scrollTop() < oTop + 200) {
flagNav = false;
navBar.style.backgroundColor = 'transparent';
document.getElementsByClassName('navbar-brand')[0].style.color = 'white';
let navLinks = document.getElementsByClassName('nav-link');
for (let i = 0; i < navLinks.length; i++) {
navLinks[i].style.color = 'white';
}
let navToggleLines = document.getElementsByClassName('lines');
for (let i = 0; i < navToggleLines.length; i++) {
navToggleLines[i].style.backgroundColor = 'white';
}
let navToggle = document.getElementsByClassName('navbar-toggler')[0];
navToggle.style.borderColor = 'white';
}
});
navBar.addEventListener('mouseover', () => {
if (!flagNav) {
navBar.style.backgroundColor = 'whitesmoke';
document.getElementsByClassName('navbar-brand')[0].style.color = 'black';
let navLinks = document.getElementsByClassName('nav-link');
for (let i = 0; i < navLinks.length; i++) {
navLinks[i].style.color = 'black';
}
let navToggleLines = document.getElementsByClassName('lines');
for (let i = 0; i < navToggleLines.length; i++) {
navToggleLines[i].style.backgroundColor = 'black';
}
let navToggle = document.getElementsByClassName('navbar-toggler')[0];
navToggle.style.borderColor = 'black';
}
});
navBar.addEventListener('mouseout', () => {
if (!flagNav) {
navBar.style.backgroundColor = 'transparent';
document.getElementsByClassName('navbar-brand')[0].style.color = 'white';
let navLinks = document.getElementsByClassName('nav-link');
for (let i = 0; i < navLinks.length; i++) {
navLinks[i].style.color = 'white';
}
let navToggleLines = document.getElementsByClassName('lines');
for (let i = 0; i < navToggleLines.length; i++) {
navToggleLines[i].style.backgroundColor = 'white';
}
let navToggle = document.getElementsByClassName('navbar-toggler')[0];
navToggle.style.borderColor = 'white';
}
});
};
$(window).on('load', () => {
navBg();
});