Skip to content

ginpei/preload-image.js

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

日本語→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.

About

Run callback when each/all specified images are loaded.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published