rcbyr / keen-slider

The HTML touch slider carousel with the most native feeling you will get.
https://keen-slider.io/
MIT License
4.57k stars 210 forks source link

Setting the slider when it has fewer slides than perView #380

Closed SzymonCU closed 8 months ago

SzymonCU commented 8 months ago

Hello, I have a slider that has different settings for different resolutions. Here is the code:

{
        loop: true,
        breakpoints: {
            "(max-width: 768px)": {
                slides: {perView: 2, spacing: 30},
            },
            "(max-width: 530px)": {
                slides: {perView: 1, spacing: 30},
            },
        },
        slides: {perView: 3, spacing: 30},
        defaultAnimation: {duration: 800},
    }

The problem occurs if I have <=3 slides. The slider should "stop being a slider" and should display, for example, 1, 2 or 3 slides but then there should be no autoplay and no ability to move slides.

However, if I have 3 slides but go below 768px resolution then the slider should work normally because I have 2 slides visible.

Is it possible to set the slider as I described above?

maxsplawski commented 8 months ago

I'm actually having the same issue, would really appreciate any answer on this 🙏

SzymonCU commented 8 months ago

Closed, I found a solution to this problem.