-
Notifications
You must be signed in to change notification settings - Fork 861
Implement wrap around feature for mo.carousel()
#7709
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
Implement wrap around feature for mo.carousel()
#7709
Conversation
Introduces a new 'wrapAround' boolean prop to SlidesComponent, allowing slides to loop when enabled by passing it to the Swiper's 'loop' property.
Add wrapAround to `CarouselPlugin` and ability to toggle in `SlidesComponent`
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements wrap around functionality for mo.carousel(), allowing carousels to loop back to the start when navigating beyond the last item (or to the last item from the first).
- Added a
wrapAroundparameter tomo.carousel()to enable/disable wrap around behavior - Integrated Swiper's
loopproperty to implement the wrap around feature - Handled the incompatibility between Swiper's
virtualandloopproperties by conditionally disablingvirtualmode when wrap around is enabled
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| marimo/_plugins/stateless/carousel.py | Added wrapAround parameter to the carousel function and passed it to the frontend via build_stateless_plugin |
| frontend/src/plugins/layout/carousel/CarouselPlugin.tsx | Added wrapAround field to the Data interface and validator schema |
| frontend/src/components/slides/slides-component.tsx | Implemented wrap around logic by conditionally enabling Swiper's loop property and disabling virtual mode when loop is active |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updated the carousel function parameter from wrapAround to wrap_around for consistency with Python naming conventions. Adjusted all references and docstrings accordingly.
|
hi @andrewsoonqn , I left a comment on the issue, I dont think we need to update the backend code |
akshayka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! Let's not add an argument to the carousel Python function, however. The carousel should just always wrap; wrapping should not be configurable
`CarouselPlugin` will now always pass a wrapAround value of `True` to the `SlideComponent`. Reverted changes to backend.
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.18.5-dev183 |
📝 Summary
This PR implements wrap around functionality to
mo.carousel()such that a carousel can be allowed to jump back to the start of the array when scrolling beyond the last item (or vice versa, back to last item from the first by clicking the left arrow)Fixes #5001
🔍 Description of Changes
wrapAroundprop toSlideComponent. This will be used to setSwiper's loop property, which directly gives the ability to wrap around.wrapAroundis alwaysTruewhen usingCarouselPluginDemo:
Screen.Recording.2026-01-08.at.16.57.57.mov
Note:
mo.carousel()were found to be added onto📋 Checklist