Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pace.js "Hide everything but PACE until the page has fully loaded" local copy

Tags:

css

pace.js

I was able to hide everything but pace until the page had loaded when installing pace.js with eager.io.

However, when using bower to install the plugin and downloading the css theme, I was unable to figure out how to do this.

like image 377
sebko Avatar asked Feb 19 '15 06:02

sebko


2 Answers

I fixed this by adding this css

body > :not(.pace),body:before,body:after {
  -webkit-transition:opacity .4s ease-in-out;
  -moz-transition:opacity .4s ease-in-out;
  -o-transition:opacity .4s ease-in-out;
  -ms-transition:opacity .4s ease-in-out;
  transition:opacity .4s ease-in-out
}

body:not(.pace-done) > :not(.pace),body:not(.pace-done):before,body:not(.pace-done):after {
  opacity:0
}
like image 145
sebko Avatar answered Nov 01 '22 02:11

sebko


The previous answer works in most cases but if for any reason pace.js is disabled, your body will keep its opacity to 0 and your content won't be shown. The following rules avoid this problem:

.pace-running > :not(.pace) {
  opacity: 0;
}

.pace-done > :not(.pace) {
  opacity: 1;
  transition: opacity .5s ease;
}

Then, up to you to add prefixes or pseudo-classes…

like image 6
NicolasGraph Avatar answered Nov 01 '22 02:11

NicolasGraph