-
Notifications
You must be signed in to change notification settings - Fork 0
/
infinitescroll.html
executable file
·73 lines (54 loc) · 2.45 KB
/
infinitescroll.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
<link rel="stylesheet" type="text/css" href="css/styles.css"/>
</head>
<body class="green">
<div class="block">
<p>This infiniteScroll page contains a list that grows when the user hits the bottom of the page</p>
<p>So scroll to infinite and beyond!</p>
<p>Your view in cobalt.json should have infiniteScroll set to true. Otherwise it won't work.<br/>
Below is a link to the same page but with infiniteScroll disabled. It should do nothing when hitting the bottom.
</p>
<a class="push" href="javascript:;" data-href="infinitescroll.html" data-classid="infiniteScrollNonActive">infiniteScroll
disabled</a>
</div>
<div class="block">
<p>This page uses infiniteScroll AND pullToRefresh together. So slide up and down.</p>
<a class="push" href="javascript:;" data-href="pulltorefresh_&_infinitescroll.html"
data-classid="PTR_and_InfiniteScroll">PullToRefresh and InfiniteScroll</a>
</div>
<div class="block">
<p>Scroll-to-top is enabled on this page. Clic on the status bar to see it working (on iOS).</p>
</div>
<div id="list">
</div>
<a href="ajax.html" id="" title="ajax">ajax</a>
<p id="loading" style="padding:10px; text-align:center; display:none;">Loading...</p>
<script type="text/javascript" src="js/zepto.min.js"></script>
<script type="text/javascript" src="js/Cobalt-Web/cobalt.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script>
var someListItems = '<div class="listItem"><div class="num">#21454</div><div class="name">John Doe</div></div><div class="listItem"><div class="num">#21454</div><div class="name">John Doe</div></div><div class="listItem"><div class="num">#21454</div><div class="name">John Doe</div></div>'
Zepto(function($) {
cobalt.init();
cobalt.subscribe('cobalt:onInfiniteScroll', function(){
cobalt.log('native asked to load more content');
$('#loading').show();
setTimeout(function() {
$('#loading').hide();
$('#list').append(someListItems);
cobalt.infiniteScroll.dismiss();
}, 1000, true);
});
app.initPage('Infinite Scroll');
while ($("body").height() <= $(window).height()) {
$('#list').append(someListItems);
}
})
</script>
</body>
</html>