Swiper: Swiper activeIndex issue

Created on 17 May 2016  路  11Comments  路  Source: nolimits4web/swiper

Swiper activeIndex is not working properly on last-slide, On every callback function it returns second last slide activeIndex number.

I am using swiper 3.3.1 latest version with following code.

        $('.sw-' + index).swiper({
        nextButton: $(this).find('.swiper-button-next'),
        prevButton: $(this).find('.swiper-button-prev'),
        pagination: $(this).find('.swiper-pagination'),
        slidesPerView: 'auto',
        paginationClickable: true,
        spaceBetween: 10,

        onSlideChangeStart: function (swiper) {

            console.log('slidechangeStart: '+swiper.activeIndex);
        },
        onSlideChangeEnd: function (swiper) {

            console.log('slidechangeEnd: ' + swiper.activeIndex);
        },
        onTransitionEnd: function (swiper) {

            console.log('onTransitionEnd: ' + swiper.activeIndex);
        },
        onInit: function (swiper) {
            swiper.update(true);
        }
        });

Most helpful comment

So, How do I know the last slide appear ?

All 11 comments

I am getting issue only when slidesPerView : auto is there.
@nolimits4web can you resolve this issue.

With slides per view > 1, last slide may never become active as activeIndex depends on slider position, not on something else. It is by design

So, How do I know the last slide appear ?

So, How do I know the last slide appear ?

So, How do I know the last slide appear ?

With slidesPerView: 'auto' I solved it this way:

if(swiper.isEnd){
  swiper.activeIndex = (swiper.slides.length - 1);
}

// access swiper.activeIndex for whatever...

So, How do I know the last slide appear ?

So, How do I know the last slide appear ?

So, How do I know the last slide appear ?

So, How do I know the last slide appear ?

So, How do I know the last slide appear ?

Was this page helpful?
0 / 5 - 0 ratings