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

fix(carousel): change to avoid references to debug info #3795

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
*
*/
angular.module('ui.bootstrap.carousel', [])
.controller('CarouselController', ['$scope', '$interval', '$animate', function ($scope, $interval, $animate) {
.controller('CarouselController', ['$scope', '$element', '$interval', '$animate', function ($scope, $element, $interval, $animate) {
var self = this,
slides = self.slides = $scope.slides = [],
NO_TRANSITION = 'uib-noTransition',
SLIDE_DIRECTION = 'uib-slideDirection',
currentIndex = -1,
currentInterval, isPlaying;
self.currentSlide = null;
Expand All @@ -36,6 +38,7 @@ angular.module('ui.bootstrap.carousel', [])
angular.extend(self.currentSlide || {}, {direction: direction, active: false});
if ($animate.enabled() && !$scope.noTransition && !$scope.$currentTransition &&
slide.$element) {
slide.$element.data(SLIDE_DIRECTION, slide.direction);
$scope.$currentTransition = true;
slide.$element.one('$animate:close', function closeFn() {
$scope.$currentTransition = null;
Expand Down Expand Up @@ -167,6 +170,10 @@ angular.module('ui.bootstrap.carousel', [])
}
};

$scope.$watch('noTransition', function(noTransition) {
$element.data(NO_TRANSITION, noTransition);
});

}])

/**
Expand Down Expand Up @@ -295,13 +302,16 @@ function CarouselDemoCtrl($scope) {
.animation('.item', [
'$animate',
function ($animate) {
var NO_TRANSITION = 'uib-noTransition',
SLIDE_DIRECTION = 'uib-slideDirection';

return {
beforeAddClass: function (element, className, done) {
// Due to transclusion, noTransition property is on parent's scope
if (className == 'active' && element.parent() &&
!element.parent().scope().noTransition) {
!element.parent().data(NO_TRANSITION)) {
var stopped = false;
var direction = element.isolateScope().direction;
var direction = element.data(SLIDE_DIRECTION);
var directionClass = direction == 'next' ? 'left' : 'right';
element.addClass(direction);
$animate.addClass(element, directionClass).then(function () {
Expand All @@ -320,9 +330,9 @@ function ($animate) {
beforeRemoveClass: function (element, className, done) {
// Due to transclusion, noTransition property is on parent's scope
if (className == 'active' && element.parent() &&
!element.parent().scope().noTransition) {
!element.parent().data(NO_TRANSITION)) {
var stopped = false;
var direction = element.isolateScope().direction;
var direction = element.data(SLIDE_DIRECTION);
var directionClass = direction == 'next' ? 'left' : 'right';
$animate.addClass(element, directionClass).then(function () {
if (!stopped) {
Expand Down
2 changes: 1 addition & 1 deletion src/carousel/test/carousel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ describe('carousel', function() {

beforeEach(function() {
scope = $rootScope.$new();
ctrl = $controller('CarouselController', {$scope: scope, $element: null});
ctrl = $controller('CarouselController', {$scope: scope, $element: angular.element('<div></div>')});
for(var i = 0;i < slides.length;i++){
ctrl.addSlide(slides[i]);
}
Expand Down