Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 38c1b14

Browse files
committed
fix(carousel): decouple animation information from DOM
- Change to use `$animate.enabled` to determine animation state Closes #4737 Fixes #4516
1 parent 8899fc8 commit 38c1b14

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/carousel/carousel.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ angular.module('ui.bootstrap.carousel', [])
44
var self = this,
55
slides = self.slides = $scope.slides = [],
66
NEW_ANIMATE = angular.version.minor >= 4,
7-
NO_TRANSITION = 'uib-noTransition',
87
SLIDE_DIRECTION = 'uib-slideDirection',
98
currentIndex = -1,
109
currentInterval, isPlaying;
@@ -200,7 +199,7 @@ angular.module('ui.bootstrap.carousel', [])
200199
};
201200

202201
$scope.$watch('noTransition', function(noTransition) {
203-
$element.data(NO_TRANSITION, noTransition);
202+
$animate.enabled($element, noTransition);
204203
});
205204

206205
}])
@@ -257,8 +256,7 @@ angular.module('ui.bootstrap.carousel', [])
257256
.animation('.item', [
258257
'$injector', '$animate',
259258
function ($injector, $animate) {
260-
var NO_TRANSITION = 'uib-noTransition',
261-
SLIDE_DIRECTION = 'uib-slideDirection',
259+
var SLIDE_DIRECTION = 'uib-slideDirection',
262260
$animateCss = null;
263261

264262
if ($injector.has('$animateCss')) {
@@ -276,7 +274,7 @@ function ($injector, $animate) {
276274
beforeAddClass: function(element, className, done) {
277275
// Due to transclusion, noTransition property is on parent's scope
278276
if (className == 'active' && element.parent() && element.parent().parent() &&
279-
!element.parent().parent().data(NO_TRANSITION)) {
277+
!$animate.enabled(element)) {
280278
var stopped = false;
281279
var direction = element.data(SLIDE_DIRECTION);
282280
var directionClass = direction == 'next' ? 'left' : 'right';
@@ -306,7 +304,7 @@ function ($injector, $animate) {
306304
beforeRemoveClass: function (element, className, done) {
307305
// Due to transclusion, noTransition property is on parent's scope
308306
if (className === 'active' && element.parent() && element.parent().parent() &&
309-
!element.parent().parent().data(NO_TRANSITION)) {
307+
!$animate.enabled(element)) {
310308
var stopped = false;
311309
var direction = element.data(SLIDE_DIRECTION);
312310
var directionClass = direction == 'next' ? 'left' : 'right';

0 commit comments

Comments
 (0)