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 transition buffering
Browse files Browse the repository at this point in the history
- Remove transition buffering

Closes #6367
Fixes #5967
  • Loading branch information
tariqporter authored and wesleycho committed Jan 23, 2017
1 parent 47c4544 commit 86ee770
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions src/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ angular.module('ui.bootstrap.carousel', [])
slides = self.slides = $scope.slides = [],
SLIDE_DIRECTION = 'uib-slideDirection',
currentIndex = $scope.active,
currentInterval, isPlaying, bufferedTransitions = [];
currentInterval, isPlaying;

var destroyed = false;
$element.addClass('carousel');
Expand Down Expand Up @@ -67,11 +67,6 @@ angular.module('ui.bootstrap.carousel', [])
self.removeSlide = function(slide) {
var index = findSlideIndex(slide);

var bufferedIndex = bufferedTransitions.indexOf(slides[index]);
if (bufferedIndex !== -1) {
bufferedTransitions.splice(bufferedIndex, 1);
}

//get the index of the slide inside the carousel
slides.splice(index, 1);
if (slides.length > 0 && currentIndex === index) {
Expand All @@ -95,7 +90,6 @@ angular.module('ui.bootstrap.carousel', [])
if (slides.length === 0) {
currentIndex = null;
$scope.active = null;
clearBufferedTransitions();
}
};

Expand All @@ -110,8 +104,6 @@ angular.module('ui.bootstrap.carousel', [])
if (nextSlide.slide.index !== currentIndex &&
!$scope.$currentTransition) {
goNext(nextSlide.slide, nextIndex, direction);
} else if (nextSlide && nextSlide.slide.index !== currentIndex && $scope.$currentTransition) {
bufferedTransitions.push(slides[nextIndex]);
}
};

Expand Down Expand Up @@ -180,12 +172,6 @@ angular.module('ui.bootstrap.carousel', [])
}
});

function clearBufferedTransitions() {
while (bufferedTransitions.length) {
bufferedTransitions.shift();
}
}

function getSlideByIndex(index) {
for (var i = 0, l = slides.length; i < l; ++i) {
if (slides[i].index === index) {
Expand Down Expand Up @@ -221,14 +207,6 @@ angular.module('ui.bootstrap.carousel', [])
if (phase === 'close') {
$scope.$currentTransition = null;
$animate.off('addClass', element);
if (bufferedTransitions.length) {
var nextSlide = bufferedTransitions.pop().slide;
var nextIndex = nextSlide.index;
var nextDirection = nextIndex > self.getCurrentIndex() ? 'next' : 'prev';
clearBufferedTransitions();

goNext(nextSlide, nextIndex, nextDirection);
}
}
});
}
Expand Down Expand Up @@ -259,7 +237,6 @@ angular.module('ui.bootstrap.carousel', [])
function resetTransition(slides) {
if (!slides.length) {
$scope.$currentTransition = null;
clearBufferedTransitions();
}
}

Expand Down

0 comments on commit 86ee770

Please sign in to comment.