This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 2 files changed +22
-6
lines changed
2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 5
5
* A pure AngularJS carousel.
6
6
*
7
7
* For no interval set the interval to non-number, or milliseconds of desired interval
8
- * Template: <carousel interval="none"><slide>{{anything}}</slide></carousel>
8
+ * To prevent pause upon mouseover set the nopause attribute to a truthy value
9
+ * Template: <carousel interval="none" nopause="someValue"><slide>{{anything}}</slide></carousel>
9
10
* To change the carousel's active slide set the active attribute to true
10
11
* Template: <carousel interval="none"><slide active="someModel">{{anything}}</slide></carousel>
11
12
*/
@@ -130,9 +131,11 @@ angular.module('ui.bootstrap.carousel', ['ui.bootstrap.transition'])
130
131
}
131
132
} ;
132
133
$scope . pause = function ( ) {
133
- isPlaying = false ;
134
- if ( currentTimeout ) {
135
- $timeout . cancel ( currentTimeout ) ;
134
+ if ( ! $scope . noPause ) {
135
+ isPlaying = false ;
136
+ if ( currentTimeout ) {
137
+ $timeout . cancel ( currentTimeout ) ;
138
+ }
136
139
}
137
140
} ;
138
141
@@ -173,7 +176,8 @@ angular.module('ui.bootstrap.carousel', ['ui.bootstrap.transition'])
173
176
templateUrl : 'template/carousel/carousel.html' ,
174
177
scope : {
175
178
interval : '=' ,
176
- noTransition : '='
179
+ noTransition : '=' ,
180
+ noPause : '='
177
181
}
178
182
} ;
179
183
} ] )
Original file line number Diff line number Diff line change @@ -20,14 +20,15 @@ describe('carousel', function() {
20
20
{ active :false , content :'three' }
21
21
] ;
22
22
elm = $compile (
23
- '<carousel interval="interval" no-transition="true">' +
23
+ '<carousel interval="interval" no-transition="true" no-pause="nopause" >' +
24
24
'<slide ng-repeat="slide in slides" active="slide.active">' +
25
25
'{{slide.content}}' +
26
26
'</slide>' +
27
27
'</carousel>'
28
28
) ( scope ) ;
29
29
carouselScope = elm . scope ( ) ;
30
30
scope . interval = 5000 ;
31
+ scope . nopause = undefined ;
31
32
scope . $apply ( ) ;
32
33
} ) ;
33
34
afterEach ( function ( ) {
@@ -178,6 +179,17 @@ describe('carousel', function() {
178
179
$timeout . flush ( ) ;
179
180
testSlideActive ( 2 ) ;
180
181
} ) ;
182
+
183
+ it ( 'should not pause on mouseover if noPause' , function ( ) {
184
+ scope . $apply ( 'nopause = true' ) ;
185
+ testSlideActive ( 0 ) ;
186
+ elm . trigger ( 'mouseenter' ) ;
187
+ $timeout . flush ( ) ;
188
+ testSlideActive ( 1 ) ;
189
+ elm . trigger ( 'mouseleave' ) ;
190
+ $timeout . flush ( ) ;
191
+ testSlideActive ( 2 ) ;
192
+ } ) ;
181
193
182
194
it ( 'should remove slide from dom and change active slide' , function ( ) {
183
195
scope . $apply ( 'slides[1].active = true' ) ;
You can’t perform that action at this time.
0 commit comments