-
-
Notifications
You must be signed in to change notification settings - Fork 979
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
[ReanimatedSwipeable
] Multiple bug fixes and improvements
#3149
[ReanimatedSwipeable
] Multiple bug fixes and improvements
#3149
Conversation
…elocity to the config
…he row state" This reverts commit 866425d.
Is it necessary to fix all of them in just 1 PR? I'd prefer to split it into smaller ones if possible. |
Most of them are very minor, most also depend on each other / are fixes to the same part of I can split them up if you'd prefer that but i think it'd significantly complicate the process, i'll definitely have to deal with conflicts, and PRs blocking eachother. |
## Description Add missing documentation for `onSwipeableOpenStartDrag` and `onSwipeableOpenStartDrag` callbacks of `ReanimatedSwipeable` Moved from #3149
…pdate (#3151) ## Description Fix `onStart` callbacks of `ReanimatedSwipeable` being called every update. Moved from #3149 ## Test plan - open `Swipeable Reanimation` example - replace the `ReanimatedSwipeable` component with the following code: ```js <ReanimatedSwipeable containerStyle={styles.swipeable} onSwipeableOpenStartDrag={(direction) => console.log(direction)} onSwipeableCloseStartDrag={(direction) => console.log(direction)}> <Text>Swipeable!</Text> </ReanimatedSwipeable> ``` - see how only one update is sent to the console, while before this PR new updates were constantly generated
appliedTranslation.value = withSpring( | ||
toValue, | ||
translationSpringConfig, | ||
(isFinished) => { | ||
if (isFinished) { | ||
runOnJS(dispatchEndEvents)(fromValue, toValue); | ||
runOnJS(dispatchEndEvents)(frozenRowState, toValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all events executed on the JS thread?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe all of them are, couldn't find any that aren't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can update the calling logic to check whether the callback is a worklet and run it on the UI thread if it is (that's for another PR though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, will do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think it could be split into smaller PRs (like switching to enum
instead of string
), but I won't block it. Please wait for @j-piasecki final opinion on this
enum SwipeDirection { | ||
LEFT = 'left', | ||
RIGHT = 'right', | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this declaration at the top of the file (somewhere around SwipeableExcludes
type). I know it is JS and it works, but I think it's a good practice. Also if you read code from the top you know what SwipeDirection
is (at first I thought it was a number
, then I saw the declaration)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in a329a6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can merge this, the changes are not necessarily related but the PR isn't that big. In the future though, please try to open separate PRs for unrelated changes (like extracting direction to enum).
Please address #3149 (comment) first.
Description
This PR applies multiple bug fixes and improvements to the
ReanimatedSwipeable
Changes:
open
andwillOpen
callbacks.startDrag
callbacks receiving invaliddirection
when opening swipeable.close
andwillClose
callbacks.onSwipeableWillClose
andonSwipeableClose
callbacks sometimes being called on open.progress
value skipping last10%
of it's range and having a delay relative to thetranslation
.closes ReanimatedSwipable Delayed #3147
Test plan
Will create an example showcasing outputs of all the affected callbacks, work in progress.