Twitter Bootstrap Carousel - access current index
Instead of adding and subtracting from the current slide, try this on the 'slide' event:
$('.carousel').on('slide',function(e){
var slideFrom = $(this).find('.active').index();
var slideTo = $(e.relatedTarget).index();
console.log(slideFrom+' => '+slideTo);
});
It appears Bootstrap 4 finally has the native implementation of this.
https://github.com/twbs/bootstrap/pull/21668
$('#myCarousel').on('slide.bs.carousel', function(e){
e.direction // The direction in which the carousel is sliding (either "left" or "right").
e.relatedTarget // The DOM element that is being slid into place as the active item.
e.from // The index of the current item.
e.to // The index of the next item.
});
This worked for me (Bootstrap 3)
$("#myCarousel").on('slide.bs.carousel', function(evt) {
console.debug("slide transition started")
console.debug('current slide = ', $(this).find('.active').index())
console.debug('next slide = ', $(evt.relatedTarget).index())
})