7
7
*
8
8
*/
9
9
angular . module ( 'ui.bootstrap.carousel' , [ ] )
10
- . controller ( 'CarouselController' , [ '$scope' , '$interval' , '$animate' , function ( $scope , $interval , $animate ) {
10
+ . controller ( 'CarouselController' , [ '$scope' , '$element' , '$ interval', '$animate' , function ( $scope , $element , $interval , $animate ) {
11
11
var self = this ,
12
12
slides = self . slides = $scope . slides = [ ] ,
13
+ NO_TRANSITION = 'uib-noTransition' ,
14
+ SLIDE_DIRECTION = 'uib-slideDirection' ,
13
15
currentIndex = - 1 ,
14
16
currentInterval , isPlaying ;
15
17
self . currentSlide = null ;
@@ -36,6 +38,7 @@ angular.module('ui.bootstrap.carousel', [])
36
38
angular . extend ( self . currentSlide || { } , { direction : direction , active : false } ) ;
37
39
if ( $animate . enabled ( ) && ! $scope . noTransition && ! $scope . $currentTransition &&
38
40
slide . $element ) {
41
+ slide . $element . data ( SLIDE_DIRECTION , slide . direction ) ;
39
42
$scope . $currentTransition = true ;
40
43
slide . $element . one ( '$animate:close' , function closeFn ( ) {
41
44
$scope . $currentTransition = null ;
@@ -167,6 +170,10 @@ angular.module('ui.bootstrap.carousel', [])
167
170
}
168
171
} ;
169
172
173
+ $scope . $watch ( 'noTransition' , function ( noTransition ) {
174
+ $element . data ( NO_TRANSITION , noTransition ) ;
175
+ } ) ;
176
+
170
177
} ] )
171
178
172
179
/**
@@ -295,13 +302,16 @@ function CarouselDemoCtrl($scope) {
295
302
. animation ( '.item' , [
296
303
'$animate' ,
297
304
function ( $animate ) {
305
+ var NO_TRANSITION = 'uib-noTransition' ,
306
+ SLIDE_DIRECTION = 'uib-slideDirection' ;
307
+
298
308
return {
299
309
beforeAddClass : function ( element , className , done ) {
300
310
// Due to transclusion, noTransition property is on parent's scope
301
311
if ( className == 'active' && element . parent ( ) &&
302
- ! element . parent ( ) . scope ( ) . noTransition ) {
312
+ ! element . parent ( ) . data ( NO_TRANSITION ) ) {
303
313
var stopped = false ;
304
- var direction = element . isolateScope ( ) . direction ;
314
+ var direction = element . data ( SLIDE_DIRECTION ) ;
305
315
var directionClass = direction == 'next' ? 'left' : 'right' ;
306
316
element . addClass ( direction ) ;
307
317
$animate . addClass ( element , directionClass ) . then ( function ( ) {
@@ -320,9 +330,9 @@ function ($animate) {
320
330
beforeRemoveClass : function ( element , className , done ) {
321
331
// Due to transclusion, noTransition property is on parent's scope
322
332
if ( className == 'active' && element . parent ( ) &&
323
- ! element . parent ( ) . scope ( ) . noTransition ) {
333
+ ! element . parent ( ) . data ( NO_TRANSITION ) ) {
324
334
var stopped = false ;
325
- var direction = element . isolateScope ( ) . direction ;
335
+ var direction = element . data ( SLIDE_DIRECTION ) ;
326
336
var directionClass = direction == 'next' ? 'left' : 'right' ;
327
337
$animate . addClass ( element , directionClass ) . then ( function ( ) {
328
338
if ( ! stopped ) {
0 commit comments