Skip to content

Incomplete Documentation: loop mode centeredSlides and slidesPerView behavior not described #8124

@y-hsgw

Description

@y-hsgw

Clear and concise description of the problem

As a developer using Swiper, I want the documentation for loop mode to state the correct minimum number of slides required when centeredSlides is enabled and slidesPerView is even, since Swiper's internal logic increases this number compared to what is currently documented.

Suggested solution

Update the documentation for Swiper loop mode (https://swiperjs.com/swiper-api#param-loop) to cover:

  • What happens when centeredSlides: true is used with loop mode.
  • The internal logic (found in src/core/loop/loopFix.mjs):

if (bothDirections && slidesPerView % 2 === 0) {
slidesPerView = slidesPerView + 1;
}

  • When using bothDirections (centeredSlides or slidesOffsetBefore/After), if slidesPerView is even, it will be incremented by 1 internally.
  • Implications for minimal required slide count, loopedSlides, or layouts.

This will help users anticipate possible layout issues or differences between configuration and the actual displayed result.

Alternative

No response

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Would you like to open a PR for this feature?

  • I'm willing to open a PR

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions