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

Fix onStart callbacks of ReanimatedSwipeable being called every update #3151

Conversation

latekvo
Copy link
Contributor

@latekvo latekvo commented Oct 11, 2024

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:
<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

@latekvo latekvo requested a review from m-bert October 14, 2024 09:18
runOnJS(onSwipeableOpenStartDrag)(direction);
} else if (rowState.value !== 0 && onSwipeableCloseStartDrag) {
runOnJS(onSwipeableCloseStartDrag)(direction);
if (dragStarted.value === false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not

Suggested change
if (dragStarted.value === false) {
if (!dragStarted.value) {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in d0bda43

updateAnimatedEvent();
})
.onEnd(
(event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {
handleRelease(event);
}
);
)
.onFinalize(() => (dragStarted.value = false));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.onFinalize(() => (dragStarted.value = false));
.onFinalize(() => {
dragStarted.value = false
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in d0bda43

@latekvo latekvo merged commit f05604c into main Oct 14, 2024
1 check passed
@latekvo latekvo deleted the @latekvo/fix-drag-start-callbacks-of-swipeable-called-every-update branch October 14, 2024 12:20
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.

2 participants