Skip to content

Commit

Permalink
Display spinner when loading al the scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAntares authored Oct 2, 2024
1 parent 6a84db6 commit cbcd530
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/App/Online.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,58 @@
* @author Vincent Thibault
*/

window.roInitSpinner = {
add: function(){
// Loading spinner ring
var loading = document.createElement('div');
loading.id = 'loading-element';
loading.className = 'lds-dual-ring';

var loadingStyle = document.createElement('style');
loadingStyle.id = 'loading-style';
loadingStyle.textContent = `
.lds-dual-ring { color: #1c4c5b }
.lds-dual-ring,
.lds-dual-ring:after { box-sizing: border-box; }
.lds-dual-ring {
position: absolute;
display: inline-block;
width: 80px;
height: 80px;
top: 50%;
left: 50%;
margin-top: -40px;
margin-left: -40px;
}
.lds-dual-ring:after {
content: " ";
display: block;
width: 64px;
height: 64px;
margin: 8px;
border-radius: 50%;
border: 6.4px solid currentColor;
border-color: currentColor transparent currentColor transparent;
animation: lds-dual-ring 1.2s linear infinite;
}
@keyframes lds-dual-ring {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
`;

document.head.appendChild(loadingStyle);
document.body.appendChild(loading);
},
remove: function(){
document.getElementById('loading-element').remove();
document.getElementById('loading-style').remove();
}
};

// Add spinner before starting the require chain to let the user know things are happening in the background
window.roInitSpinner.add();

// Errors Handler (hack)
require.onError = function (err) {
'use strict';
Expand Down
3 changes: 3 additions & 0 deletions src/Engine/GameEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ define(function( require )

// Execute
q.run();

// Remove init spinner
window.roInitSpinner.remove();
}


Expand Down

0 comments on commit cbcd530

Please sign in to comment.