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

Wrap option #383

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ angular.module('MyApp', ['angular-carousel']);
library](https://github.com/jeremyckahn/shifty/blob/master/src/shifty.formulas.js) (default=easeIn)
- `rn-carousel-duration`: add this attribute to set the duration of the transition (default=300)
- `rn-carousel-controls-allow-loop`: add this attribute to allow looping through slides from prev/next controls
- `rn-carousel-wrap`: Allows the carousel to loop from end to start (and vice versa) when sliding (default=true)

## Indicators

Expand Down
2 changes: 2 additions & 0 deletions dist/angular-carousel.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions dist/angular-carousel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Angular Carousel - Mobile friendly touch carousel for AngularJS
* @version v1.0.1 - 2015-11-16
* @version v1.0.1 - 2015-12-14
* @link http://revolunet.github.com/angular-carousel
* @author Julien Bouquillon <[email protected]>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down Expand Up @@ -263,6 +263,12 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach

carouselId++;

var wrap = scope.$eval(iAttributes.rnCarouselWrap);

if (!angular.isDefined(wrap)) {
wrap = true
}

var defaultOptions = {
transitionType: iAttributes.rnCarouselTransition || 'slide',
transitionEasing: iAttributes.rnCarouselEasing || 'easeTo',
Expand All @@ -272,7 +278,8 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
bufferSize: 5,
/* in container % how much we need to drag to trigger the slide change */
moveTreshold: 0.1,
defaultIndex: 0
defaultIndex: 0,
wrap: wrap
};

// TODO
Expand Down Expand Up @@ -331,7 +338,11 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
scope.nextSlide = function(slideOptions) {
var index = scope.carouselIndex + 1;
if (index > currentSlides.length - 1) {
index = 0;
if (options.wrap) {
index = 0;
} else {
index = scope.carouselIndex;
}
}
if (!locked) {
goToSlide(index, slideOptions);
Expand All @@ -341,7 +352,11 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
scope.prevSlide = function(slideOptions) {
var index = scope.carouselIndex - 1;
if (index < 0) {
index = currentSlides.length - 1;
if (options.wrap) {
index = currentSlides.length - 1;
} else {
index = scope.carouselIndex;
}
}
goToSlide(index, slideOptions);
};
Expand Down
Loading