diff --git a/README.md b/README.md index 96e834e..9c49a06 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,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-items-per-slide`: add this attribute to specify how many slides will slide on one click (used for multiple item slider) / default value "1" if not used ## Indicators diff --git a/dist/angular-carousel.css b/dist/angular-carousel.css index a11d852..8985d28 100755 --- a/dist/angular-carousel.css +++ b/dist/angular-carousel.css @@ -29,6 +29,12 @@ ul[rn-carousel] { height: 100%; display: inline-block; } +div.slides-per-click-demo ul[rn-carousel] { + width: 420px; + /* wrapper created a bit bigger to show that next slide is 'on its way' */ } + div.slides-per-click-demo ul[rn-carousel] > li { + width: 200px; } + /* prevent flickering when moving buffer */ ul[rn-carousel-buffered] > li { display: none; } @@ -43,6 +49,9 @@ div.rn-carousel-indicator span { div.rn-carousel-indicator span.active { color: white; } +div.demo-container > div { + position: relative; } + /* prev/next controls */ .rn-carousel-control { -webkit-transition: opacity 0.2s ease-out; @@ -62,3 +71,5 @@ div.rn-carousel-indicator span { right: 0.5em; } .rn-carousel-control.rn-carousel-control-next:before { content: ">"; } + +/*# sourceMappingURL=angular-carousel.css.map */ diff --git a/dist/angular-carousel.css.map b/dist/angular-carousel.css.map index 835dca7..8f53645 100644 --- a/dist/angular-carousel.css.map +++ b/dist/angular-carousel.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,iBAAkB;EAChB,KAAK,EAAC,KAAK;;AAGb,eAAgB;EACd,QAAQ,EAAC,MAAM;EACf,OAAO,EAAC,CAAC;EACT,WAAW,EAAE,MAAM;EACnB,QAAQ,EAAE,QAAQ;EAClB,WAAW,EAAC,MAAM;EAClB,gBAAgB,EAAE,KAAK;EACvB,YAAY,EAAE,KAAK;EACnB,oBAAK;IAC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AAQ;IACjB,IAAI,EAAC,CAAC;IACN,KAAK,EAAC,CAAC;IACP,WAAW,EAAE,MAAM;IACnB,OAAO,EAAC,CAAC;IACT,MAAM,EAAC,CAAC;IACR,eAAe,EAAC,IAAI;IACpB,KAAK,EAAC,IAAI;IACV,MAAM,EAAC,IAAI;IACX,OAAO,EAAC,YAAY;;AAKtB,yCAAgB;EACd,KAAK,EAAE,KAAK;;EACZ,8CAAK;IACH,KAAK,EAAE,KAAK;;;AAMlB,6BAA8B;EAC5B,OAAO,EAAC,IAAI;;AAGd,oCAAqC;EACnC,QAAQ,EAAC,OAAO;;;AAIlB,8BAA+B;EAC7B,MAAM,EAAC,OAAO;EACd,KAAK,EAAE,IAAI;EACX,qCAAS;IACP,KAAK,EAAE,KAAK;;AAIhB,wBAAyB;EACvB,QAAQ,EAAE,QAAQ;;;AAIpB,oBAAqB;EACnB,UAAU,EAAE,qBAAqB;EACjC,SAAS,EAAE,IAAI;EACf,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,GAAG;EACR,OAAO,EAAE,IAAI;EACb,MAAM,EAAE,OAAO;EACf,0BAAQ;IACN,OAAO,EAAE,CAAC;EAGZ,6CAA2B;IACzB,IAAI,EAAE,KAAK;IACX,oDAAS;MACP,OAAO,EAAE,GAAG;EAIhB,6CAA2B;IACzB,KAAK,EAAE,KAAK;IACZ,oDAAS;MACP,OAAO,EAAE,GAAG", "sources": ["../src/css/angular-carousel.scss"], "names": [], "file": "angular-carousel.css" diff --git a/dist/angular-carousel.js b/dist/angular-carousel.js index 58c9556..e4b90c6 100644 --- a/dist/angular-carousel.js +++ b/dist/angular-carousel.js @@ -1,6 +1,6 @@ /** * Angular Carousel - Mobile friendly touch carousel for AngularJS - * @version v0.3.13 - 2015-06-15 + * @version v0.3.13 - 2015-09-30 * @link http://revolunet.github.com/angular-carousel * @author Julien Bouquillon * @license MIT License, http://www.opensource.org/licenses/MIT @@ -292,7 +292,8 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach intialState = true, animating = false, mouseUpBound = false, - locked = false; + locked = false, + slidesPerClickLimit = parseInt(iAttributes.rnCarouselItemsPerSlide); //rn-swipe-disabled =true will only disable swipe events if(iAttributes.rnSwipeDisabled !== "true") { @@ -329,7 +330,12 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach } scope.nextSlide = function(slideOptions) { - var index = scope.carouselIndex + 1; + var index; + if(isNaN(slidesPerClickLimit) === false && currentSlides.length - scope.carouselIndex + slidesPerClickLimit >= slidesPerClickLimit && currentSlides.length/slidesPerClickLimit > 1) { + index = scope.carouselIndex + slidesPerClickLimit; + } else { + index = scope.carouselIndex + 1; + } if (index > currentSlides.length - 1) { index = 0; } @@ -339,7 +345,12 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach }; scope.prevSlide = function(slideOptions) { - var index = scope.carouselIndex - 1; + var index; + if(isNaN(slidesPerClickLimit) === false && currentSlides.length - scope.carouselIndex + slidesPerClickLimit >= slidesPerClickLimit && currentSlides.length/slidesPerClickLimit > 1) { + index = scope.carouselIndex - slidesPerClickLimit; + } else { + index = scope.carouselIndex - 1; + } if (index < 0) { index = currentSlides.length - 1; } @@ -453,8 +464,15 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach if (iAttributes.rnCarouselControls!==undefined) { // dont use a directive for this + var slidesCountInCurrent = isRepeatBased ? scope[repeatCollection.replace('::', '')].length : currentSlides.length; + var noneDividableCarouselItemCount = 1; + if(isNaN(slidesPerClickLimit) === false){ + noneDividableCarouselItemCount = (slidesCountInCurrent%slidesPerClickLimit !== 0 && slidesCountInCurrent/slidesPerClickLimit > 1) ? (slidesCountInCurrent%slidesPerClickLimit) : 1; + } else { + noneDividableCarouselItemCount = 1; + } var canloop = ((isRepeatBased ? scope[repeatCollection.replace('::', '')].length : currentSlides.length) > 1) ? angular.isDefined(tAttributes['rnCarouselControlsAllowLoop']) : false; - var nextSlideIndexCompareValue = isRepeatBased ? repeatCollection.replace('::', '') + '.length - 1' : currentSlides.length - 1; + var nextSlideIndexCompareValue = isRepeatBased ? repeatCollection.replace('::', '') + '.length - ' + noneDividableCarouselItemCount.toString() : currentSlides.length - 1; var tpl = ' -
+

Buffered ngRepeat demo

A simple buffered ng-repeat with a custom template. @@ -37,6 +37,24 @@

Buffered ngRepeat demo

+
+
+

Buffered ngRepeat demo with Slides per click enabled

+
A simple buffered ng-repeat with a custom template. +
+ Swipe 50 slides with only 5 slides in the DOM. use builtin controls +
+ +

buffered ngRepeat with auto-slide(pause on hover) and builtin indicators

@@ -155,7 +173,7 @@

End to End Swiping