This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 3 files changed +42
-2
lines changed
3 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,14 @@ angular.module('ui.bootstrap.carousel', [])
123
123
return $scope . active === slide . slide . index ;
124
124
} ;
125
125
126
+ $scope . isPrevDisabled = function ( ) {
127
+ return $scope . active === 0 && $scope . noWrap ( ) ;
128
+ } ;
129
+
130
+ $scope . isNextDisabled = function ( ) {
131
+ return $scope . active === slides . length - 1 && $scope . noWrap ( ) ;
132
+ } ;
133
+
126
134
$scope . pause = function ( ) {
127
135
if ( ! $scope . noPause ) {
128
136
isPlaying = false ;
Original file line number Diff line number Diff line change @@ -163,6 +163,38 @@ describe('carousel', function() {
163
163
expect ( navPrev . length ) . toBe ( 0 ) ;
164
164
} ) ;
165
165
166
+ it ( 'should disable prev button when slide index is 0 and noWrap is truthy' , function ( ) {
167
+ scope . $apply ( ) ;
168
+
169
+ var $scope = elm . isolateScope ( ) ;
170
+ $scope . noWrap = function ( ) { return true ; } ;
171
+
172
+ $scope . isPrevDisabled ( ) ;
173
+ scope . $apply ( ) ;
174
+
175
+ var navPrev = elm . find ( 'a.left' ) ;
176
+ expect ( navPrev . hasClass ( 'disabled' ) ) . toBe ( true ) ;
177
+ } ) ;
178
+
179
+ it ( 'should disable next button when last slide is active and noWrap is truthy' , function ( ) {
180
+ scope . slides = [
181
+ { content : 'one' , index : 0 } ,
182
+ { content : 'two' , index : 1 }
183
+ ] ;
184
+
185
+ scope . $apply ( ) ;
186
+
187
+ var $scope = elm . isolateScope ( ) ;
188
+ $scope . noWrap = function ( ) { return true ; } ;
189
+ $scope . next ( ) ;
190
+
191
+ $scope . isNextDisabled ( ) ;
192
+ scope . $apply ( ) ;
193
+
194
+ var navNext = elm . find ( 'a.right' ) ;
195
+ expect ( navNext . hasClass ( 'disabled' ) ) . toBe ( true ) ;
196
+ } ) ;
197
+
166
198
it ( 'should show navigation when there are 3 slides' , function ( ) {
167
199
var indicators = elm . find ( 'ol.carousel-indicators > li' ) ;
168
200
expect ( indicators . length ) . not . toBe ( 0 ) ;
Original file line number Diff line number Diff line change 1
1
< div ng-mouseenter ="pause() " ng-mouseleave ="play() " class ="carousel " ng-swipe-right ="prev() " ng-swipe-left ="next() ">
2
2
< div class ="carousel-inner " ng-transclude > </ div >
3
- < a role ="button " href class ="left carousel-control " ng-click ="prev() " ng-show ="slides.length > 1 ">
3
+ < a role ="button " href class ="left carousel-control " ng-click ="prev() " ng-class =" { disabled: isPrevDisabled() } " ng- show ="slides.length > 1 ">
4
4
< span aria-hidden ="true " class ="glyphicon glyphicon-chevron-left "> </ span >
5
5
< span class ="sr-only "> previous</ span >
6
6
</ a >
7
- < a role ="button " href class ="right carousel-control " ng-click ="next() " ng-show ="slides.length > 1 ">
7
+ < a role ="button " href class ="right carousel-control " ng-click ="next() " ng-class =" { disabled: isNextDisabled() } " ng- show ="slides.length > 1 ">
8
8
< span aria-hidden ="true " class ="glyphicon glyphicon-chevron-right "> </ span >
9
9
< span class ="sr-only "> next</ span >
10
10
</ a >
You can’t perform that action at this time.
0 commit comments