-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoadingBar.js
53 lines (48 loc) · 1.47 KB
/
LoadingBar.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
class LoadingBar{
constructor(options){
this.domElement = document.createElement("div");
this.domElement.style.position = 'fixed';
this.domElement.style.top = '0';
this.domElement.style.left = '0';
this.domElement.style.width = '100%';
this.domElement.style.height = '100%';
this.domElement.style.background = '#000';
this.domElement.style.opacity = '0.7';
this.domElement.style.display = 'flex';
this.domElement.style.alignItems = 'center';
this.domElement.style.justifyContent = 'center';
this.domElement.style.zIndex = '1111';
const barBase = document.createElement("div");
barBase.style.background = '#aaa';
barBase.style.width = '50%';
barBase.style.minWidth = '250px';
barBase.style.borderRadius = '10px';
barBase.style.height = '15px';
this.domElement.appendChild(barBase);
const bar = document.createElement("div");
bar.style.background = '#22a';
bar.style.width = '50%';
bar.style.borderRadius = '10px';
bar.style.height = '100%';
bar.style.width = '0';
barBase.appendChild(bar);
this.progressBar = bar;
document.body.appendChild(this.domElement);
function onprogress(delta){
const progress = delta*100;
loader.progressBar.style.width = `${progress}%`;
}
}
set progress(delta){
const percent = delta*100;
this.progressBar.style.width = `${percent}%`;
}
set visible(value){
if (value){
this.domElement.style.display = 'flex';
}else{
this.domElement.style.display = 'none';
}
}
}
export { LoadingBar };