/preload-image.js

Run callback when each/all specified images are loaded.

Primary LanguageJavaScript

日本語→README.ja.md

preload-image.js

Run callback when each/all specified images are loaded.

Usage

See sample JS. -> sample/sample.js

Paste content of preload-image.min.js and:

preloadImages([
	'path/to/image1',
	'path/to/image2',
	'path/to/image3'
])
	.onprogress(function(data) {
		var loaded = data.loadeds.length;
		var all = data.files.length;
		var progress = parseInt(100 * loaded / all, 10);

		console.log(
			data.path, 'is loades.',
			'Status:', loaded + '/' + all, '(' + progress + '%)'
			);

		// show image on browser
		document.body.appendChild(data.image);
	})
	.onload(function(data) {
		console.log('Done.');
	})
	.onerror(function(data) {
		console.error('ERROR!', data.event);
	});

About

Developed by

License

History

  • 2014-11-08
    • First release.