-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
48 lines (31 loc) · 850 Bytes
/
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
47
48
"use strict";
var btn = document.querySelector(".btn");
var bar = document.querySelector(".snackbar-wrapper");
btn.addEventListener("click", () => {
btn.disabled = true;
showPromise().then(setTimeout(() => {
hidePromise().then(() => {
btn.disabled = false;
});;
}, 3000));
});
var showPromise = () => {
return new Promise((resolve, reject) => {
bar.style.display = "inline-block";
setTimeout(() => {
bar.style.opacity = 1;
bar.style.top = "90vh";
resolve();
}, 10);
});
}
var hidePromise = () => {
return new Promise((resolve, reject) => {
bar.style.opacity = 0;
bar.style.top = "110vh";
setTimeout(() => {
bar.style.display = "none";
resolve();
}, 500);
});
}