-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
87 lines (79 loc) · 2.09 KB
/
index.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<title>md-virtual-repeater</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script>
<script src="virtual-repeater.js"></script>
<script>
angular.module('pokeApp', ['virtualRepeat'])
.controller('listCtrl', function($http, $scope) {
$http.get('pokemon.json')
.then(function(response) {
$scope.pokemon = response.data.results;
});
$scope.$watch('search', function() {
$scope.topIndex = 0;
})
});
</script>
<style>
body {
display: flex;
flex-direction: column;
font-family: Arial, sans-serif;
margin: 0;
}
.pokemon-search {
box-shadow: 0 0 2px 2px #ddd;
max-height: 55px;
position: relative;
z-index: 1;
}
.pokemon-input {
border: 0;
box-sizing: border-box;
font-size: 20px;
margin: 0;
padding: 16px;
width: 100%;
}
.pokemon-list {
height: calc(100vh - 55px);
overflow-x: hidden;
overflow-y: scroll;
position: absolute;
width: 100%;
}
.pokemon-list:-webkit-scrollbar {
width: 0 !important;
}
.pokemon-item {
padding: 14px;
text-transform: capitalize;
}
.pokemon-item:nth-child(2n) {
background-color: #FAFAFA;
}
.pokemon-index {
display: inline-block;
margin-right: 24px;
text-align: right;
width: 48px;
}
</style>
</head>
<body ng-app="pokeApp">
<main ng-controller="listCtrl">
<div class="pokemon-search">
<input class="pokemon-input" placeholder="Search" ng-model="search">
</div>
<md-virtual-repeat-container class="pokemon-list" md-top-index="topIndex">
<div class="pokemon-item" md-virtual-repeat="i in pokemon | filter: search" md-item-size="20">
<span class="pokemon-index">#{{ $index }}</span>
<span class="pokemon-name">{{ i.name }}</span>
</div>
</md-virtual-repeat-container>
</main>
</body>
</html>