Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flex parent around the carousel breaks sliding #1067

Open
2 tasks done
william-abboud opened this issue Aug 16, 2024 · 3 comments
Open
2 tasks done

Flex parent around the carousel breaks sliding #1067

william-abboud opened this issue Aug 16, 2024 · 3 comments

Comments

@william-abboud
Copy link

william-abboud commented Aug 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Question

Hey guys, first of all I want to congratulate you on the new 8th version of nuka and to tell you that I've been a delighted user of it so far.

I've hit one bump which I didn't see mentioned in the docs anywhere and that is that any time I have any DOM element wrapping my Carousel at whatever level above it it could be a direct parent, grandparent element etc. if any parent has display: flex or display: grid the carousel breaks and no longer slides.

Browser: Latest Chrome
Nuka: v8.0.1
React: 18

Funny enough I came to that conclusion when I briefly swapped the nuka-carousel for Swiper where it calculated the width of each slide as some gigantic number and then I started digging and found out that I had a parent element with display: flex which was causing the issue.

@carbonrobot carbonrobot added Type: Bug high priority Issue: Accepted This issue has been tested and has been verified labels Oct 7, 2024
@william-abboud
Copy link
Author

william-abboud commented Oct 8, 2024

One way to solve this is to set the flex basis on the slide item:

.your-slide-item {
  flex: 0 0 96px; /* replace with whatever size you would like the item to have or "auto" to extend fully */
  width: 100%; /* Ensures items take full width of the container */
}

@carbonrobot carbonrobot removed high priority Issue: Accepted This issue has been tested and has been verified labels Oct 8, 2024
@carbonrobot
Copy link
Contributor

@william-abboud Do you have any example code you can share, I was unable to reproduce this locally.

@william-abboud
Copy link
Author

I'll put something together these days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants