Skip to content

Use Gesture to handle TabBarItem presses #2039

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

Merged
merged 1 commit into from
May 18, 2022

Conversation

ethanshar
Copy link
Collaborator

@ethanshar ethanshar commented May 10, 2022

Description

This is a small improvement for performance in TabController component.
In TabBarItem I replaced the TouchableOpacity with gesture-handler Gesture component.
Instead of having a round trip (Native side -> JS side) to invoke the onPress callback in order to change the currIndex shared value, I now use the Gesture API to do that, this way we avoid the round trip.

Changelog

Small performance improvement in TabController transitions

}, [style]);

const gesture = Gesture.Tap()
.maxDuration(60000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this limit solving a problem?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it create a proper time between touch down and touch up.
I didnt find any proper way to do it.
I need to handle touch down - for the active press background color and opacity
and touch up - is for completing the actual press (and moving the current index)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I just tested without it and with .maxDuration(0) and now I get it.
I'd expect it'll be possible to have unlimited time...

@ethanshar ethanshar requested a review from M-i-k-e-l May 15, 2022 11:36
@M-i-k-e-l M-i-k-e-l merged commit 5268ff2 into master May 18, 2022
@ethanshar ethanshar deleted the infra/ImproveTabControllerPerformance branch April 2, 2024 06:38
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