forked from RobFenger/7vs7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.js
66 lines (53 loc) · 1.88 KB
/
form.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
const team = document.querySelector('input[id=team]:checked');
const teamName = document.querySelector(".team-name-input");
const formContainer = document.querySelector(".form-container");
const btnSubmit = document.querySelector(".submit-button");
const form = document.querySelector("form.submit-form");
let formHeight = 110;
function animateUp() {
if (formHeight >= 2500) {
clearInterval(animateFormUp);
} else {
formHeight = formHeight + 8;
// this 8 is used for the speed of the animation. the height of the form decreases with 8px per 1/100 second
// So speed = (800px per second)
formContainer.style.maxHeight = formHeight + 'px';
};
};
function displayForm() {
formContainer.classList.remove("form-is-closed");
btnSubmit.style.zIndex = 1;
if (formContainer.classList.contains("hide-form")) {
clearInterval(animate);
};
formContainer.classList.add("show-form");
formContainer.classList.remove("hide-form");
animateFormUp = setInterval(animateUp, 10);
};
function animateDown() {
if (formHeight <= (btnDisplayHeight + btnDisplayMarginBottom)) {
form.style.maxHeight = btnDisplayHeight + btnDisplayMarginBottom + 'px';
clearInterval(animate);
formContainer.classList.remove("show-form");
} else {
formHeight = formHeight - 8;
// this 8 is used for the speed of the animation. the height of the form decreases with 8px per 1/100 second
// So speed = (800px per second)
form.style.maxHeight = formHeight + 'px';
};
};
function hideForm() {
clearInterval(animateFormUp);
formContainer.classList.add("hide-form");
formHeight = form.offsetHeight;
if (window.innerWidth <= 992) {
body.classList.remove("no-scroll");
};
animate = setInterval(animateDown, 10);
};
function showTeam () {
teamName.style.display = "flex";
}
function hideTeam () {
teamName.style.display = "none"
}