Skip to content
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
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
2 changes: 1 addition & 1 deletion 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.6",
"description": "Generic AngularJS carousel",
"main": "angular-carousel.js",
"scripts": {
Expand Down