-
Notifications
You must be signed in to change notification settings - Fork 206
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
Support fling for nested scroll on TimetableGrid. #1273
Support fling for nested scroll on TimetableGrid. #1273
Conversation
Hi @usuiat! Codes seem to be unformatted. To resolve this issue, please run |
@@ -128,17 +127,11 @@ fun TimetableSheet( | |||
} | |||
|
|||
is GridTimetable -> { | |||
val nestedScrollDispatcher = remember { NestedScrollDispatcher() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great PR!
I would like to comment on a point of concern.
Is there any reason why you originally defined the NestedScrollDispatcher and applied Modifier nestedScroll here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first I was misunderstanding that I needed to pass a nestedScrollDispatcher and a timetableSheetContentScrollState.nestedScrollConnection to one Modifier.nestedScroll() argument.
But in this case, the TimetableGrid's nestedScrollDispatcher is independent of the TimetableSheet. Therefore I moved the dispatcher into TimetableGrid class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much. I am convinced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a little curious about the behavior when I moved it in my hand, so let me share it with you.
(We are still in the process of figuring out which part of the problem can be resolved, so we will only share once.)
First, is it an expected behavior that the scroll position returns to the original position after a slight fling at the initial position?
Second, when I scroll in the direction that the border wraps around, it scrolls in the opposite direction. Is this unintended behavior?
(This may just be on my end, so please let me know if this does not reproduce 🙏)
1st | 2nd |
---|---|
default.mp4 |
default.mp4 |
@@ -128,17 +127,11 @@ fun TimetableSheet( | |||
} | |||
|
|||
is GridTimetable -> { | |||
val nestedScrollDispatcher = remember { NestedScrollDispatcher() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much. I am convinced.
Thank you for pointing out. I referred to the Modifier.scrollable() code when implementing this fling operation. |
- Use a position relative to the root component to calculate velocity. - Reset VelocityTracker when drag gesture starts. - Cancel fling animation when another drag gesture starts. - Don't do scroll process when the position does not change.
@swimmy-reo |
.pointerInput(Unit) { | ||
detectDragGestures( | ||
onDragStart = { | ||
scrollState.resetTracking() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's so good! 👍
@@ -672,6 +713,9 @@ private class TimetableScreen( | |||
position: Offset, | |||
nestedScrollDispatcher: NestedScrollDispatcher, | |||
) { | |||
// If the position does not change, VelocityTracker malfunctions. Therefore return here. | |||
if (dragAmount == Offset.Zero) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! I did not know that! 😮
🏅 🏅 🏅 🏅 I was amazed at how quickly the correction was handled! Amazing! 🏅 🏅 🏅 🏅 Let me make one suggestion. I think it would be good to see if the tabs are collapsed when switching the cancelFling flag that you defined.
To use CompositionLocal, I'm thinking of passing the data in a bucket relay format since the data is of limited use. As before, let me know if you can't reproduce this! (Digression) |
@swimmy-reo Yes, sometimes the fling does not work (scrolling stops as soon as I release my finger), but I think this is the same as before. (This is not a good, though 🤔) |
@swimmy-reo |
I see! By the way, I tried it with a release build. |
I'm having someone else check it out to see if it works. To be honest, my device specs are low lol. |
I will reply this evening! |
I have had others look at this and the degree of reproduction seems to vary from device to device. Below is a release build with Pixel Fold.
I asked others to debug in detail the point in pixel fold where the fling does not work when scrolling from bottom to top, and found that the fling does not work when scrolling in the direction where there is no grid, but it works when scrolling in the direction where there is a grid.
Here we see that the reproducibility varies from device to device. Here is the issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your hard work! It was very helpful! 😄
I appreciate your sincere review and people who helped👏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
@usuiat |
@RyuNen344 |
Issue
Overview (Required)
After drag gesture on TimetableGrid ends, the header height and the tab height expand or shrink in conjunction with TimetableGrid flinging.
Movie (Optional)
before.mp4
after.mp4