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
3k stars 596 forks source link

v5 scroll to end results in whitespace #1002

Closed joekur closed 2 months ago

joekur commented 1 year ago

Bugs and Questions

Describe Your Environment

Describe the Problem

Previously in v4, when using slidesToScroll="auto", scrolling to the end of the slides would align the last slide with the right edge of the carousel, leaving no extra whitespace:

Screen Shot 2023-03-20 at 12 55 30 PM

Link to the sandbox

In v5 however, scrolling to the end of the carousel can leave the last slide with whitespace to its right, despite the docs stating that:

Set scrollMode="remainder" if you don't want to see the white space when you scroll to the end of a non-infinite carousel.

Screen Shot 2023-03-20 at 12 54 42 PM

Link to the sandbox

Expected behavior:

Scrolling to the end of slides aligns the final slide to the right side of the carousel.

Actual behavior

Scrolling to the end of the slides leaves whitespace to the right of the final slide.

Additional Information

I noticed some other changes, potentially bugs, unrelated to the main issue:

I'm not sure how many of these are related, so for the time being I haven't created separate issues.

joekur commented 1 year ago

I'm not yet super familiar with the source code, but I think this may be the section that was handling this case if v4 of nuka-carousel: https://github.com/FormidableLabs/nuka-carousel/blob/v4.8.4/src/index.js#L712-L721

joekur commented 1 year ago

I have been working on fixes to these issues on a fork. Since I mentioned a few different issues above, specifically I am fixing:

Before I start opening PRs, I wanted to check that my expectations of functionality match yours, particularly for the first two issues.

On this one I mentioned in the PR description:

In v4, each scroll action would result in the left-most visible slide being left-aligned with the carousel container. But in v5, when using cellSpacing, this is no longer the case. The offset appears to grow with each page scrolled. Note that the main issue is still present when cellSpacing is not used, so these two issues don't seem strictly related.

I wasn't able to reproduce that in this package's storybook, I'm not sure why it's happening in my sandbox example.

carbonrobot commented 2 months ago

Closing as we have moved several versions past this one and the API no longer exists