-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
43 lines (36 loc) · 1.15 KB
/
script.js
File metadata and controls
43 lines (36 loc) · 1.15 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
const menuBtn = document.querySelector('.menu-btn');
const menuPage = document.querySelector('.cont-page');
let menuOpen = false;
if(menuBtn){
menuBtn.addEventListener('click', () => {
if(!menuOpen) {
menuBtn.classList.add('open2');
menuPage.classList.add('open2');
menuOpen = true;
}else{
menuBtn.classList.remove('open2');
menuPage.classList.remove('open2');
menuOpen = false;
}
});
}
var prevScrollpos = window.scrollY;
function hidenavbar() {
var currentScrollPos = window.scrollY;
if (prevScrollpos > currentScrollPos) {
document.getElementById("navbar").style.top = "0";
}else{
document.getElementById("navbar").style.top = "-120px";
}
prevScrollpos = currentScrollPos;
}
window.onscroll = function() {hidenavbar()};
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add('show');
}
});
});
const hiddenElements = document.querySelectorAll('.js-scroll');
hiddenElements.forEach((el) => observer.observe(el));