asmyshlyaev177/react-horizontal-scrolling-menu

[BUG] Show and Hide Button Arrows

Closed this issue · 1 comments

Describe the bug
I have two carousels with the scroll but when I go down the page the arrows appear and disappear, it is a behavior that happens the same in your examples. How could I control that from the beginning they do not appear if they do not have more items on the scroll?

To Reproduce
Link to codesandbox where can see the bug or steps to reproduce the behavior:

  1. put a scroll at the end of the page
  2. Scroll down to scroll items
  3. See error

Expected behavior
If they do not have items they should not appear

Screenshots
Captura de pantalla 2024-06-24 a la(s) 13 31 37

Captura de pantalla 2024-06-24 a la(s) 13 31 46

Desktop (please complete the following information):

  • Browser chrome 89, safari 14
  • OS: MAC
  • Mobile device (eg iPhone, Galaxy etc)

Can hide arrows by default, and when items updated they will appear if there are scroll.

const isFirstItemVisible = visibility.useIsVisible('first', true);
const isLastItemVisible = visibility.useIsVisible('last', true);

Second value in useIsVisible is default value, e.g. before first update.

Will dig into it more tomorrow.