-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
83 lines (76 loc) · 2.65 KB
/
index.html
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>FreakLoad</title>
<link rel="stylesheet" href="assets/css/main.min.css" />
</head>
<body>
<h1>FreakLoad</h1>
<img data-url="assets/img/img1.jpg" data-priority="teste" data-tags="a, b" alt="img-1" />
<img data-url="assets/img/img2.jpg" data-priority="0.3" data-tags="a" alt="img-2" />
<img data-url="assets/img/img4.jpg" data-priority="0.7" data-tags="c" alt="img-4" />
<img data-url="assets/img/img3.jpg" data-priority="0.5" data-tags="a" alt="img-3" />
<img data-url="assets/img/img5.jpg" data-priority="0.9" data-tags="b" alt="img-5" />
<img data-url="assets/img/img6.jpg" data-priority="1.0" data-tags="b" alt="img-6" />
<script src="assets/vendor/jquery/dist/jquery.min.js"></script>
<script src="dist/js/jquery.freakload.js"></script>
<script>
$(function() {
$('img').freakLoad(
// item options
{
onStart: function(item) {
console.log(item);
},
onComplete: function(data, item) {
item.src = item.dataset.url;
item.classList.add('loaded');
}
},
// general options
{
groupOrder: ['c', 'a', 'b']
}
);
});
</script>
<!-- script>
$(function() {
var imgs = [],
html = '',
i = 0;
while (i < 6) {
imgs[i] = {
url: 'assets/img/img' + (i + 1) + '.jpg',
priority: Math.random(),
tags: [(i < 2 ? 'a' : 'b'), 'c']
}
html += '<li><img data-src="' + imgs[i].url + '" /></li>';
i++;
}
html = $('<ul />').append(html);
$('body').append(html);
$.freakLoad(imgs, {
groupOrder: ['a', 'b', 'c'],
on: {
complete: function() {
$('img').each(function() {
var $this = $(this);
$this.attr('src', $this.data('src'));
});
}
},
onGroup: {
start: function(group) {
console.log('group start', group);
},
complete: function(group) {
console.log('group complete', group);
}
}
});
});
</script -->
</body>
</html>