-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjQuery.qLoad.js
More file actions
36 lines (33 loc) · 834 Bytes
/
jQuery.qLoad.js
File metadata and controls
36 lines (33 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// First code snippp version... coments on its way...
(function($) {
var buffer = [];
var cache = [];
var history = [];
var countLoading = 0;
$.preLoadImages = function() {
var args_len = arguments.length;
for (var i = args_len; i--;) {
if(0<=$.inArray(arguments[i], history)){
continue;
}
if(0<=$.inArray(arguments[i], buffer)){
buffer.splice(buffer.indexOf(arguments[i]),1)
}
buffer.push(arguments[i]);
}
jQuery.preLoadNextImage();
jQuery.preLoadNextImage();
}
$.preLoadNextImage = function() {
if(3<countLoading){
return
}
countLoading++
var cacheImage = $('<img/>').load(function(){
history.push($(this).attr('src'));
countLoading--;
jQuery.preLoadNextImage();
}).attr('src', buffer.pop());
cache.push(cacheImage);
}
})(jQuery)