fix: pass correct params to animateToPosition #610
Merged
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.
Motivation
animateToPosition accepts:
it was incorrectly called like this
animateToPosition(context.initialPosition, velocityY / 2);
- sovelocityY / 2
was used in place ofANIMATION_SOURCE
which is an enum.According to this SO answer, TS does not distinguish between numbers and numeric Enums, which is why the error came to be in the first place. Let me know if you wanna change the enums to strings, I can add that to this PR (or open a new one).
There is one more change in
src/hooks/useGestureEventsHandlersDefault.tsx
- in this block I removed the first condtion and slightly simplified the second.In the original code, if you look at the second condition you can see it is the same condition as the first one, just relaxed by the
context.initialPosition === highestSnapPoint
part. That means the second condition is a "superset" of the first and so the first can be removed (I hope I'm not wrong here :D).Thanks!