nghiepdev / smooth-scrollbar-react

A wrapper for smooth-scrollbar to React Component.
https://codesandbox.io/s/smooth-scrollbar-react-4pu86
MIT License
40 stars 5 forks source link

Show tracks on hover #15

Closed eltongonc closed 2 years ago

eltongonc commented 2 years ago

Hi, thank you for this!

Is there a way to show the tracks when you hover over the content?

I've tried a mouse-enter / mouse-leave listener to change the alwaysShowTracks, but unfortunately the Scrollbar doesn't do anything with the value

eltongonc commented 2 years ago

This does the trick:

(.SCSS)

.element {
 .scrollbar-track.show,
  .scrollbar-track:hover {
    opacity: 0;
    transition: 0.3s ease-in-out;
    background-color: ${({ theme }) => theme.main};

    .scrollbar-thumb {
      background-color: ${({ theme }) => theme.textColor};
    }
  }

  &:hover {
    .scrollbar-track.show,
    .scrollbar-track:hover {
      opacity: 1;
    }
  }
}