Fix WheelPicker visual bug by setting offset in onValueChange #3508
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.
Description
Which item is visually highlighted is controlled by
const offset = useSharedValue(0);
.This value is currently only set inside
useAnimatedScrollHandler
.In some configurations the scroll handler will not be called when scrolling very fast, especially when scrolling fast to the end of the list.
Changelog
Set the value of
offset
inonValueChange
to force the visual appearence to be congruent with the current selection in case something goes awry with the animated scroll handler.Additional info
This will alleviate the issue described in #2939.
One could also imagine a
withTiming
to smoothen the visual effect. I tried this and liked it but it also increased the delay until the highlight and the selected value were in sync.