#22: use opaque loader background on first show

This commit is contained in:
SleepWalker 2018-05-13 22:32:22 +03:00
parent 64cb197756
commit a860e10847
3 changed files with 12 additions and 4 deletions

View File

@ -1,4 +1,4 @@
<div id="loader" class="loader-overlay">
<div id="loader" class="loader-overlay is-first-launch">
<div class="loader">
<div class="loader__cube loader__cube--1"></div>
<div class="loader__cube loader__cube--2"></div>

View File

@ -12,12 +12,19 @@
transition: 0.4s ease;
&.is-first-launch {
// if loader is shown for the first time, we will
// remove opacity and hide the entire site contents
background: #f2efeb;
}
&.is-active {
opacity: 1;
visibility: visible;
}
}
.loader {
position: absolute;
top: 50%;

View File

@ -3,14 +3,15 @@ let stack = 1;
export default {
show() {
if (++stack !== 1) {
if (++stack >= 0) {
document.getElementById('loader').classList.add('is-active');
}
},
hide() {
if (--stack === 0) {
document.getElementById('loader').classList.remove('is-active');
if (--stack <= 0) {
stack = 0;
document.getElementById('loader').classList.remove('is-active', 'is-first-launch');
}
}
};