A
A
Alex2020-04-17 06:44:31
JavaScript
Alex, 2020-04-17 06:44:31

How to move slides in swiper.js?

Good afternoon, there are sliders on page one should work so that part of the right slide is hidden behind the screen and when scrolling to the last one it should be fully shown and at the same time the left one that did not fit should be hidden behind the screen. Everything is fine if it were not for the indents that should be first on the left, then when scrolling to the end on the right (while it should no longer be on the left)

this is how it should usually look like:

5e99245477945065640968.png

and so when they reached the end

5e99249e1ac3c328402805.png

I tried to check if the last slide is visible on the change event and change the indents , but no event fires when scrolling to the half of the slide, that is, half of the last.

And the second question on another slider, is it possible to somehow center the slider with an even number of slides visible. (it turns out only with an odd number of centeredSlides) and at the same time, so that there would not be a huge space on the left and right if this is the first or last slide
5e9925e33a56c120731042.png

, everything worked here

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oaks, 2021-02-15
@oaksaudio

Put a non-integer value in:
Example 1

slidesPerView: 3.5 // Показать три с половиной слайда, как на примере 1

Then you will see half of the fourth slide. And also at the end the first one will be cut in half.
Example 2
slidesPerView:1.5,
centeredSlides: true,  //в связке с slidesPerView: 1.5 встанет как на примере 2

V
Vladimir, 2020-04-17
@HistoryART

You need to specify the number of visible slides and the number of flipped sliders in the swiper config.
click
Here we are interested in:

var swiper = new Swiper('.swiper-container', {
      slidesPerView: 3, // this
      slidesPerColumn: 1, // and this
      pagination: {
        el: '.swiper-pagination',
        clickable: true,
      },
    });

The first parameter is the number of visible slides, the second is how many visible areas to move, put auto in the first parameter and see what happens.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question