forked from revolunet/angular-carousel
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
231 lines (212 loc) · 11 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
<!DOCTYPE html>
<html ng-app="DemoApp">
<head>
<meta charset="UTF-8">
<title>angular-carousel demo</title>
<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'>
<link href='./dist/angular-carousel.css' rel='stylesheet' type='text/css'>
<link href='./demo/demo.css' rel='stylesheet' type='text/css'>
</head>
<body ng-controller="DemoCtrl">
<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 HTML; AngularJS directives FTW :)<br><br>
Carousels are data-bound to your ngRepeat collections and can be DOM buffered (good for performance)
<br><br>
Swipe these demos with your mouse or finger
</div>
<div>
<div>
<h3>Buffered ngRepeat demo</h3>
<div class="details">A simple buffered ng-repeat with a custom template.
<br>
Swipe 50 slides with only 5 slides in the DOM. use builtin controls
</div>
<div class="carousel-demo">
index : <input type="number" class="tiny" ng-model="carouselIndex">
<ul rn-carousel rn-carousel-controls rn-carousel-index="carouselIndex" rn-carousel-buffered class="carousel1">
<li ng-repeat="slide in slides track by slide.id" ng-class="'id-' + slide.id">
<div ng-style="{'background-image': 'url(' + slide.img + ')'}" class="bgimage">
#{{ slide.id }}
</div>
</li>
</ul>
</div>
</div>
<div>
<h3>buffered ngRepeat with auto-slide(pause on hover) and builtin indicators </h3>
<div class="details">
</div>
<div class="carousel-demo">
index: <input type="number" class="tiny" ng-model="carouselIndex2">
<ul rn-carousel rn-carousel-index="carouselIndex2" rn-carousel-auto-slide rn-carousel-pause-on-hover rn-carousel-buffered class="carousel2">
<li ng-repeat="slide in slides2 track by slide.id" ng-class="'id-' + slide.id">
<div ng-style="{'background-image': 'url(' + slide.img + ')'}" class="bgimage">
#{{ slide.id }}
</div>
</li>
</ul>
<div rn-carousel-indicators ng-if="slides2.length > 1" slides="slides2" rn-carousel-index="carouselIndex2"></div>
</div>
</div>
<br>
<div>
<h3>buffered ngRepeat and custom indicators </h3>
<div class="details">
</div>
<div class="carousel-demo">
<ul rn-carousel rn-carousel-index="carouselIndex22" rn-carousel-auto-slide rn-carousel-buffered class="carousel2">
<li ng-repeat="slide in slides2 track by slide.id" ng-class="'id-' + slide.id">
<div ng-style="{'background-image': 'url(' + slide.img + ')'}" class="bgimage">
#{{ slide.id }}
</div>
</li>
</ul>
<div class="rn-carousel-indicator custom-indicator">
<span ng-repeat="slide in slides2" ng-class="{active: $index==$parent.carouselIndex22}" ng-click="$parent.carouselIndex22 = $index">★</span>
</div>
</div>
</div>
<br>
<div >
<h3>buffered ngRepeat with custom transition</h3>
<div class="details">Use the 'hexagon' transition. index is shared with the carousel below.
</div>
<div class="carousel-demo">
<ul rn-carousel rn-carousel-index="carouselIndex3" rn-carousel-transition="hexagon" rn-carousel-buffered class="carousel3">
<li ng-repeat="slide in slides3 track by slide.id">
<div ng-style="{'background-image': 'url(' + slide.img + ')'}" class="bgimage">
#{{ slide.id }}
</div>
</li>
</ul>
</div>
</div>
<br>
<div>
<h3>Custom templates without ng-repeat and auto-slide</h3>
<div class="details">
</div>
<div class="carousel-demo">
<ul rn-carousel rn-carousel-index="3" rn-carousel-auto-slide="3" class="carousel5">
<li>Slide 1</li>
<li>Slide 2</li>
<li>Slide 3</li>
<li>Slide 4</li>
<li>Slide 5</li>
<li>Slide 6</li>
<li>Slide 7</li>
<li>Slide 8</li>
<li>Slide 9</li>
</ul>
</div>
</div>
<br>
<div>
<h3>Lockable carousel</h3>
<div class="details">
use rn-carousel-locked binding to dynamically lock/unlock the carousel
</div>
<div class="carousel-demo">
<label><input type="checkbox" ng-model="isLocked"/>Lock the carousel</label>
<ul rn-carousel class="carousel5" rn-carousel-locked="isLocked">
<li ng-repeat="slide in slides3 track by slide.id">
<div ng-style="{'background-image': 'url(' + slide.img + ')'}" class="bgimage">
#{{ slide.id }}
</div>
</li>
</ul>
</div>
</div>
<br>
<div>
<h3>Add/Remove items in the collection</h3>
<div class="details">
The carousel is bound to your ngRepeat collection.<br>
If you add items at the start of the collection, then by default, the slide position will change.<br>
If you want to preserve position even when adding items at the head of the collection, you need to add the `rn-carousel-deep-watch` attribute. This has a performance impact so use carefully.<br>
Works great with buffering too so you can have almost infinite slides while keeping only 5 items in the DOM<br>
</div>
<div class="carousel-demo" >
<button ng-click="addSlide('head')">Add at beginning</button>
<button ng-click="addSlide('tail')">Add at end</button>
<ul rn-carousel rn-carousel-index="carouselIndex6" rn-carousel-deep-watch rn-carousel-buffered class="carousel5">
<li ng-repeat="slide in slides6 track by slide.id">
<div ng-style="{'background-image': 'url(' + slide.img + ')'}" class="bgimage">
#{{ slide.id }}
</div>
</li>
</ul>
<div rn-carousel-indicators ng-if="slides6.length > 1" slides="slides6" rn-carousel-index="carouselIndex6"></div>
</div>
</div>
</div>
<p> </p>
<p> </p>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular-touch.min.js"></script>
<script src="./dist/angular-carousel.min.js"></script>
<!--<script src="./src/angular-carousel.js"></script>
<script src="./src/directives/rn-carousel.js"></script>
<script src="./src/directives/rn-carousel-indicators.js"></script>
<script src="./src/directives/sliceFilter.js"></script>
<script src="./src/directives/shifty.js"></script>
-->
<script>
angular.module('DemoApp', [
'angular-carousel'
])
.controller('DemoCtrl', function($scope) {
$scope.colors = ["#fc0003", "#f70008", "#f2000d", "#ed0012", "#e80017", "#e3001c", "#de0021", "#d90026", "#d4002b", "#cf0030", "#c90036", "#c4003b", "#bf0040", "#ba0045", "#b5004a", "#b0004f", "#ab0054", "#a60059", "#a1005e", "#9c0063", "#960069", "#91006e", "#8c0073", "#870078", "#82007d", "#7d0082", "#780087", "#73008c", "#6e0091", "#690096", "#63009c", "#5e00a1", "#5900a6", "#5400ab", "#4f00b0", "#4a00b5", "#4500ba", "#4000bf", "#3b00c4", "#3600c9", "#3000cf", "#2b00d4", "#2600d9", "#2100de", "#1c00e3", "#1700e8", "#1200ed", "#0d00f2", "#0800f7", "#0300fc"];
function getSlide(target, style) {
var i = target.length;
return {
id: (i + 1),
label: 'slide #' + (i + 1),
img: 'http://lorempixel.com/450/300/' + style + '/' + ((i + 1) % 10) ,
color: $scope.colors[ (i*10) % $scope.colors.length],
odd: (i % 2 === 0)
};
}
function addSlide(target, style) {
target.push(getSlide(target, style));
};
$scope.carouselIndex = 3;
$scope.carouselIndex2 = 0;
$scope.carouselIndex2 = 1;
$scope.carouselIndex3 = 5;
$scope.carouselIndex4 = 5;
function addSlides(target, style, qty) {
for (var i=0; i < qty; i++) {
addSlide(target, style);
}
}
// 1st ngRepeat demo
$scope.slides = [];
addSlides($scope.slides, 'sports', 50);
// 2nd ngRepeat demo
$scope.slides2 = [];
addSlides($scope.slides2, 'sports', 10);
// 3rd ngRepeat demo
$scope.slides3 = [];
addSlides($scope.slides3, 'people', 50);
// 4th ngRepeat demo
$scope.slides4 = [];
addSlides($scope.slides4, 'city', 50);
// 5th ngRepeat demo
$scope.slides6 = [];
$scope.carouselIndex6 = 0;
addSlides($scope.slides6, 'sports', 10);
$scope.addSlide = function(at) {
if(at==='head') {
$scope.slides6.unshift(getSlide($scope.slides6, 'people'));
} else {
$scope.slides6.push(getSlide($scope.slides6, 'people'));
}
}
})
</script>
</html>