Skip to content
Open
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# angular-carousel.js 1.2.0
# angular-carousel.js 1.2.9

A simple very generic AngularJS carousel. Features:

Expand Down
31 changes: 21 additions & 10 deletions angular-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ angular.module('angular-carousel', [])
return 'ontouchstart' in document.documentElement;
}

var MOVE_TRESHOLD_PERCENTAGE = 25;
var MOVE_TRESHOLD_PERCENTAGE = 5;

function createEmptySlide(){
return angular.element('<slide class="empty"></slide>');
Expand All @@ -166,7 +166,8 @@ angular.module('angular-carousel', [])
restrict: 'AE',
replace: true,
scope: {
ngCarouselWatch: '='
ngCarouselWatch: '=',
ngCarousalNoDrag: '='
},
link: function(scope, element, attrs) {
// Options
Expand Down Expand Up @@ -271,8 +272,10 @@ angular.module('angular-carousel', [])

setNextSlideTimeout();
refreshVirtualSlides();
};
currentCarousel.onSlideChange(onSlideChangeCallback);
};
if(currentCarousel && currentCarousel.onSlideChange) {
currentCarousel.onSlideChange(onSlideChangeCallback);
}

// If new slide was out of range, move to the new assigned one
if(savedSlideIndex !== false && currentCarousel.currentSlide !== savedSlideIndex) {
Expand Down Expand Up @@ -301,7 +304,7 @@ angular.module('angular-carousel', [])

// On pan left/right
hammer.on("panleft panright", function(ev) {
if(!ev.isFinal) carouselDrag(ev.deltaX);
if(!ev.isFinal && attrs.ngCarousalNoDrag !== 'true') carouselDrag(ev.deltaX);
});
} else {
console.log('ng-carousel error: No slidecontainer found')
Expand Down Expand Up @@ -353,7 +356,9 @@ angular.module('angular-carousel', [])
move(currentCarousel.currentSlide + 1 - deltaXFactor, false);
};
var carouselPress = function() {
width = slideContainer[0].offsetWidth;
if(slideContainer && slideContainer[0]) {
width = slideContainer[0].offsetWidth;
}
};
var carouselRelease = function() {
if(Math.abs(deltaXFactor) > MOVE_TRESHOLD_PERCENTAGE / 100) {
Expand Down Expand Up @@ -396,11 +401,17 @@ angular.module('angular-carousel', [])
// Destroy all binded events on scope destroy
scope.$on('$destroy', function() {
$timeout.cancel(refreshInteractionWithDomTimer);
element.off('mouseover mouseout');
if(element) {
element.off('mouseover mouseout');
}
$document.off(pressEvent);
$document.off(releaseEvent);
slideContainer.off('transitionend oTransitionEnd webkitTransitionEnd');
currentCarousel.onSlideChangeCallbacks = [];
$document.off(releaseEvent);
if(slideContainer) {
slideContainer.off('transitionend oTransitionEnd webkitTransitionEnd');
}
if(currentCarousel && typeof currentCarousel === "object") {
currentCarousel.onSlideChangeCallbacks = [];
}
Carousel.remove(name);
});

Expand Down
6 changes: 3 additions & 3 deletions angular-carousel.min.js

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

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-carousel",
"description": "Touch-optimized carousel for Angular",
"version": "1.2.0",
"version": "1.2.2",
"keywords": [
"carousel",
"angular",
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-carousel",
"version": "1.2.0",
"version": "1.2.9",
"description": "Generic AngularJS carousel",
"main": "angular-carousel.js",
"scripts": {
Expand All @@ -20,10 +20,10 @@
"url": "https://github.com/lifelynl/angular-carousel/issues"
},
"devDependencies": {
"del": "^2.2.0",
"gulp": "^3.9.1",
"gulp-clean-css": "^2.0.3",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.3"
"del": "^6.0.0",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0",
"gulp-rename": "^2.0.0",
"gulp-uglify": "^3.0.2"
}
}