-
-
Notifications
You must be signed in to change notification settings - Fork 800
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
scrollView losing position + please make code more contributor-friendly #461
Comments
@vonovak: hello! 👋 This issue is being automatically closed because it does not follow the issue template. |
Epic detailed well-composed issue info! |
thanks @vonovak for this well detailed issue, this deserve a well proper reply. I will get back to you tomorrow 👍 |
hi @vonovak, for the issue with scrollable losing its position when dragged by handle , it is a known issue and i will make sure to fix it with
Each scrollable will have its own This was added to allow multiple scrollables in one
In current implementation, i have ditch the usage of The solution for this issue would be to utilise animated state variables to lock and unlock scrolling.
First, thanks for highlighting this, i know this code got too much complicated especially This is something i already planned for Please feel free to highlight ambiguity in the code-base and i would make sure to add more descriptive in-code docs. Thanks :) |
resolved here #427 (comment) |
Bug
Hello, firstly, thanks for a nice lib. I'd like to report a bug and ask for the recommended solution. The bug can be reproduced using the example app, on the
v4
branch (at commit 2599f6c).I'm working on a bigger feature that customizes the interaction between the PanGestureHandler that lives "above" the scrollView and the scrollView itself. This is an issue that I found along the way:
Steps To Reproduce
scroll the scrollview to about 50% of the content, then drag the sheet down using the handle, and then slightly scroll the content.
The scrollView loses its position (offset)
I expect the scrollView to not lose its scrolling offset.
Simulator.Screen.Recording.-.iPhone.11.-.2021-05-27.at.13.09.32.mp4
The reason the bug happens are the imperative
scrollTo
calls inreact-native-bottom-sheet/src/hooks/useScrollableInternal.ts
Line 40 in 2599f6c
Now, I am fine with implementing a fix for this and contributing it to the repo, but wanted to ask you opinion on how you think this should be fixed.
Currently, both the scrollview (SV) and the pan gesture handler (PGH) are responders to the dragging.
Comments / questions
scrollableContentOffsetY
and_rootScrollableContentOffsetY
inhttps://github.com/gorhom/react-native-bottom-sheet/blob/v4/src/hooks/useScrollableInternal.ts
?
Using
waitFor
so that only either the PGH or SV (but not both) probably won't work - consider this:enableContentPanningGesture=true
3a) user starts to drag the SV up -> we want the whole bottom sheet to go up and SV stays in position (SV waited for PGH to become responder)
3b) user starts to drag the SV down -> we want the SV to scroll to the beginning and the bottom sheet to stay in position (so SV did not wait for PGH) ---> this is in discrepancy with (3a) which is why I don't think waitFor works for this.
Is that why you chose the approach that is implemented?
As I digged through the code base I noticed it's a little hard to read for newcomers / external contributors - there are a lot of conditions that are unclear. eg. thing like
react-native-bottom-sheet/src/hooks/useInteractivePanGestureHandler.ts
Line 231 in 2599f6c
react-native-bottom-sheet/src/hooks/useInteractivePanGestureHandler.ts
Line 121 in 2599f6c
it would be really nice if you could break those down into named constants so that those conditions have some semantic meaning, break down long functions where it's hard to know much about what is going on and why 😅, and give those functions names.
Even names like
useInteractivePanGestureHandler
do not provide much detail on what the hook does - I mean, isn't a gesture handler interactive by definition? A more descriptive name or comments would tell me more about what the use of this hook is 🙂Please note I am by no means trying to criticize and I do very much value your work on this, it's just a little hard to read code that is not optimized for reading.
Thank you! :)
Environment info
libraries are used as in the example app @2599f6cf46af0f95812e34670de5a7cae5d44fd9
edited:
The text was updated successfully, but these errors were encountered: