Skip to content

Commit a650523

Browse files
committed
reload(100) demo
1 parent ef0c4b3 commit a650523

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

demo/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ <h1 class="page-header">Scroller Examples</h1>
5454
Top visible (Adapter)
5555
</a>
5656
</li>
57+
<li>
58+
<a href="reload100/reload100.html">
59+
Reload datasource to specified index
60+
</a>
61+
</li>
5762
<li>
5863
<a href="visibility/visibility.html">
5964
Visibility

demo/reload100/reload100.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Reload 100</title>
6+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js"></script>
7+
<script src="../../dist/ui-scroll.js"></script>
8+
<script src="../../dist/ui-scroll-jqlite.js"></script>
9+
<script src="reload100.js"></script>
10+
<link rel="stylesheet" href="../css/style.css" type="text/css"/>
11+
</head>
12+
<body ng-controller="mainController" ng-app="application">
13+
14+
<div class="cont cont-global">
15+
16+
<a class="back" href="../index.html">browse other examples</a>
17+
18+
<h1 class="page-header page-header-exapmle">Datasource as service</h1>
19+
20+
<div class="description">
21+
Here we provide an ability to reload the datasource to some specified position.
22+
</div>
23+
24+
<div class="actions" ng-init="reloadIndex = 100">
25+
<input ng-model="reloadIndex" size="2"> - index to reload <br>
26+
<button ng-click="doReload(reloadIndex)"> Reload({{reloadIndex}}) </button>
27+
</div>
28+
29+
<div class="viewport" id="viewport-serviceDatasource" ui-scroll-viewport>
30+
<div class="item" ui-scroll="item in datasource" adapter="adapter">{{item}}</div>
31+
</div>
32+
33+
</div>
34+
35+
</body>
36+
</html>

demo/reload100/reload100.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
angular.module('application', ['ui.scroll', 'ui.scroll.jqlite'])
2+
.controller('mainController', [
3+
'$scope', '$log', '$timeout', function ($scope, console, $timeout) {
4+
var datasource = {};
5+
6+
datasource.get = function (index, count, success) {
7+
$timeout(function () {
8+
var result = [];
9+
for (var i = index; i <= index + count - 1; i++) {
10+
result.push("item #" + i);
11+
}
12+
success(result);
13+
}, 100);
14+
};
15+
16+
$scope.datasource = datasource;
17+
18+
$scope.doReload = function () {
19+
if (angular.isObject($scope.adapter) && angular.isFunction($scope.adapter.reload)) {
20+
var reloadIndex = parseInt($scope.reloadIndex, 10);
21+
reloadIndex = isNaN(reloadIndex) ? 1 : reloadIndex;
22+
$scope.adapter.reload(reloadIndex);
23+
}
24+
};
25+
26+
}
27+
]);

0 commit comments

Comments
 (0)