forked from revolunet/angular-carousel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
252 lines (225 loc) · 7.94 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=620, user-scalable=no">
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<style>
html, body {
height:100%;
padding:0;
margin:0;
}
body {
margin: 0;
background: #333;
color:white;
padding: 10px;
}
* {
font-family: 'Droid Sans', sans-serif;
}
h1 {
margin-top: 5px;
}
h3 {
margin: 30px 0 10px 0;
}
.image {
width: 400px;
height: 200px;
}
.image-wide {
width: 500px;
height: 250px;
}
.image li, .image-wide li {
background-size: auto;
background-position: center center;
}
div.layer {
background-color:rgba(0, 0, 0, 0.5);
padding:5px;
font-size:10px;
}
.repo {
width: 300px;
height: 200px;
}
.repo li {
padding:10px;
color:black;
background: #bbb;
box-sizing: border-box;
-moz-box-sizing: border-box;
}
div.repo-name {
font-size: 18px;
font-weight: bold;
margin-bottom:10px;
text-decoration:underline;
-webkit-transition: all 1s ease-in;
transition: all 1s ease-in;
color:black;
}
div.repo-name:hover {
color:red;
}
ul li {
list-style-type: none
}
ul.basic {
width:300px;
height:200px;
}
ul.basic li {
text-align:center;
padding-top:80px;
font-size: 22px;
}
a {
color:white;
}
ul.puredom {
width:300px;
height:200px;
font-size:0;
}
.puredom li {
background: #666;
text-align:center;
font-size:24px;
}
</style>
</head>
<body ng-app="myApp" ng-controller='demoController'>
<a href="https://github.com/revolunet/angular-carousel"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
<h1>AngularJS Touch Carousel</h1>
<div class='intro'>Transform your ng-repeat or DOM nodes in a mobile-friendly carousel just by adding a 'rn-carousel' attribute to your ul/li block, thanks to AngularJS magic :)<br><br>
Carousels are data-bound to your ngRepeat collections, can be DOM buffered (good for performance), can cycle over your fixed collection or receive on-demand slides for infinite carousels :)
<br><br>
Try to swipe these demos with your mouse or your finger :
</div>
<h3>Simple carousel</h3>
A very basic carousel with indicators<br><br>
<ul rn-carousel rn-carousel-indicator class="image">
<li ng-repeat="image in cityImages" style="background-image:url({{ image }});">
<div class="layer" ng-bind-html-unsafe="image"></div>
</li>
</ul>
<h3>Simple carousel without ng-repeat</h3>
This carousel use the ul/li structure to generate the slides<br><br>
<ul rn-carousel rn-carousel-indicator class="puredom">
<li>Slide #1</li>
<li>Slide #2</li>
<li>Slide #3</li>
<li>Slide #4</li>
<li>Slide #5</li>
</ul>
<!--
<h3>Forever carousel</h3>
A carousel that cycles forever<br><br>
<ul rn-carousel rn-carousel-cycle rn-carousel-indicator class="image">
<li data-ng-repeat="image in cityImages2" style="background-image:url({{ image }});">
<div class="layer" ng-bind-html-unsafe="image"></div>
</li>
</ul>
<h3>Forever buffered carousel</h3>
A cycling buffered carousel<br><br>
<ul rn-carousel rn-carousel-cycle rn-carousel-buffered class="image">
<li ng-repeat="image in cityImages2" style="background-image:url({{ image }});">
<div class="layer" ng-bind-html-unsafe="image"></div>
</li>
</ul>
-->
<h3 data-ng-bind-html-unsafe="'Discover sports (slide ' + (currentSport + 1) + '/' + sportImages.length + ')'"></h3>
This carousel has two way data-binding, custom controls and is buffered (only 3 slides rendered)<br><br>
<ul data-rn-carousel rn-carousel-buffered rn-carousel-index="currentSport" class="image">
<li ng-repeat="image in sportImages" style="background-image:url({{ image }});">
<div class="layer" ng-bind-html-unsafe="image"></div>
</li>
</ul>
<button ng-click="currentSport = currentSport - 1" ng-disabled="currentSport == 0">prev</button>
<button ng-click="currentSport = currentSport + 1" ng-disabled="currentSport == sportImages.length - 1">next</button>
<h3>Our Public GitHub repos</h3>
This carousel has a more advanced template and DOM buffered.<br><br>
<ul rn-carousel rn-carousel-buffered class="repo" >
<li ng-repeat="repo in githubRepos">
<div class="repo-name">{{ repo.name }}</div>
{{ repo.description }}<br>
<br>
<b>watchers</b> : {{ repo.watchers_count }}<br>
<b>forks</b> : {{ repo.forks_count }}<br>
<b>open issues</b> : {{ repo.open_issues_count }}<br>
</li>
</ul>
<h3>Other examples</h3>
<!-- <lI><a href="./demo/infinite.html">Infinite buffered carousel</a> : full screen example for mobile devices. Previous/Next slides are generated on-demand from functions or promises.</li>
<br>
-->
<li><a href="./demo/flickr-full/index.html">Fullscreen Flickr demo (mobile)</a> : demo using Flickr API and a carousel to display Flickr groups feeds</li>
<li><a href="./demo/infinite.html">Infinite carousel 1</a> : using rn-carousel-prev and rn-carousel-next</li>
<li><a href="./demo/infinite2.html">Infinite carousel 2</a> : using rn-carousel-infinite and prev/next callbacks</li>
<li><a href="./demo/dynamic.html">add/remove slides dynamically</a> : using the rn-carousel-watch attribute</li>
<br><br><br>
<script src="//code.angularjs.org/1.1.5/angular.js"></script>
<script src="./lib/angular-mobile.js"></script>
<!-- include carousel src -->
<script src="./dist/angular-carousel.js"></script>
<link href='./dist/angular-carousel.min.css' rel='stylesheet' type='text/css'>
<script>
/* demo page code */
angular.module('myApp', ['angular-carousel'])
.controller('demoController', function($scope, $http) {
$scope.sportImages = [];
$scope.cityImages = [];
$scope.cityImages2 = [];
$scope.githubRepos = [];
$scope.currentSport = 0;
$http.get('https://api.github.com/users/revolunet/repos', {
params: {
sort: 'updated',
order:'desc'
}
}).success(function(data) {
$scope.githubRepos = data;
}).error(function() {
alert('cannot fetch github API');
})
for (var i=0; i<10; i++) {
for (var j=0; j<10; j++) {
$scope.sportImages.push('http://lorempixel.com/400/200/sports/' + j + '/');
}
$scope.cityImages.push('http://lorempixel.com/400/200/city/' + i + '/');
if (i<5) $scope.cityImages2.push('http://lorempixel.com/400/200/city/' + i + '/');
}
// infinite carousel stuff
var currentDay = (new Date()),
colors = ['#339966', '#336699', '#cc9933', '#cc6633', '#cc3366', '#66cc33'];
function addPage() {
// generate a single page, with color and a new date
var colorIndex = $scope.pages.length % colors.length;
$scope.pages.push({
bg: colors[colorIndex],
date: currentDay
})
currentDay = new Date(currentDay.getTime() + 60*60*24*1000);
}
// add some initial pages
$scope.pages = [];
addPage();
addPage();
addPage();
addPage();
addPage();
$scope.generateSlides = function() {
// callback called when carousel reach the penultimate slide
// add some slides (could be one)
addPage();
addPage();
addPage();
};
});
</script>
</body>
</html>