-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (28 loc) · 892 Bytes
/
script.js
File metadata and controls
34 lines (28 loc) · 892 Bytes
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
(function(loader) {
window.addEventListener('beforeunload', function(e) {
activateLoader();
});
window.addEventListener('load', function(e) {
deactivateLoader();
});
function activateLoader() {
loader.style.display = 'block';
loader.style.opacity = 1;
}
function deactivateLoader() {
/**
* ensures that the loading animation plays for at least a second to give the
* appearance of seamless loading on pages that execute and load extremely
* quickly (i.e., intranet pages)
*/
setTimeout(function() {
deactivate();
}, 1000);
function deactivate() {
loader.style.opacity = 0;
loader.addEventListener('transitionend', function() {
loader.style.display = 'none';
}, false);
}
}
})(document.querySelector('.o-page-loader'));