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

Commit

Permalink
fix(carousel): remove version checks
Browse files Browse the repository at this point in the history
- Make use of `$animateCss` directly since a shell service was introduced in Angular proper

Closes #4122
Closes #4774
  • Loading branch information
wesleycho committed Oct 30, 2015
1 parent 30099a0 commit 9d93af1
Showing 1 changed file with 16 additions and 45 deletions.
61 changes: 16 additions & 45 deletions src/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ angular.module('ui.bootstrap.carousel', [])
.controller('UibCarouselController', ['$scope', '$element', '$interval', '$animate', function($scope, $element, $interval, $animate) {
var self = this,
slides = self.slides = $scope.slides = [],
NEW_ANIMATE = angular.version.minor >= 4,
SLIDE_DIRECTION = 'uib-slideDirection',
currentIndex = -1,
currentInterval, isPlaying;
Expand Down Expand Up @@ -37,18 +36,12 @@ angular.module('ui.bootstrap.carousel', [])
}

$scope.$currentTransition = true;
if (NEW_ANIMATE) {
$animate.on('addClass', slide.$element, function(element, phase) {
if (phase === 'close') {
$scope.$currentTransition = null;
$animate.off('addClass', element);
}
});
} else {
slide.$element.one('$animate:close', function closeFn() {
$animate.on('addClass', slide.$element, function(element, phase) {
if (phase === 'close') {
$scope.$currentTransition = null;
});
}
$animate.off('addClass', element);
}
});
}

self.currentSlide = slide;
Expand Down Expand Up @@ -250,14 +243,9 @@ angular.module('ui.bootstrap.carousel', [])
})

.animation('.item', [
'$injector', '$animate',
function ($injector, $animate) {
var SLIDE_DIRECTION = 'uib-slideDirection',
$animateCss = null;

if ($injector.has('$animateCss')) {
$animateCss = $injector.get('$animateCss');
}
'$animate', '$animateCss',
function($animate, $animateCss) {
var SLIDE_DIRECTION = 'uib-slideDirection';

function removeClass(element, className, callback) {
element.removeClass(className);
Expand All @@ -277,20 +265,11 @@ function ($injector, $animate) {
directionClass + ' ' + direction, done);
element.addClass(direction);

if ($animateCss) {
$animateCss(element, {addClass: directionClass})
.start()
.done(removeClassFn);
} else {
$animate.addClass(element, directionClass).then(function () {
if (!stopped) {
removeClassFn();
}
done();
});
}
$animateCss(element, {addClass: directionClass})
.start()
.done(removeClassFn);

return function () {
return function() {
stopped = true;
};
}
Expand All @@ -304,18 +283,10 @@ function ($injector, $animate) {
var directionClass = direction == 'next' ? 'left' : 'right';
var removeClassFn = removeClass.bind(this, element, directionClass, done);

if ($animateCss) {
$animateCss(element, {addClass: directionClass})
.start()
.done(removeClassFn);
} else {
$animate.addClass(element, directionClass).then(function() {
if (!stopped) {
removeClassFn();
}
done();
});
}
$animateCss(element, {addClass: directionClass})
.start()
.done(removeClassFn);

return function() {
stopped = true;
};
Expand Down

0 comments on commit 9d93af1

Please sign in to comment.