0

Thanks to the comments below. Here is an updated question and code:

I have written two bits of code, a loader and sequential fade in. The loader works by adding the load class which with css displays a loading spinner.gif. Then removes the class and inserts an image.

The second fade's in a sequence of divs in order.

$.fn.myLoader = function() {
    $(this).addClass("loading").queue(function(next) {
        $(this).removeClass("loading");
        $(this).prepend('URL');
        next();
    });
};

$('#logo').myLoader();

and

$('.load').delay(5000).each(function(i) {
    $(this).delay(i * 250).css({
        opacity: 0.0,
        visibility: 'visible'
    }).animate({
        opacity: 1.0
    });
});

and the following markup:

<div id="logo"></div>
    <div class="load" style="visibility: hidden;"></div>
    <div class="load" style="visibility: hidden;"></div>
    <div class="load" style="visibility: hidden;"></div>
    <div class="load" style="visibility: hidden;"></div>
    <div class="load" style="visibility: hidden;"></div>
    <div class="load" style="visibility: hidden;"></div>

These work separately but I would like to merge the two so that the loader happens and once that has finished, loads the sequential images.

Please point out the errors of my way.

Thanks

Craig
  • 23
  • 4
  • Your code doesn't make much sense... your loader doesn't load anything and it doesn't allow for a way to tell it to hide when something finishes loading, it just assumes that it's done in 200ms... Please give a more complete sample. – Kevin B Jan 15 '13 at 18:27
  • Also, [.delay()](http://api.jquery.com/delay/) doesn't work like that. It only affects items in the animation queue. – Christian Jan 15 '13 at 18:43
  • Kevin B: Thank, I'll re-write it. Let me know if make better sense. Christian Varga: THat's actually a mistake, sorry. Thanks for spotting it. – Craig Jan 15 '13 at 19:09
  • dude, you cannot call $('#logo').myLoader with a callback argument, because your plugin doest not receive a callback as an argument. – Rodrigo Dias Jan 15 '13 at 19:29
  • Rodrigo - I need to read up some more. Cheers. – Craig Jan 15 '13 at 20:55

0 Answers0