New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CollapsingToolbar does not consume fling #7
Comments
ProgressI found that the the value in the |
This might be related https://issuetracker.google.com/issues/179417109 |
Thank you for pointing the issue. It is sad that the commit has reverted since I thought calculation based on a relative position was correct. |
Fixed as of 2.2.0. |
Summary
Although the user flings the content all the way to the top and there is a left velocity that CollapsingToolbar can consume, it does not consume fling.
Partial Solution
I can implement fling behavior by overriding
onPreScroll()
andonPostScroll()
callbacks in NestedScrollConnection. However, the problem is that as of Jetpack Compose 1.0.0-rc01 it calculates fling velocity by relative position of the content (For the actual source code calculating the velocity, refer to here and here). As an offset of content moves as the toolbar is expanded/collapsed, the velocity that is calculated inside a child(moving) layout does not provide a valid velocity as a whole resulting in buggy fling behavior because the change in relative position hardly matches the global position change in screen surface.Further Observations
Jetpack Compose basically utilizes event bubble(where event is passed from child through its parents) while we can capture an event before the child processes it using Initial PointerEventPass. However using
PointerEventPass.Initial
type will pay high implementation cost as there is an only small set of high level API with Initial passing type.Traditional Android UI System
The traditional Android UI components which support nested scrolling such as RecyclerView and NestedScrollView calculate velocity using relative position, but they adjust their offset when its relative position to the screen has changed as we can see at here and here.
Conclusion
At the moment, I could not find a method to implement flinging behavior correctly, I will leave this as an issue until a valid way is found.
The text was updated successfully, but these errors were encountered: