akiran / akiran/react-slick

With infinite:true and centerMode:true, when swiping make a complete tour the first slide becomes the selected slide

Aperta
#1,600 2 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
11.9k
Fork
2.1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Let's say I have a carousel with 5 slide, `centerMode = true`, `infinite = true` and `swipeToSlide = true`.
I'm currently at slide 3, I swipe to the right, pass beyond the first slide (slide 0) and stop above slide 2.

**Expected behaviour**: slider stops at slide 2.
**Current behaviour**: slider moves to slide 0.

You can verify this behaviour with the [official Multiple Rows example](https://react-slick.neostack.com/docs/example/multiple-rows).

Checking the code it doesn't looks like a bug, you can see in [/utils/innerSliderUtils.js](https://github.com/akiran/react-slick/blob/640ce007ab0a1764203aae3f5b21c95d7e65250b/src/utils/innerSliderUtils.js#L201)
```js
} else if (centerMode && animationSlide >= slideCount) {
animationSlide = infinite ? slideCount : slideCount - 1;
finalSlide = infinite ? 0 : slideCount - 1;
```

Is this a correct behaviour? This doesn't happens If `centerMode = false` or I'm swiping in left direction.

In my opinion it should be:
```js
} else if (centerMode && animationSlide >= slideCount) {
animationSlide = infinite ? animationSlide : slideCount - 1;
finalSlide = infinite ? animationSlide%slideCount : slideCount - 1;
```

Or there is a particular reason why it does that? I did some test and I don't see any side effect with this change.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.