-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
40 lines (32 loc) · 1001 Bytes
/
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
let navOpen = document.querySelector(".header")
let closBtn = document.querySelector(`[name="close-outline"]`)
let openBtn = document.querySelector(`[name="menu-outline"]`)
let navBtn = document.querySelectorAll(".main-nav-list li")
navBtn.forEach((e)=>{
e.onclick = function(){
navOpen.classList.remove("nav-open")
}
})
openBtn.addEventListener("click",(e)=>{
navOpen.classList.add("nav-open")
})
closBtn.addEventListener("click",(e)=>{
navOpen.classList.remove("nav-open")
})
// ///////////////////////////////////////
const sectionHero = document.querySelector(".section-hero")
const obs = new IntersectionObserver(function(entries){
const ent = entries[0]
console.log(ent)
if(ent.isIntersecting === false){
document.body.classList.add("sticky")
}else{
document.body.classList.remove("sticky")
}
},{
root: null,
threshold:0,
rootMargin:'-80px'
})
obs.observe(sectionHero)
let sticky = document.querySelector(".sticky")