All Projects → zzarcon → walter.js

zzarcon / walter.js

Licence: MIT license
:squirrel: Preload images with a Promise flavor

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Walter.js Build Status

Walter.js is a Javascript library that does all common things that you usually do when preload images. In this way Walter.js exports an easy Api based on Promises and events in wich you can subscribe for know the status of each image.

API

Preload one image
var promise = Walter('picture.jpg');
Preload multiple images
var promise = Walter(['picture1.jpg', 'picture2.jpg']);
Events
var promise = Walter(['picture1.jpg', 'picture2.jpg']);

//It's called when each image is loaded
promise.progress(function(index, img) {
  console.log(index, img);
});

//It's called when all images are loaded
promise.then(function(images) {
  console.log('then', images);
});

//It's called if some image has error
promise.catch(function(promise) {
  console.log('catch', promise);
});
Chaining

You can also use Walter.js with chain style

promise.then(onComplete).catch(onError).progress(onUpdate);
Config
Walter.config({
  path: 'assets/images'
});

Dependencies

None :D

How to Run Unit Tests

  • npm install
  • grunt test

TODO

  • Add RSVP library for support old browsers
  • Document code
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].