mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
demo(collection-repeat): add basic demo
This commit is contained in:
32
demos/collection-repeat/index.html
Normal file
32
demos/collection-repeat/index.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<html ng-app="ionic">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
|
||||
|
||||
<title>Collection-Repeat: Early Preview</title>
|
||||
|
||||
<link href="http://code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
|
||||
<link href="style.css" rel="stylesheet">
|
||||
<script src="http://code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
|
||||
<script src="script.js"></script>
|
||||
</head>
|
||||
|
||||
<body ng-controller="MainCtrl">
|
||||
<ion-header-bar class="bar-positive">
|
||||
<h1 class="title">Try On a Phone</h1>
|
||||
<a class="button" ng-click="scrollBottom(true)">
|
||||
Scroll Bottom
|
||||
</a>
|
||||
</ion-header-bar>
|
||||
<ion-content>
|
||||
<ion-refresher on-refresh="onRefresh()"></ion-refresher>
|
||||
<div class="list">
|
||||
<div class="item"
|
||||
collection-repeat="item in items"
|
||||
collection-item-height="getItemHeight($index)">
|
||||
{{item}}
|
||||
</div>
|
||||
</div>
|
||||
</ion-content>
|
||||
</body>
|
||||
</html>
|
||||
25
demos/collection-repeat/script.js
Normal file
25
demos/collection-repeat/script.js
Normal file
@@ -0,0 +1,25 @@
|
||||
function MainCtrl($scope, $ionicScrollDelegate, $timeout) {
|
||||
$scope.items = [];
|
||||
for (var i = 0; i < 5000; i++) {
|
||||
$scope.items.push('item '+i);
|
||||
}
|
||||
|
||||
$scope.getItemHeight = function(index) {
|
||||
return 52 + 5 * (index % 5);
|
||||
};
|
||||
|
||||
$scope.onRefresh = function() {
|
||||
$timeout(function() {
|
||||
$scope.items.unshift(-$scope.items.length);
|
||||
$scope.items.unshift(-$scope.items.length);
|
||||
$scope.items.unshift(-$scope.items.length);
|
||||
$scope.items.unshift(-$scope.items.length);
|
||||
$scope.items.unshift(-$scope.items.length);
|
||||
$scope.$broadcast('scroll.refreshComplete');
|
||||
}, 1500);
|
||||
};
|
||||
|
||||
$scope.scrollBottom = function(animate) {
|
||||
$ionicScrollDelegate.scrollBottom(animate);
|
||||
};
|
||||
}
|
||||
4
demos/collection-repeat/style.css
Normal file
4
demos/collection-repeat/style.css
Normal file
@@ -0,0 +1,4 @@
|
||||
.item {
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
Reference in New Issue
Block a user