Swiper: watchOverflow and loop

Created on 2 Dec 2018  路  4Comments  路  Source: nolimits4web/swiper

When you have one image/element/slide, watchOverflow: true hides the navigation and pagination as expected. However, if you also have loop: true (because you want it to loop in instances where there is more than one slide), watchOverflow no longer has any effect. I guess the watchOverflow calculation isn't done before the additional/duplicate slides are inserted for the loop effect.

Most helpful comment

Well, that is technically correct, but for example with only one slide, loop: true and slidesPerView: 3, I end up with 3 same slides, which is not what would the user expect, is it? It would be more practical to use the number of real slides for watchOverflow calculation, hide the navigation and do not generate the extra slides.
I am referring to the case when the number of slides is not known (e.g. they come from CMS) and slidesPerView changes with breakpoints.

All 4 comments

Everything is correct, because with loop you have more than one slide. Just don't enable loop if you don't need it in this case

Well, that is technically correct, but for example with only one slide, loop: true and slidesPerView: 3, I end up with 3 same slides, which is not what would the user expect, is it? It would be more practical to use the number of real slides for watchOverflow calculation, hide the navigation and do not generate the extra slides.
I am referring to the case when the number of slides is not known (e.g. they come from CMS) and slidesPerView changes with breakpoints.

This is a problem I am encountering. Is there a way to configure the swiper so when in loop mode the navigation is checked and if the number of slides is less than visible slide viewport looping is not necessary? The additional problem is when configured with loop mode and breakpoints that in a desktop mode navigation is not needed so no looping but when reduced to tablet then navigation is needed which would place it in loop mode as well.

This is a duplicate of #2621. So I think we can keep this one closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leone510es picture leone510es  路  3Comments

joakimk picture joakimk  路  3Comments

callumacrae picture callumacrae  路  3Comments

chansecampbell picture chansecampbell  路  3Comments

lxmarinkovic picture lxmarinkovic  路  4Comments