Preloader: How to make an element change style during preload
Hello everybody,
so I got my preloader working and counting up until 100%.
My full preloader.js can be found here:
http://mc-communicate.com/preloader.js
I call the preloader on my front-page.js:
var _pContainer = $('<div id="coll-preloader"></div>')
- var _pPercent = $('<div class="percent">0</div>')
- var _pbgwhite = $('<div class="bgwhite"></div>')
- var _pbred = $('<div class="bgred"></div>')
- if (!$('.lt-ie9').length) {
- _pContainer.append(_pPercent, _pbgwhite, _pbred);
- $('body.home').append(_pContainer);
- document.addEventListener("collpercent", function () {
- _pPercent.text(Math.round(myPreloader.percentage));
- })
- var myPreloader = new sPreloader({
- contentDiv:'main', //ID of your mainContent
- loaderDiv:'coll-preloader', //ID of your loading DIV
- excludingClass:'no', //Name of class to exclude from the preloader
- logProgress:true, //log the percentage through console.log
- animation:'fade', //animation type: fade | none
- animationSpeed:'1.0' //animation speed
- });
- myPreloader.start();
But now I want a div to move up while preloading like this:
if 10% preloaded #bgwhite.css(top:40%) if 20% preloaded #bgwhite.css(top:30%) ... and so on
Something like: $(function () { $('.percent:contains("5")').each(function () { $('.bgwhite').css("top","49.7%"); });
Maybe I've sat at this for too long, but does anybody know how to do this?
Greez,
LL