timusus / RecyclerView-FastScroll

A simple FastScroller for Android's RecyclerView
Other
1.39k stars 182 forks source link

Add interface for fast scroll state change #31

Closed ricknout closed 8 years ago

ricknout commented 8 years ago

It would be very useful to have an interface to determine when fast scrolling has begun and ended (and possibly any states/offsets in between).

In my case, I have a layout that includes a FastScrollRecyclerView and a FloatingActionButton in a FrameLayout. I want to be able to hide the FAB when a user is fast scrolling - as the fast scroll popup goes under the FAB - and show it again when the user stops.

This may also help to solve the issue of the RecyclerView.onScrollListener not being called for scrollToPosition (see: http://stackoverflow.com/questions/27819507/recyclerview-scrolltoposition-not-trigger-scrolllistener).

timusus commented 8 years ago

This should be fairly trivial to implement. I'm not sure how it solved the issue you've linked? That sounds like an issue to be resolved by the RecyclerView/LayoutManager rather than this library. Can you elaborate?

ricknout commented 8 years ago

Hi @timusus,

Great! It would be awesome if you could add it.

Sorry, I should have elaborated. In my case, I have certain parts of my UI (eg. Toolbar elevation) that change with the onScrollListener offset. Fast scrolling does not trigger the listener (as per the link above). I think an interface to observe both the state change as well as the current offset of the FastScrollRecyclerView could be doable, and would be useful in my case.

timusus commented 8 years ago

No worries, I'll see what I can do.

I wonder if it would make more sense to fix the issue where the onScrollListener isn't triggered rather than implementing a custom callback. (I don't know what's involved here, but I've experienced similar issues using a CoordinatorLayout with parallax scrolling)

ricknout commented 8 years ago

Yes, agreed. Just the state change is great for now.

I have a workaround for my specific case (add an OnLayoutChangeListener to the RecyclerView, use .computeVerticalOffset(), apply change).

Thanks for your time

ricknout commented 8 years ago

@timusus please see #34

timusus commented 8 years ago

Thanks for this. I just haven't had time. I'll take a look and update tonight.