-
Notifications
You must be signed in to change notification settings - Fork 0
/
shared.js
84 lines (66 loc) · 2 KB
/
shared.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var buttons = document.querySelectorAll('.plan button');
var backdrop = document.querySelector('.backdrop');
var modal = document.querySelector('.modal');
var buttonNoModal = document.querySelector('.modal__action--negative');
var toggleButton = document.querySelector('.toggle-button');
var sideBar = document.querySelector('.mobile-nav');
var ctaButton = document.querySelector('.nav-nav__item--cta');
console.log(buttons);
//add listener to buttons Choose Plan
buttons.forEach(button => {
button.addEventListener('click', () => {
openBackdrop();
openModalWithTransition();
})
});
/*Sidebar mobile*/
toggleButton.addEventListener('click', () => {
openBackdrop();
sideBar.classList.add('open');
});
backdrop.addEventListener('click', () => {
closeBackdrop();
closeSideBar();
closeModal();
});
/*capture the animation event trigger by animation property*/
ctaButton.addEventListener("animationstart", (event) => {
console.log("animationstrar", event);
});
ctaButton.addEventListener("animationiteration", (event) => {
console.log("animationiteration", event);
});
ctaButton.addEventListener("animationend", (event) => {
console.log("animationend", event);
});
//functions
function openModalWithTransition() {
eventButtonNoModal();
modal.classList.remove("modal-display__none");
modal.classList.add("modal-display__block");
setTimeout(() => {
modal.classList.add("modal-transition");
}, 10);
}
function closeBackdrop() {
backdrop.style.display = "none";
}
function openBackdrop() {
backdrop.style.display = "block";
}
function closeModal() {
modal.classList.remove("modal-transition");
setTimeout(() => {
modal.classList.remove("modal-display__block");
modal.classList.add("modal-display__none");
}, 300);
}
function closeSideBar() {
sideBar.classList.remove('open');
}
function eventButtonNoModal() {
buttonNoModal.addEventListener('click', () => {
closeBackdrop();
closeModal();
});
}