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

Carousel position resetting when toggling visibility (display none) #666

Open
hybrid897 opened this issue Jun 21, 2024 · 2 comments
Open
Labels
needs triage This issue has not been triaged by maintainers

Comments

@hybrid897
Copy link

hybrid897 commented Jun 21, 2024

Describe the bug

My use case is a carousel inside a tab component. After I have traversed images in the carousel, I swap tabs and then swap back, adding a display none to the content that is in the inactive tab.

The position of the carousel seems to reset back to the first item. How can I keep the selected carousel item stable after show/hiding it?

Thank you.

Reproduction

https://stackblitz.com/edit/react-ts-pv5u2i

Traverse carousel item to any but the first, then click the show / hide button to toggle display none, it will reset the carousel back to the first item.

Additional context

No response

@hybrid897 hybrid897 added the needs triage This issue has not been triaged by maintainers label Jun 21, 2024
@hybrid897 hybrid897 changed the title Carousel position resetting when display none Carousel position resetting when toggling visibility (display none) Jun 21, 2024
@fancyapps
Copy link
Owner

Hi! The script reads the dimensions of the container to determine which slides to display. Therefore, if the container has no dimensions, it is assumed that there is nothing to display.

@hybrid897
Copy link
Author

hybrid897 commented Jun 21, 2024

Thanks for the reply, I can fix it using absolute / visibility hidden positioning it offscreen + aria-hidden instead of display none.

Would be nice if there was an option to disable this behaviour or remember current slide index, but I imagine it would have other repercussions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants