forked from LinZap/jquery.waterfall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadmore.html
74 lines (60 loc) · 1.34 KB
/
loadmore.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Waterfall-Light Demo</title>
<style type="text/css">
*{
margin: 0;
padding:0;
}
body{
padding:20px;
}
.endele{
padding: 100px 0;
font-size: 30px;
}
</style>
</head>
<body>
<div id="box"></div>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="waterfall-light.js"></script>
<script>
$(function(){
var page = 5;
// as below
var setting = {
gap: 10,
gridWidth: [0,400,600,800,1200],
scrollbottom:{
gap: 300,
endtxt : 'No More Data !!',
callback: function(container){
// if scroll to bottom, load more data...
ajax_get_more_data(container);
if(page>=0) container.waterfall('sort');
else container.waterfall('end');
}
}
};
$('#box').waterfall(setting);
// such as $.ajax()
function ajax_get_more_data(container){
if(page>0){
for (var i = 0; i< 30; i++) {
var card = $('<div>').addClass('card').css({
height: Math.floor((Math.random() * 100) + 200)+"px",
background: '#ace'
});
container.append(card);
}
}
page--;
}
});
</script>
</body>
</html>