fix: onScrollEnd race condition breaking onValueChanged#77
Open
LouisHaftmann wants to merge 1 commit into
Open
fix: onScrollEnd race condition breaking onValueChanged#77LouisHaftmann wants to merge 1 commit into
onScrollEnd race condition breaking onValueChanged#77LouisHaftmann wants to merge 1 commit into
Conversation
Member
|
@LouisHaftmann Thanks for looking into this and opening the PR. I don't have enough information about the issue yet. Could you please share more details: the platform/environment where you can reproduce it, a short video if possible, and logs showing the order in which the scroll callbacks/listeners are called? |
Author
|
I'll gather as much info as possible and come back to you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Might fix #65 but didn't test it on web
Problem
onValueChangedis frequently not being triggered.Cause
onScrollEndis often not called when theonMomentumScrollEndcallback is triggered because the debounce is cancelled before running theonScrollEndfunction. The debounce gets cancelled by the scroll offset listener which runs afteronMomentumScrollEndbecause react-native scrolls the container to snap to the selected item.Fix
Check if the momentum scroll already ended inside the scroll offset listener and only clear the debounce if momentum scroll hasn't ended yet.
Possible new Problems
I don't think this will cause any new issues (not 100% sure) since the default behavior (even without
onMomentumScrollBeginever being called) is the same as before.