brindille-preloader
v2.0.0
Published
Promise or event based preloader using PxLoader
Downloads
4
Readme
brindille-preloader
Promise or event based preloader using PxLoader
Install
With npm do:
$ npm install brindille-preloader --save
Usage
var preloader = require('brindille-preloader');
Event based usage
preloader.on('progress', progressHandler);
preloader.on('complete', completeHandler);
preloader.on('error', errorHandler);
preloader.load([
{ id: 'img1', src: 'images/1.jpg', priority: 0, origin: 'anonymous' },
{ id: 'img2', src: 'images/2.jpg', priority: 0, origin: 'anonymous' },
{ id: 'vidTest', src: 'videos/vid.mp4', priority: 0, origin: 'anonymous' },
{ id: 'soundTest', src: 'sounds/sound.mp3', priority: 0, origin: 'anonymous' }
]);
Promise based usage
preloader.load([
{ id: 'img1', src: 'images/1.jpg', priority: 0, origin: 'anonymous' },
{ id: 'img2', src: 'images/2.jpg', priority: 0, origin: 'anonymous' },
{ id: 'vidTest', src: 'videos/vid.mp4', priority: 0, origin: 'anonymous' },
{ id: 'soundTest', src: 'sounds/sound.mp3', priority: 0, origin: 'anonymous' }
]);
preloader.getPromise()
.then(completeHandler)
.fail(errorHandler);
Get loaded ressource
var myImage = preloader.getImage('img1');
var myVideo = preloader.getVideo('vidTest');
var mySound = preloader.getSound('soundTest');
License
MIT