demo(collection-repeat): add basic demo

This commit is contained in:
Andy Joslin
2014-04-23 17:52:34 -06:00
parent 37d956371f
commit 4ac5483017
3 changed files with 61 additions and 0 deletions

View 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>

View 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);
};
}

View File

@@ -0,0 +1,4 @@
.item {
left: 0;
right: 0;
}