Last active
December 31, 2015 18:09
-
-
Save rodrigogmdias/8024626 to your computer and use it in GitHub Desktop.
Função de Preload de Imagens no Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function preloadImages(images, callback) { | |
var count = images.length; | |
if(count === 0) { | |
callback(); | |
} | |
var loaded = 0; | |
$(images).each(function() { | |
$('<img>').attr('src', this).load(function() { | |
loaded++; | |
if (loaded === count) { | |
callback(); | |
} | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment