Skip to content
:squirrel: Preload images with a Promise flavor
JavaScript CSS
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
dist
sample-app Rename all the things
test
.gitignore
.travis.yml
Gruntfile.js
LICENSE Rename all the things
README.md
bower.json Rename all the things
package.json Add preload images tests

README.md

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
Something went wrong with that request. Please try again.