Last active
January 11, 2018 00:35
-
-
Save juandinella/1350615f03dc3a3d190ec72f7dc45104 to your computer and use it in GitHub Desktop.
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($) { | |
var imgList = []; | |
$.extend({ | |
preload: function(imgArr, option) { | |
var setting = $.extend({ | |
loaded_all: function(loaded, total) {} | |
}, option); | |
var total = imgArr.length; | |
var loaded = 0; | |
for(var i in imgArr) { | |
imgList.push($("<img />") | |
.attr("src", imgArr[i]) | |
.load(function() { | |
loaded++; | |
if(loaded == total) { | |
setting.loaded_all(loaded, total); | |
} | |
}) | |
); | |
} | |
} | |
}); | |
})(jQuery); | |
$(function() { | |
$.preload([ | |
"logo.png", | |
"img-1.png", | |
"img-2.png" | |
], { | |
loaded_all: function(loaded, total) { | |
$( "#preload" ).fadeOut(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment