akiran / akiran/react-slick

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

オープン
#1,600 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
11.9k
フォーク
2.1k
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。