@@ -22,28 +22,33 @@ angular.module('ui.bootstrap.carousel', [])
22
22
if ( direction === undefined ) {
23
23
direction = nextIndex > self . getCurrentIndex ( ) ? 'next' : 'prev' ;
24
24
}
25
- if ( nextSlide && nextSlide !== self . currentSlide ) {
26
- goNext ( ) ;
25
+ //Prevent this user-triggered transition from occurring if there is already one in progress
26
+ if ( nextSlide && nextSlide !== self . currentSlide && ! $scope . $currentTransition ) {
27
+ goNext ( nextSlide , nextIndex , direction ) ;
27
28
}
28
- function goNext ( ) {
29
- // Scope has been destroyed, stop here.
30
- if ( destroyed ) { return ; }
29
+ } ;
31
30
32
- angular . extend ( nextSlide , { direction : direction , active : true } ) ;
33
- angular . extend ( self . currentSlide || { } , { direction : direction , active : false } ) ;
34
- if ( $animate . enabled ( ) && ! $scope . noTransition && nextSlide . $element ) {
35
- $scope . $currentTransition = true ;
36
- nextSlide . $element . one ( '$animate:close' , function closeFn ( ) {
37
- $scope . $currentTransition = null ;
38
- } ) ;
39
- }
31
+ function goNext ( slide , index , direction ) {
32
+ // Scope has been destroyed, stop here.
33
+ if ( destroyed ) { return ; }
40
34
41
- self . currentSlide = nextSlide ;
42
- currentIndex = nextIndex ;
43
- //every time you change slides, reset the timer
44
- restartTimer ( ) ;
35
+ angular . extend ( slide , { direction : direction , active : true } ) ;
36
+ angular . extend ( self . currentSlide || { } , { direction : direction , active : false } ) ;
37
+ if ( $animate . enabled ( ) && ! $scope . noTransition && ! $scope . $currentTransition &&
38
+ slide . $element ) {
39
+ $scope . $currentTransition = true ;
40
+ slide . $element . one ( '$animate:close' , function closeFn ( ) {
41
+ $scope . $currentTransition = null ;
42
+ } ) ;
45
43
}
46
- } ;
44
+
45
+ self . currentSlide = slide ;
46
+ currentIndex = index ;
47
+
48
+ //every time you change slides, reset the timer
49
+ restartTimer ( ) ;
50
+ }
51
+
47
52
$scope . $on ( '$destroy' , function ( ) {
48
53
destroyed = true ;
49
54
} ) ;
@@ -75,19 +80,13 @@ angular.module('ui.bootstrap.carousel', [])
75
80
$scope . next = function ( ) {
76
81
var newIndex = ( self . getCurrentIndex ( ) + 1 ) % slides . length ;
77
82
78
- //Prevent this user-triggered transition from occurring if there is already one in progress
79
- if ( ! $scope . $currentTransition ) {
80
- return self . select ( getSlideByIndex ( newIndex ) , 'next' ) ;
81
- }
83
+ return self . select ( getSlideByIndex ( newIndex ) , 'next' ) ;
82
84
} ;
83
85
84
86
$scope . prev = function ( ) {
85
87
var newIndex = self . getCurrentIndex ( ) - 1 < 0 ? slides . length - 1 : self . getCurrentIndex ( ) - 1 ;
86
88
87
- //Prevent this user-triggered transition from occurring if there is already one in progress
88
- if ( ! $scope . $currentTransition ) {
89
- return self . select ( getSlideByIndex ( newIndex ) , 'prev' ) ;
90
- }
89
+ return self . select ( getSlideByIndex ( newIndex ) , 'prev' ) ;
91
90
} ;
92
91
93
92
$scope . isActive = function ( slide ) {
0 commit comments