Skip to content
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

Add scrollViewOffset prop to AnimatedScrollView #4414

Merged

Conversation

mstach60161
Copy link
Contributor

Summary

This PR moves logic from useScrollViewOffset hook to Animated.ScrollView prop.

The API of useScrollViewOffset is a bit cumbersome, because we need to pass the same ref to both ScrollView and hook.

Now we just need to pass variable with type ScrollValue<number> to Animated.ScrollView and when Scroll View changes its position, our value is updated

Test plan

  • Example app

@mstach60161 mstach60161 marked this pull request as ready for review May 5, 2023 10:21
@mstach60161 mstach60161 requested a review from piaskowyk May 5, 2023 10:30
Copy link
Member

@piaskowyk piaskowyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@mstach60161 mstach60161 added this pull request to the merge queue May 25, 2023
Merged via the queue into main with commit 8b4fef8 May 25, 2023
6 checks passed
@mstach60161 mstach60161 deleted the @mstach60161/add-scrollViewOffsetProp-to-AnimatedScrollView branch May 25, 2023 09:46
fluiddot pushed a commit to wordpress-mobile/react-native-reanimated that referenced this pull request Jun 5, 2023
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect. -->

## Summary

This PR moves logic from `useScrollViewOffset` hook to
`Animated.ScrollView` prop.

The API of `useScrollViewOffset` is a bit cumbersome, because we need to
pass the same `ref` to both `ScrollView` and hook.

Now we just need to pass variable with type `ScrollValue<number>` to
`Animated.ScrollView` and when Scroll View changes its position, our
value is updated

## Test plan

- Example app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants