-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
44 lines (37 loc) · 1.41 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
window.onload = function onLoad() {
this.setTimeout(()=>{
const length = 3
let fulfilled = 0
const anims = Array.from({length}, () => getRandomArbitrary(1000, 3000))
.map((duration, i)=>{
return anime(getAnimeProps(duration, i))
})
this.document.querySelector('#console0').style.color = 'black'
anims.forEach((anim, i) => {
anim.finished.then(()=>{
fulfilled++
this.document.querySelector(`#text${i}`).style.fill = 'green'
this.document.querySelector(`#text${i}`).innerHTML = 'Fulfilled.'
this.document.querySelector(`#circle${i}`).style.fill = '#086e30'
this.document.querySelector(`#promise${i}`).style.color = 'green'
if(fulfilled === length) {
this.document.querySelector('#promise-status').innerHTML = 'Fulfilled. ✅'
this.document.querySelector('#console1').style.color = 'black'
}
})
})
}, 750)
};
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
function getAnimeProps(duration, i){
return {
targets: `#circle${i}`,
autoplay: true,
loop: false,
easing: 'easeInOutQuad',
translateX: window.innerWidth * 0.5,
duration
}
}