Skip to content

Commit bcbfd31

Browse files
committed
start/end indexes manipulating demo
1 parent dbe3988 commit bcbfd31

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed

demo/index.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ <h1 class="page-header">Scroller Examples</h1>
5959
Reload datasource to specified index
6060
</a>
6161
</li>
62+
<li>
63+
<a href="userIndexes/userIndexes.html">
64+
Manipulate start and end indexes outside the directive
65+
</a>
66+
</li>
6267
<li>
6368
<a href="visibility/visibility.html">
6469
Visibility
@@ -109,7 +114,7 @@ <h1 class="page-header">Scroller Examples</h1>
109114
<div class="more-wrap">
110115
<a href="https://github.com/angular-ui/ui-scroll/">read more...</a>
111116
</div>
112-
117+
113118
</div>
114119
</body>
115120
</html>

demo/userIndexes/userIndexes.html

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>User min and max indexes</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="userIndexes.js"></script>
10+
<link rel="stylesheet" href="../css/style.css" type="text/css"/>
11+
<style type="text/css">
12+
button {
13+
width: 180px;
14+
margin-bottom: 3px;
15+
margin-right: 7px;
16+
}
17+
</style>
18+
</head>
19+
<body ng-controller="mainController" ng-app="application">
20+
21+
<div class="cont cont-global">
22+
23+
<a class="back" href="../index.html">browse other examples</a>
24+
25+
<h1 class="page-header page-header-exapmle">Set user min and max indexes</h1>
26+
27+
<div class="description">
28+
Here we provide an ability of external min and max indexes setting to let the viewport know how many items do we have.
29+
</div>
30+
31+
<div class="actions" ng-init="userMinIndex = -100; userMaxIndex = 100">
32+
<button ng-click="setUserMinIndex()"> Set minIndex = {{userMinIndex}} </button>
33+
<input ng-model="userMinIndex" size="2"> minIndex value to set
34+
<br>
35+
<button ng-click="setUserMaxIndex()"> Set maxIndex = {{userMaxIndex}} </button>
36+
<input ng-model="userMaxIndex" size="2"> maxIndex value to set
37+
<br>
38+
<button ng-click="setUserIndexes()"> Set both Indexes </button>
39+
</div>
40+
41+
<div ng-if="delay" class="viewport" id="viewport-serviceDatasource" ui-scroll-viewport>
42+
<div class="item" ui-scroll="item in datasource" adapter="adapter">{{item}}</div>
43+
</div>
44+
45+
</div>
46+
47+
</body>
48+
</html>

demo/userIndexes/userIndexes.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
$scope.adapter = {};
18+
19+
$scope.setUserMinIndex = function () {
20+
var userMinIndex = parseInt($scope.userMinIndex, 10);
21+
if(!isNaN(userMinIndex))
22+
$scope.datasource.minIndex = userMinIndex;
23+
};
24+
25+
$scope.setUserMaxIndex = function () {
26+
var userMaxIndex = parseInt($scope.userMaxIndex, 10);
27+
if(!isNaN(userMaxIndex))
28+
$scope.datasource.maxIndex = userMaxIndex;
29+
};
30+
31+
$scope.setUserIndexes = function () {
32+
$scope.setUserMinIndex();
33+
$scope.setUserMaxIndex();
34+
};
35+
36+
$scope.delay = false;
37+
$timeout(function() {
38+
$scope.delay = true;
39+
}, 500);
40+
41+
}
42+
]);

0 commit comments

Comments
 (0)