-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
TouchableHighlight vs TouchableWithoutFeedback #134
Comments
One quick thought is I could remove nesting. Just realized that Text has onPress____ methods. Going to try that. |
Usually, the reason why there's a delay is that the JS thread is blocked doing something else. Do you have some timers or code running at the same time? |
No, i do not. The strange thing is that switching components makes it lighting fast. TouchableOpacity and TouchableWithoutFeedback are extremely fast responding, while TouchableHighlight is sluggish. |
The culprit is the default HIGHLIGHT_DELAY_MS property, which is 130ms. When I change the value (see below), it works as expected.
|
The obvious question is how does one override touchableGetHighlightDelayMS for a particular configuration of TouchableHighlight? Perhaps it should be a property configuration? (Just thinking out loud) |
cc @sahrens who implemented the delay |
It's worth noting that the only way I could figure out how to leverage the styling of a and the speed of a Touchable is by nesting like so:
|
I didn't implement the delay, it blames back to @jordwalke internally (D765907) and the 130ms value has remained unchanged since first introduced in react on the FB desktop website in April 2013. My guess is that it exists for reasons similar to those described here: but it doesn't really seem to be necessary since TouchableOpacity works fine. @jaygarcia - for your last comment with the nested structure, do you still need to do that if you set the delay to zero, or does changing changing the delay fix the issue completely? We can definitely add
to TouchableHighlight to match TouchableOpacity if that's the better behavior - want to send a PR if that fixes things for you? |
@sahrens , If i set the delay to zero in the following file, it works as desired, giving immediate feedback, which is what is expected.
The nesting above isn't required if we remove the delay. What about the other issues I surfaced, however? The fact that the other Touchable____ views not conforming to , thus preventing layout controls, etc (see above animated gif)? Also, please pardon the newb question, but PR as in "Pull Request"? Isn't that reserved for code changes? I recall there being a Contrib's Lic. agreement that goes along with that, correct? (This is more of a generic react question :-)
|
Yes, I'm suggesting that you change the implementation of TouchableHighlight.js and send us a PR with those changes (which requires the contrib agreement). We can make the change ourselves if you prefer, but it will take longer. For the layout issues, those are due to unfortunate discrepancies in the implementations - TouchableHighlight is unique because it requires an extra view be rendered behind the content to provide the colored highlight. It's fixable, but would require some work. |
To get things working with TouchableWithoutFeedback, I think if you add a View wrapper around the inner text and apply the styles to that instead of to TouchableWithoutFeedback, it will work? |
Yeah, the delay was intentional to mimic touchable elements that exist within scroll views. On iOS, you don't want items highlighting immediately just in case a containing scroll view begins to scroll right after the touch start. So our delay values might be too large, which we can adjust, or we could also allow override values for certain instances of your choosing. |
Allowing an override is going to be the best route, IMHO. |
@jordwalke , I'd like to invite you to install the eBay app for iOS. Their "ListView" has a delay on highlight, but immediate feedback on tap. I believe that this level of feedback & interaction needs to be provided by react. |
I thought that we did have immediate feedback on the release of a tap. You probably have to implement the |
@jordwalke, it was not like that in a previous build. Today, it's working like a champ :) |
Has this been addressed? I'm experiencing the same delay, regardless of whether the TouchableHighlight component is in a ScrollView or just a View. It's not the biggest deal, since an easy workaround is to just extend the component and override the delay: class TouchableButton extends TouchableHighlight {
touchableGetHighlightDelayMS() {
return 0;
}
} However, I am wondering if there could be a better implementation. Currently, the stock TouchableHighlight component is noticeably unresponsive. |
I noticed a huge issue with TouchableHighlight where there is a significant delay with the onPressIn method being called, making this component next to unusable for real-time feedback.
The TouchableWithoutFeedback component, however provided realtime feedback, but being that it doesn't conform to the same component that TouchableHighlight does, styles break.
The text was updated successfully, but these errors were encountered: