-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (33 loc) · 1.06 KB
/
index.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
/* Open */
function openNav() {
document.getElementById("navbar").style.width = "100%";
}
/* Close */
function closeNav() {
document.getElementById("navbar").style.width = "0%";
}
const sections = document.querySelectorAll("section");
const menuIcon = document.querySelector("#openMenu");
// listen for scroll events
window.addEventListener('scroll', () => {
// get the current scroll position
const scrollPos = window.scrollY;
// loop through each section and see if it's in view
sections.forEach(section => {
if (section.offsetTop <= scrollPos && (section.offsetTop + section.offsetHeight) > scrollPos) {
// the section is in view, so change the color of the menu icon
menuIcon.style.color = section.dataset.color;
}
});
});
window.onbeforeunload = () => {
for (const form of document.getElementsByTagName('form')) {
form.reset();
}
}
window.onload = function () {
var el = document.getElementById('g-recaptcha-response');
if (el) {
el.setAttribute('required', 'required');
}
}