Skip to content
This repository was archived by the owner on May 10, 2018. It is now read-only.

Commit 755d3c7

Browse files
committed
refactor(carousel): transitions refactor :
- single slide based transitions - externalize some services - use shifty.js for transitions - fix bunch of issues
1 parent 0ebcfd0 commit 755d3c7

16 files changed

+3943
-1330
lines changed

README.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Comments and contributions welcome :)
88

99
Proudly brought to you by the [@revolunet](http://twitter.com/revolunet) team.
1010

11-
**NOTE :** if you use IE<=9, iOS<7 or Android<4 please include the [requestAnimationFrame polyfill](https://github.com/darius/requestAnimationFrame/blob/master/requestAnimationFrame.js) in your application.
1211

1312
## Usage :
1413

@@ -28,7 +27,7 @@ angular.module('MyApp', ['angular-carousel']);
2827
- Add a `rn-carousel` attribute to your `<ul>` block and your `<li>`'s become magically swipable ;)
2928
```html
3029
<ul rn-carousel class="image">
31-
<li ng-repeat="image in sportImages" ng-style="{ backgroundImage: 'url(' + image + ')' }">
30+
<li ng-repeat="image in sportImages">
3231
<div class="layer">{{ image }}</div>
3332
</li>
3433
</ul>
@@ -43,27 +42,31 @@ angular.module('MyApp', ['angular-carousel']);
4342
</ul>
4443
```
4544

45+
## Directive options :
46+
- `rn-carousel-index` two way binding to control the carousel position (0-indexed)
47+
- `rn-carousel-buffered` add this attribute to enable the carousel buffering, good to minimize the DOM (5 slides)
48+
- `rn-carousel-controls` add this attribute to enable builtin prev/next buttons (you can override by CSS)
49+
- `rn-carousel-auto-slide` add this attribute to make the carousel slide automatically after given seconds (default=3)
50+
- `rn-carousel-transition` : transition type, can be one of `slide,zoom,hexagon,none,slideAndFade`. (default=slide)
4651

52+
## Indicators
4753

48-
## Features :
49-
- Mobile friendly, tested on webkit+firefox
50-
- Use CSS 3D transformations and `requestAnimationFrame`. (fallback to CSS 2D if 3D support not available)
51-
- DOM buffering
52-
- Index data-binding
53-
- Optional indicators
54+
You can add position indicators by adding this directive where you want :
55+
```html
56+
<div rn-carousel-indicators ng-if="slides.length > 1" slides="slides" rn-carousel-index="carouselIndex"></div>
57+
```
58+
- `slides` is the same collection you use in the carousel ng-repeat
59+
- `carouselIndex` is the same index you've defined for the carousel
5460

55-
### Regular carousel :
56-
- `rn-carousel-index` two way binding to control the carousel position.
57-
- `rn-carousel-indicator` boolean value to enable the indicator, see demo page.
58-
- `rn-carousel-buffered` boolean value to enable the carousel buffering, good to minimize the DOM, defaults to 5 slides. (works only with arrays)
59-
- `rn-carousel-swipe` boolean value to enable/disable swiping (default true)
60-
- `rn-carousel-control` boolean value to enable builtin prev/next buttons (you can override by CSS)
61-
- `rn-carousel-auto-slide` integer value will make the slider automatically change the visible slide after given seconds
62-
- `rn-carousel-pause-on-hover="true"` prevent auto-slide on hover
63-
- `rn-carousel-prevent-animation="true"` if you dont want animations
61+
## Notes :
62+
- if you use IE<=9, iOS<7 or Android<4 please include the [requestAnimationFrame polyfill](https://github.com/darius/requestAnimationFrame/blob/master/requestAnimationFrame.js) in your application.
63+
- don't set any style attribute to your li's. they would be overwritten by the carousel (use classes instead).
64+
- angular-carousel use the great [shifty.js](https://github.com/jeremyckahn/shifty) for the animations
6465

6566
## Todo :
66-
- see the [TODO file](./TODO)
67+
- customisable transitions
68+
- more transition types
69+
- infinite loop support
6770

6871
## Contributing
6972
- Please follow [AngularJS GIT conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#)

TODO

Lines changed: 0 additions & 38 deletions
This file was deleted.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angular-carousel",
33
"description": "Angular Carousel - Mobile friendly touch carousel for AngularJS",
4-
"version": "0.2.5",
4+
"version": "0.3.0",
55
"homepage": "http://revolunet.github.com/angular-carousel",
66
"author": "Julien Bouquillon <julien@revolunet.com>",
77
"repository": {

demo/demo.css

Lines changed: 26 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -22,110 +22,42 @@ h3 {
2222
font-size:30px;
2323
margin: 30px 0 10px 0;
2424
}
25-
.my-slider {
26-
width: 450px;
27-
height: 300px;
28-
font-size:0;
29-
}
30-
.my-slider li {
31-
box-sizing: border-box;
32-
font-size:30px;
33-
position:relative;
25+
26+
.center {
27+
text-align: center;
3428
}
35-
.my-slider li div.debug {
36-
box-sizing: border-box;
37-
position:absolute;
38-
bottom:0;
39-
height:50px;
40-
background:rgba(0,0,0,0.7);
29+
.bgimage {
30+
text-align:right;
4131
color:white;
42-
font-size:12px;
43-
width:100%;
44-
padding:5px;
32+
background-size:cover;
33+
height: 100%;
4534
}
46-
.my-slider.standard li {
47-
text-align:center;
48-
padding:20px;
49-
font-size:20px;
35+
36+
ul[rn-carousel] {
37+
width:400px;
38+
height:200px;
39+
margin: 0 auto;
5040
}
51-
.big {
52-
margin-top:30px;
41+
42+
.carousel5 li {
5343
width:100%;
44+
height:100%;
5445
font-size:30px;
46+
background-color: #ccc;
5547
}
56-
.controls {
57-
margin-top:5px;
58-
width:450px;
48+
49+
div.carousel-demo {
50+
margin-top:20px;
51+
display:inline-block;
5952
text-align: center;
6053
}
61-
.ng-cloak {
62-
display:none;
63-
}
64-
.center {
65-
text-align:center;
66-
}
67-
.thumbs {
68-
width:450px;
54+
55+
input.tiny {
56+
width:50px;
6957
text-align:center;
7058
}
71-
.thumb {
72-
display: inline-block;
73-
background-size:cover;
74-
border:1px solid transparent;
75-
margin:2px 4px;
76-
width:60px;
77-
height:40px;
78-
transition: border 0.2s ease-in;
79-
}
80-
.is-active {
81-
border:1px solid red;
82-
}
83-
.details {
84-
color:white;
85-
font-size:12px;
86-
margin-bottom:10px;
87-
}
88-
.button{
89-
display: inline-block;
90-
text-decoration: none;
91-
font: bold 12px/12px HelveticaNeue, Arial;
92-
padding: 8px 11px;
93-
color: #555;
94-
border: 1px solid #dedede;
95-
-webkit-border-radius: 3px;
96-
-moz-border-radius: 3px;
97-
border-radius: 3px;
98-
cursor:pointer;
99-
}
100-
.button:disabled {
101-
cursor: default !important;
102-
color: #aaa !important;
103-
}
104-
.button.grey{
105-
background: #bdbdbd;
106-
background: -webkit-gradient(linear, left top, left bottom, from(#cacaca), to(#aeaeae)); /* WebKit */
107-
background: -moz-linear-gradient(top, #cacaca, #aeaeae);
108-
border-color: #b5b5b5 #a1a1a1 #8f8f8f;
109-
color: #555;
110-
text-shadow: 0 1px 0 #d4d4d4;
111-
}
112-
.button.grey:hover{
113-
background: #c2c2c2;
114-
background: -webkit-gradient(linear, left top, left bottom, from(#bcbcbc), to(#c2c2c2)); /* WebKit */
115-
background: -moz-linear-gradient(top, #bcbcbc, #c2c2c2);
116-
border-color: #989898 #8e8e8e #878787;
117-
text-shadow: 0 1px 0 #dadada;
118-
}
11959

120-
/* override default controls */
121-
.rn-carousel-control {
122-
font-size:50px !important;
123-
color:white;
124-
opacity: 1;
125-
}
126-
.rn-carousel-control.rn-carousel-control-prev {
127-
left: 5px;
128-
}
129-
.rn-carousel-control.rn-carousel-control-next {
130-
right: 5px;
60+
61+
ul[rn-carousel-transition="hexagon"] {
62+
margin-left:100px;
13163
}

dist/angular-carousel.css

Lines changed: 41 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,58 @@
1-
/* variables */
2-
/* general */
3-
.rn-carousel-container {
1+
body {
2+
background: #ccc; }
3+
4+
input[type=range] {
5+
width: 300px; }
6+
7+
ul[rn-carousel] {
48
overflow: hidden;
9+
padding: 0;
10+
white-space: nowrap;
511
position: relative;
12+
-webkit-perspective: 1000px;
13+
-ms-perspective: 1000px;
14+
perspective: 1000px;
615
-ms-touch-action: none;
716
touch-action: none; }
17+
ul[rn-carousel] li {
18+
color: black;
19+
-webkit-backface-visibility: hidden;
20+
-ms-backface-visibility: hidden;
21+
backface-visibility: hidden;
22+
overflow: visible;
23+
vertical-align: top;
24+
position: absolute;
25+
left: 0;
26+
right: 0;
27+
white-space: normal;
28+
padding: 0;
29+
margin: 0;
30+
list-style-type: none;
31+
width: 100%;
32+
height: 100%;
33+
display: inline-block; }
834

9-
.rn-carousel-slides {
10-
-webkit-transform: translate3d(0, 0, 0);
11-
-ms-transform: translate3d(0, 0, 0);
12-
transform: translate3d(0, 0, 0);
13-
position: relative;
14-
white-space: nowrap;
15-
overflow: visible;
16-
padding: 0;
17-
margin: 0; }
35+
/* prevent flickering when moving buffer */
36+
ul[rn-carousel-buffered] li {
37+
display: none; }
1838

19-
/* IE 9 */
20-
:root .rn-carousel-slides {
21-
-webkit-transform: translate(0, 0);
22-
-ms-transform: translate(0, 0);
23-
transform: translate(0, 0);
24-
position: relative;
25-
white-space: nowrap;
26-
overflow: visible;
27-
padding: 0;
28-
margin: 0; }
29-
30-
.rn-carousel-slide {
31-
white-space: normal;
32-
vertical-align: top;
33-
display: inline-block;
34-
width: 100%;
35-
height: 100%;
36-
-webkit-backface-visibility: hidden;
37-
-ms-backface-visibility: hidden;
38-
backface-visibility: hidden; }
39+
ul[rn-carousel-transition="hexagon"] {
40+
overflow: visible; }
3941

4042
/* indicators */
41-
.rn-carousel-indicator {
42-
width: 100%;
43-
text-align: center;
44-
height: 20px;
45-
background-color: black;
46-
background-color: rgba(0, 0, 0, 0.6);
47-
position: relative;
48-
bottom: 0;
49-
cursor: pointer; }
50-
.rn-carousel-indicator span {
51-
-webkit-transition: color .2s ease-out;
52-
transition: color .2s ease-out;
53-
padding: 0 5px;
54-
color: #333; }
55-
.rn-carousel-indicator span:before {
56-
content: "\25cf"; }
57-
.rn-carousel-indicator span.ng-leave {
58-
-webkit-transition: none !important;
59-
transition: none !important; }
60-
.rn-carousel-indicator .active {
43+
div[rn-carousel-indicators] span {
44+
cursor: pointer;
45+
color: #666; }
46+
div[rn-carousel-indicators] span.active {
6147
color: white; }
6248

63-
/* controls */
49+
/* prev/next controls */
6450
.rn-carousel-control {
6551
-webkit-transition: opacity 0.2s ease-out;
6652
transition: opacity 0.2s ease-out;
67-
font-size: 30px;
53+
font-size: 2rem;
6854
position: absolute;
69-
top: 50%;
70-
margin-top: -35px;
55+
top: 40%;
7156
opacity: 0.75;
7257
cursor: pointer; }
7358
.rn-carousel-control:hover {

0 commit comments

Comments
 (0)