-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloading-sannie.js
More file actions
46 lines (35 loc) · 1.41 KB
/
loading-sannie.js
File metadata and controls
46 lines (35 loc) · 1.41 KB
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
const LoadScreen = {
loadScreenEl: document.getElementById("loadscreen"),
spinnerEl: null,
init() {
this.checkAltBody();
// bind methode this.endLoadscreen aan window.onload, zorg ervoor
// dat het LoadScreen object als context wordt gezien
// Ik heb een extra seconden toegevoegd voor pagina's die te snel geladen
window.onload = () => {
setTimeout(this.endLoadscreen.bind(this), 1000);
};
},
checkAltBody() {
// Als er gekozen is voor een eigen spinner oid, return false (sluit methode af)
if (this.loadScreenEl.children.length) return false;
let newSpinner = document.createElement("div");
let altcolor = this.loadScreenEl.getAttribute("altcolor");
newSpinner.id = "spinner";
this.spinnerEl = newSpinner;
// if (altcolor) {
// this.spinnerEl.style.borderTopColor = altcolor;
// } else {
// this.spinnerEl.style.borderTopColor = "#f25a41";
// }
this.spinnerEl.style.borderTopColor = altcolor ? altcolor : "#f25a41";
//overlay background color aanpassen
this.loadScreenEl.style.background = "#a57bca"
this.loadScreenEl.appendChild(this.spinnerEl);
},
endLoadscreen() {
this.loadScreenEl.outerHTML = "";
delete this.loadScreenEl;
}
}
LoadScreen.init();