diff --git a/README.md b/README.md
index d017aba..71b0ec5 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# angular-carousel.js 1.2.0
+# angular-carousel.js 1.2.1
A simple very generic AngularJS carousel. Features:
diff --git a/angular-carousel.css b/angular-carousel.css
index 7e6de0a..fb9b856 100644
--- a/angular-carousel.css
+++ b/angular-carousel.css
@@ -1,5 +1,5 @@
-/**
- * @license AngularJS v1.2.0
+/*!
+ * @license AngularJS v1.2.1
* (c) 2015 Lifely
* License: MIT
*/
diff --git a/angular-carousel.js b/angular-carousel.js
index 6dbc9b5..284d869 100644
--- a/angular-carousel.js
+++ b/angular-carousel.js
@@ -1,5 +1,5 @@
/**
- * @license AngularJS v1.2.0
+ * @license AngularJS v1.2.1
* (c) 2015 Lifely
* License: MIT
*/
@@ -216,82 +216,84 @@ angular.module('angular-carousel', [])
removeOldVirtualSlides();
slides = element.find('slide');
- // Add slides before and after the current slides
- if(slides.length > 0) {
+ // Create new carousel and duplicate slides
+ name = attrs.ngCarouselName;
+ currentCarousel = Carousel.add(slides.length, attrs.ngCarouselName, scope, {
+ looping: looping
+ });
+ angular.forEach(savedCallbacks, function(savedCallback) {
+ currentCarousel.onSlideChange(savedCallback);
+ currentCarousel.unbindOnSlideChangeCallback(0);
+ });
- // Create new carousel and duplicate slides
- name = attrs.ngCarouselName;
- currentCarousel = Carousel.add(slides.length, attrs.ngCarouselName, scope, {
- looping: looping
- });
- angular.forEach(savedCallbacks, function(savedCallback) {
- currentCarousel.onSlideChange(savedCallback);
- currentCarousel.unbindOnSlideChangeCallback(0);
- });
+ // Duplicate first and last slide (for infinite effect)
+ var refreshVirtualSlides = function() {
+ removeOldVirtualSlides();
- // Duplicate first and last slide (for infinite effect)
- var refreshVirtualSlides = function() {
- removeOldVirtualSlides();
- slides = element.find('slide');
+ if(slides.length < 1){
+ return;
+ }
- if(looping) {
- copyFirstAndLastSlide();
- }
- else {
- makeFirstAndLastSlideEmpty();
- }
+ slides = element.find('slide');
- firstSlideCopy.addClass('carousel-slide-copy');
- lastSlideCopy.addClass('carousel-slide-copy');
- slideContainer.append(firstSlideCopy);
- slideContainer.prepend(lastSlideCopy);
- slideContainer.addClass('carousel-ignore-first-slide');
+ if(looping) {
+ copyFirstAndLastSlide();
+ }
+ else {
+ makeFirstAndLastSlideEmpty();
+ }
- };
+ firstSlideCopy.addClass('carousel-slide-copy');
+ lastSlideCopy.addClass('carousel-slide-copy');
+ slideContainer.append(firstSlideCopy);
+ slideContainer.prepend(lastSlideCopy);
+ slideContainer.addClass('carousel-ignore-first-slide');
- refreshVirtualSlides();
+ };
+
+ refreshVirtualSlides();
- // On slide change, move the slideContainer
- var onSlideChangeCallback = function(slideIndex, wrapping) {
- var newSlideIndex = slideIndex + 1; // because the first slide doesn't count
+ // On slide change, move the slideContainer
+ var onSlideChangeCallback = function(slideIndex, wrapping) {
+ var newSlideIndex = slideIndex + 1; // because the first slide doesn't count
+ if(wrapping === 'left') {
+ newSlideIndex = 0; // first slide
+ } else if(wrapping === 'right') {
+ newSlideIndex = slides.length + 1; // last slide
+ }
+
+ move(newSlideIndex, true, function() {
if(wrapping === 'left') {
- newSlideIndex = 0; // first slide
+ move(slides.length, false);
} else if(wrapping === 'right') {
- newSlideIndex = slides.length + 1; // last slide
+ move(1, false);
}
+ });
+
+ setNextSlideTimeout();
+ refreshVirtualSlides();
+ };
- move(newSlideIndex, true, function() {
- if(wrapping === 'left') {
- move(slides.length, false);
- } else if(wrapping === 'right') {
- move(1, false);
- }
- });
-
- setNextSlideTimeout();
- refreshVirtualSlides();
- };
+ if(currentCarousel.onSlideChange){
currentCarousel.onSlideChange(onSlideChangeCallback);
+ }
- // If new slide was out of range, move to the new assigned one
- if(savedSlideIndex !== false && currentCarousel.currentSlide !== savedSlideIndex) {
- onSlideChangeCallback(currentCarousel.currentSlide, false);
- currentCarousel.toIndex(savedSlideIndex);
- }
+ // If new slide was out of range, move to the new assigned one
+ if(savedSlideIndex !== false && currentCarousel.currentSlide !== savedSlideIndex) {
+ onSlideChangeCallback(currentCarousel.currentSlide, false);
+ currentCarousel.toIndex(savedSlideIndex);
+ }
- // Option: random
- if(random) {
- var randomSlide = Math.floor(Math.random() * currentCarousel.slidesCount);
- currentCarousel.toIndex(randomSlide);
- }
+ // Option: random
+ if(random) {
+ var randomSlide = Math.floor(Math.random() * currentCarousel.slidesCount);
+ currentCarousel.toIndex(randomSlide);
+ }
- // Option: interval
- if (interval && currentCarousel.slidesCount >= 2) {
- setNextSlideTimeout();
- }
- } else {
- console.log('ng-carousel error: No slides found')
+ // Option: interval
+ if (interval && currentCarousel.slidesCount >= 2) {
+ setNextSlideTimeout();
}
// Initialize Hammer
diff --git a/angular-carousel.min.css b/angular-carousel.min.css
index 95fc4a8..cb6cc21 100644
--- a/angular-carousel.min.css
+++ b/angular-carousel.min.css
@@ -1,6 +1,5 @@
-/**
- * @license AngularJS v1.2.0
+/*!
+ * @license AngularJS v1.2.1
* (c) 2015 Lifely
* License: MIT
- */
-.ng-carousel{display:block;width:100%;height:300px;white-space:nowrap;position:relative;overflow:hidden}.ng-carousel slidecontainer{display:block;position:absolute;top:0;width:100%;height:100%;z-index:1;font-size:0}.ng-carousel slidecontainer.carousel-ignore-first-slide{-webkit-transform:translate(-100%,0);-moz-transform:translate(-100%,0);-o-transform:translate(-100%,0);-ms-transform:translate(-100%,0);transform:translate(-100%,0)}.ng-carousel slidecontainer.carousel-animate{-webkit-transition:-webkit-transform .5s ease-out 0s;-moz-transition:-moz-transform .5s ease-out 0s;-ms-transition:-ms-transform .5s ease-out 0s;-o-transition:-o-transform .5s ease-out 0s;transition:transform .5s ease-out 0s}.ng-carousel slide{position:relative;display:inline-block;vertical-align:top;font-size:16px;width:100%;height:100%;-webkit-background-size:cover;background-size:cover;background-position:center}.ng-carousel .carousel-arrow{display:inline-block;position:absolute;top:0;bottom:0;z-index:1;width:100px;text-align:center}.ng-carousel .carousel-arrow.carousel-arrow-left{left:0}.ng-carousel .carousel-arrow.carousel-arrow-right{right:0}
+ */.ng-carousel{display:block;width:100%;height:300px;white-space:nowrap;position:relative;overflow:hidden}.ng-carousel slidecontainer{display:block;position:absolute;top:0;width:100%;height:100%;z-index:1;font-size:0}.ng-carousel slidecontainer.carousel-ignore-first-slide{-webkit-transform:translate(-100%,0);-moz-transform:translate(-100%,0);-o-transform:translate(-100%,0);-ms-transform:translate(-100%,0);transform:translate(-100%,0)}.ng-carousel slidecontainer.carousel-animate{-webkit-transition:-webkit-transform .5s ease-out 0s;-moz-transition:-moz-transform .5s ease-out 0s;-ms-transition:-ms-transform .5s ease-out 0s;-o-transition:-o-transform .5s ease-out 0s;transition:transform .5s ease-out 0s}.ng-carousel slide{position:relative;display:inline-block;vertical-align:top;font-size:16px;width:100%;height:100%;-webkit-background-size:cover;background-size:cover;background-position:center}.ng-carousel .carousel-arrow{display:inline-block;position:absolute;top:0;bottom:0;z-index:1;width:100px;text-align:center}.ng-carousel .carousel-arrow.carousel-arrow-left{left:0}.ng-carousel .carousel-arrow.carousel-arrow-right{right:0}
\ No newline at end of file
diff --git a/angular-carousel.min.js b/angular-carousel.min.js
index 78764ec..0baaf09 100644
--- a/angular-carousel.min.js
+++ b/angular-carousel.min.js
@@ -1,6 +1,6 @@
/**
- * @license AngularJS v1.2.0
+ * @license AngularJS v1.2.1
* (c) 2015 Lifely
* License: MIT
*/
-angular.module("angular-carousel",[]).factory("Carousel",function(){var n={};n.instances={},n.add=function(o,t,i,a){if(t=t||!1,!t)return"Error: no carousel name specified";o=o||0;var r=n.instances[t]||!1;if(r)return"Error: carousel instance already exists";var s=new e(o,i,a);return n.instances[t]=s,s},n.get=function(e){var o=n.instances[e]||!1;return o?o:"Error: carousel with name '"+e+"' does not exist"},n.remove=function(e){delete n.instances[e]};var e=function(n,e,o){o=o||{},"undefined"==typeof o.looping&&(o.looping=!0);var t=this;this.slidesCount=n,this.currentSlide=0,this.onSlideChangeCallbacks=[],this.toIndex=function(n,o){o=o||!1,this.currentSlide=n%this.slidesCount,angular.forEach(this.onSlideChangeCallbacks,function(n){"function"==typeof n&&n(t.currentSlide,o)}),setTimeout(function(){e.$apply()},0)},this.next=function(){var n=this.currentSlide+1,e=!1;return n>this.slidesCount-1&&(o.looping?(n=0,e="right"):n=this.slidesCount-1),this.toIndex(n,e),n},this.previous=function(){var n=this.currentSlide-1,e=!1;return 0>n&&(o.looping?(n=this.slidesCount-1,e="left"):n=0),this.toIndex(n,e),n},this.onSlideChange=function(n){return this.onSlideChangeCallbacks.push(n),this.onSlideChangeCallbacks.indexOf(n)},this.unbindOnSlideChangeCallback=function(n){"undefined"!=typeof this.onSlideChangeCallbacks[n]&&this.onSlideChangeCallbacks.splice(n,1)}};return n}).directive("ngCarousel",["Carousel","$compile","$document","$timeout",function(n,e,o,t){function i(){return"ontouchstart"in document.documentElement}var a=25;return{restrict:"AE",replace:!0,scope:{ngCarouselWatch:"="},link:function(e,r,s){function l(){p=angular.element(C[0].outerHTML),v=angular.element(C[C.length-1].outerHTML)}function u(){p=angular.element('
+ + + +
+ +