thinkpixellab / PxLoader

PxLoader is a simple JavasScript library for creating preloaders and resource downloaders for HTML5 apps.
http://thinkpixellab.com/pxloader
1.11k stars 173 forks source link

ability to only load ressources with specified tags #21

Open timohausmann opened 11 years ago

timohausmann commented 11 years ago

Hey. I added the following functionality:

It is now possible to load ressources in groups, defined by tags. Each group can have an own completionListener. An example: you want to load a group of ressources on document ready. Later, when the user performs a specific action, you want to preload other ressources and treat them differently when loading is complete.

All you have to do is pass true as a second argument to the start-function (specifiedTagsOnly).

A quick demo: http://jsbin.com/ugojeb/2/

loader.addImage( 'http://placekitten.com/200/300', 'initial' );
loader.addImage( 'http://placekitten.com/200/300', 'content' );

loader.addCompletionListener(function() {
    [...]
}, 'initial');
loader.addCompletionListener(function() {
    [...]
}, 'content');

loader.start('initial', true);
$('button').on('click', function() {
  loader.start('content', true);
});