FormidableLabs / nuka-carousel

Small, fast, and accessibility-first React carousel library with an easily customizable UI and behavior to fit your brand and site.
https://commerce.nearform.com/open-source/nuka-carousel
Other
3.06k stars 593 forks source link

fix: Correct number and indices of dots in remainder scrollMode #941

Closed fritz-c closed 2 years ago

fritz-c commented 2 years ago

Description

Previously, when slidesToScroll was set to a value larger than 1 with scrollMode set to "remainder", the dots shown were missing the last one. In the case of fractional slidesToShow values, the index of the last dot was also incorrect.

image
Example: 2 dots, not the expected 3, shown for 5 slides with slidesToScroll={2} Demo link

This PR fixes both these issues and adds a few unit tests to double-check the function that generates the dot indices.

Type of Change

How Has This Been Tested?

I created unit tests that passed a variety of parameters to the getDotIndexes function to test that it returned indices as expected.

The issue can be reproduced by looking at the dots versus the button behavior with this issue example.

vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nuka-carousel ✅ Ready (Inspect) Visit Preview Sep 2, 2022 at 3:34PM (UTC)