-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared.js
More file actions
93 lines (76 loc) · 2.64 KB
/
Copy pathshared.js
File metadata and controls
93 lines (76 loc) · 2.64 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var backdrop = document.querySelector('.backdrop');
var modal = document.querySelector('.modal');
var modalNoButton = document.querySelector('.modal__action--negative');
var selectPlanButtons = document.querySelectorAll('.plan button');
var toggleButton = document.querySelector('.toggle-button');
var mobileNav = document.querySelector('.mobile-nav');
var ctaButton = document.querySelector('.main-nav__item--cta');
var selectPlanButtons = document.querySelectorAll('.plan button');
for (var i = 0; i < selectPlanButtons.length; i++) {
selectPlanButtons[i].addEventListener('click', function () {
modal.classList.add('open-modal');
backdrop.style.display = 'block';
setTimeout(function () {
backdrop.classList.add('open');
}, 20);
});
}
if (modalNoButton) {
modalNoButton.addEventListener('click', closeModal);
}
function closeModal() {
if (modal) {
modal.classList.remove('open-modal');
}
backdrop.style.display = 'none';
setTimeout(function () {
backdrop.classList.remove('open');
}, 10);
}
function revealUpwards() {
var reveals = document.querySelectorAll('.reveal-upwards');
for (var i = 0; i < reveals.length; i++) {
var windowHeight = window.innerHeight;
var elementTop = reveals[i].getBoundingClientRect().top;
var elementVisible = 150;
if (elementTop < windowHeight - elementVisible) {
reveals[i].classList.add('active');
} else {
reveals[i].classList.remove('active');
}
}
}
function revealSideways() {
const reveals = document.querySelectorAll('.reveal-sideways');
for (var i = 0; i < reveals.length; i++) {
const windowHeight = window.innerHeight;
const elementTop = reveals[i].getBoundingClientRect().top;
const elementVisible = 150;
if (elementTop < windowHeight - elementVisible) {
reveals[i].classList.add('active');
} else {
reveals[i].classList.remove('active');
}
}
}
function openNavigation() {
document.getElementById('mySidebar').style.width = '260px';
document.querySelector('main').style.marginLeft = '260px';
}
function closeNavigation() {
document.getElementById('mySidebar').style.width = '0px';
document.querySelector('main').style.marginLeft = '0px';
}
window.addEventListener('DOMContentLoaded', revealUpwards);
window.addEventListener('scroll', revealUpwards);
window.addEventListener('scroll', revealSideways);
if (backdrop) {
backdrop.addEventListener('click', function () {
closeModal();
});
}
if (ctaButton) {
ctaButton.addEventListener('animationstart', function () {});
ctaButton.addEventListener('animationend', function () {});
ctaButton.addEventListener('animationiteration', function () {});
}