-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
46 lines (34 loc) · 1.18 KB
/
script.js
File metadata and controls
46 lines (34 loc) · 1.18 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
44
45
46
const btnMenu = document.querySelector('.btn-mobile-nav');
const btnFullHero = document.querySelector('.btn--full');
const btnEmptyHero = document.querySelector('.btn--outline');
const mainNav = document.querySelector('.main-nav');
const secHero = document.querySelector('.section-hero')
const cta = document.querySelector('.section-cta');
const steps = document.querySelector('.section-how');
const nav = document.querySelector('.header-nav');
//Setting the current year for copyright
const copyYear = document.querySelector('.year');
const year = new Date().getFullYear();
copyYear.textContent = year;
//Add functionality to the mobile navigation
btnMenu.addEventListener('click', function(e) {
e.preventDefault();
nav.classList.toggle('nav-open');
})
//Smooth Scrolling Animation
//Implementing sticky navigation
const addSticky = function(entries) {
const [entry] = entries;
console.log(entry);
if (entry.isIntersecting) {
nav.classList.remove('sticky');
}
else if (!entry.isIntersecting) {
nav.classList.add('sticky');
}
}
const observer = new IntersectionObserver(addSticky, {
root: null,
threshold: 0.3,
})
observer.observe(secHero);