FastScroll-Everywhere icon indicating copy to clipboard operation
FastScroll-Everywhere copied to clipboard

Use fast-scroll or default scrollbar depending on list size

Open mortalis13 opened this issue 6 years ago • 3 comments

Hi. Is there a possibility to use default scrollbar for short lists (say in RecyclerView) and fast-scroll in larger ones?
Maybe I could add a list size parameter or list min height in px/dp when the fast-scroll begins to show.
Besides, it would be similar to the default Android fast-scroll behaviour.

Thanks.

mortalis13 avatar Oct 14 '18 13:10 mortalis13

There is a method yourFastScrollRecyclerView.getDelegate().setThumbDynamicHeight(isDynamicHeight).

  • isDynamicHeight=true, the thumb-height will be calculated by the full list size and the visible size;

  • isDynamicHeight=false, the thumb-height will be a fixed size;

So, you can set isDynamicHeight=true when the list is short and set isDynamicHeight=false when the list is large.

Mixiaoxiao avatar Oct 14 '18 15:10 Mixiaoxiao

First I thought it should show the fast-scroll for large data and default thin bar for small lists. Because I use thicker thumb for long lists as it's more comfortable but wanted just thin thumb to show the scrolling position if there's no need to scroll fast.

As I understood from the code the fast-scroll rectangle relaces the default scrollbar so it would be better to change its width rather that height, in my case. And the rectangle height for any list should reflect its relative size.

So I digged a little the source code for FastScrollDelegate and think that in the updateThumbRect() I could check visiblePercent and for example for values more than 0.5 set the rectangle width to the default (say 4dp).

I'll test it better and if you don't mind will add a pull request with my suggestion. It would be, of course, a user option whether to change or not the thumb width depending on the list size.

Thanks for your response.

mortalis13 avatar Oct 15 '18 17:10 mortalis13

Thanks for your great jod. I think this feature is useful for many apps.

Mixiaoxiao avatar Oct 18 '18 11:10 Mixiaoxiao