This repository has been archived by the owner on Sep 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
61 lines (55 loc) · 1.6 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const menuBtn = document.querySelector('.menu-toggler');
let menuOpen = false;
menuBtn.addEventListener('click', () => {
if(!menuOpen) {
menuBtn.classList.add('open');
menuOpen = true;
}
else {
menuBtn.classList.remove('open');
menuOpen = false;
}
});
const questionOneBtn = document.querySelector('.why-economica-header');
const questionTwoBtn = document.querySelector('.compare-economica-header');
const questionOneAnimation = document.querySelector('.why-economica-icon');
const questionTwoAnimation = document.querySelector('.compare-economica-icon');
let questionOpen = false;
questionOneBtn.addEventListener('click', () => {
if (!questionOpen) {
questionOneAnimation.classList.add('why-economica-icon-open');
questionOpen = true;
}
else {
questionOneAnimation.classList.remove('why-economica-icon-open');
questionOpen = false;
}
})
questionTwoBtn.addEventListener('click', () => {
if (!questionOpen) {
questionTwoAnimation.classList.add('compare-economica-icon-open');
questionOpen = true;
}
else {
questionTwoAnimation.classList.remove('compare-economica-icon-open');
questionOpen = false;
}
})
const faders = document.querySelectorAll('.fade-in');
const appearOptions = {
threshold: 0.1,
}
const appearOnScroll = new IntersectionObserver(function(entries,appearOnScroll) {
entries.forEach(entry => {
if (!entry.isIntersecting) {
return;
}
else {
entry.target.classList.add('appear');
appearOnScroll.unobserve(entry.target);
}
})
}, appearOptions);
faders.forEach(fader => {
appearOnScroll.observe(fader);
});