-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
46 lines (44 loc) · 1.47 KB
/
script.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
//Smooth Scrolling
const btnScrollTo = document.querySelectorAll('.btn-scroll-to');
const btnExplore = document.querySelectorAll('.btn-explore');
const ctaSection = document.querySelector('#cta');
const featureSection = document.querySelector('#feature');
const btnSubmit = document.querySelector('.btn-submit');
const inputName = document.querySelector('#name');
const inputEmail = document.querySelector('#email');
const inputTelephone = document.querySelector('#telephone');
const inputAmount = document.querySelector('#amount');
btnScrollTo.forEach((e) => {
e.addEventListener('click', function () {
ctaSection.scrollIntoView({ behavior: 'smooth' });
});
});
btnExplore.forEach((e) => {
e.addEventListener('click', function () {
featureSection.scrollIntoView({ behavior: 'smooth' });
});
});
btnSubmit.addEventListener('click', function () {
inputName.value =
inputEmail.value =
inputTelephone.value =
inputAmount.value =
'';
});
// Reveal Section
const allSections = document.querySelectorAll('.sections');
const revealSection = function (entires, observer) {
const [entry] = entires;
console.log(entry);
if (!entry.isIntersecting) return;
entry.target.classList.remove('section-hidden');
observer.unobserve(entry.target);
};
const sectionObserver = new IntersectionObserver(revealSection, {
root: null,
threshold: 0.15,
});
allSections.forEach(function (section) {
sectionObserver.observe(section);
section.classList.add('section-hidden');
});