Skip to content

Conversation

@cristiantiradob
Copy link

feat(carousel): automatic hiding of navigation buttons when the first or last image is active

Added 'autoHideControls' feature to ImageSlider for intuitive navigation button visibility.

Gives a nice touch for UX when not needing to move from last image to first one.
Conditional rendering of carousel controls when autoHideControls is true.

demo.mp4

fixes #1205

New optional prop added to Carousel component: autoHideControls with false as default value.
Example:
Captura de pantalla 2023-12-31 a la(s) 4 34 23 p m

… or last image is active

Added 'autoHideControls' feature to ImageSlider for intuitive navigation button visibility.
@vercel
Copy link

vercel bot commented Dec 31, 2023

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

Name Status Preview Comments Updated (UTC)
flowbite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 2, 2024 2:35am

@codecov
Copy link

codecov bot commented Dec 31, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7461173) 99.54% compared to head (5354f6b) 97.35%.
Report is 184 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1207      +/-   ##
==========================================
- Coverage   99.54%   97.35%   -2.19%     
==========================================
  Files         163      214      +51     
  Lines        6621     9089    +2468     
  Branches      401      532     +131     
==========================================
+ Hits         6591     8849    +2258     
- Misses         30      240     +210     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tulup-conner
Copy link
Collaborator

tulup-conner commented Jan 1, 2024

Thank you for contributing! I like this idea and solution a lot, but like you said, it's not in the vanilla library so we probably shouldn't add it. @zoltanszogyenyi What do you think here? This PR looks good if we want it.

className={`${theme.root.rightControl} transition-opacity duration-300 ${
activeItem === items.length - 1 && autoHideControls ? 'pointer-events-none opacity-0' : 'opacity-100'
}`}
>
Copy link
Contributor

@wheresdiasd wheresdiasd Jan 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

Would opacity be the best approach in this case? W/opacity the controls will remain available to user interactions on the dom, while display:none would prevent interactions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, yes, that's right.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello. If with controls remaining available you mean that the user will go from last image to first image even with control hided, in my tests when control hides click has no effect. In this video you will see a circle in the pointer when I click:

Grabacion.de.pantalla.2024-01-01.a.la.s.1.30.21.p.m.mov

Please correct me if I misunderstood.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still change this to display:none because this may come up as still clickable for users navigating with Tab.

I can't confirm that since you didn't add an example to the docs, which, if you could, would be great.

With that said, I'm still not sure if we can merge this because this is a UX feature that isn't available in the vanilla library at all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! Thanks for your feedback I will implement this in my forked repo. Please let me know if you'd like this feature here so I can update the PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind that if the navigation button/icon disappears from the DOM, when the user spam clicks next (or prev) until he gets to the last, if in the future we'll implement click-to-fullscreen (or similar), then this behaviour would be very unpredictable.

So the case study is, the next/prev icons are wrapped in a button element in order to be focusable/accessible and the button becomes disabled=true when is last or first page, according to the direction, this way tabbing is not possible (CC @tulup-conner ) and also clicking the disabled button should stop event propagation.

#just_thoughts 🤔

Avoid use of controls when tab pressed
Added example of autoHideControls for carousel.
ran prettier to format the code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Carousel auto hide controls

4 participants