feat: allow js and reanimated scroll handlers for KeyboardAwareScrollView
#500
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
Use
useScrollViewOffset
hook to get a scrolled distance.💡 Motivation and Context
useScrollViewOffset
hook doesn't substituteonScroll
handlers withdummyListener
and thus it allows you to define your customonScroll
handler (and at the same time it can be plain js handler or reanimated one).The new approach gives us next advantages:
position.value
is still calculating on UI;onScroll
and it will work out of the box without additional manipulations 😎@ts-expect-error
and don't ship the code with potential errors;2.11.0
(the first release that addeduseScrollViewOffset
).The disadvantage is that we need to bump REA from
2.3.0
to2.11.0
(I described that in documentation). Theoretically we can create our own version ofuseScrollViewOffset
and support REA from2.3.0
again. But version2.11.0
was released 2 years ago:And after math calculations I figured out that dropping support from
2.3.0
to2.11.0
we'll loose only 2% of users (overall downloads for2.3.0
-2.10.0
are ~17k with 770k of overall downloads), so I don't think it's a breaking change.And I think this 2% of users typically don't update deps at all in the project so I think it's not critical to bump minimal supported version for v1.12.x of this library.
📢 Changelog
JS
useScrollViewOffset
hook to get a scrolled distance;🤔 How Has This Been Tested?
Tested manually + on CI.
📝 Checklist