Add hitSlop prop on iOS and Android#5720
Conversation
|
By analyzing the blame information on this pull request, we identified @dmmiller, @andreicoman11 and @Ehesp to be potential reviewers. |
There was a problem hiding this comment.
undefined This type is incompatible with number
779f977 to
34cec67
Compare
|
@jesseruder updated the pull request. |
|
It looks like the tests don't like me doing |
|
@andreicoman11 @kmagiera are you guys the best people to look at Android touch system diffs? |
|
@bestander it looks like R.java isn't generated (?) because the tests don't use Gradle -- off the top of your head do you know how to make Buck take care of this for us? |
There was a problem hiding this comment.
undefined This type is incompatible with object type
34cec67 to
b5ee125
Compare
|
@jesseruder updated the pull request. |
There was a problem hiding this comment.
Why not just add an extra property to the ReactViewGroup and assing it there? Calling setTag this way will often allocate an extra SparseArray.
There was a problem hiding this comment.
Makes sense. I'll change that.
b5ee125 to
a50bc13
Compare
|
@jesseruder updated the pull request. |
|
I tried adding Is there any clean way to solve this @bestander? I could add an interface under react/uimanager but that seems like overkill. |
There was a problem hiding this comment.
Can you extract getHitSlopRect to an interface so that other views (such as Text elements) can implement hitSlop too if we need it?
|
@jesseruder yeah, that sucks. |
a50bc13 to
6db6921
Compare
|
@mkonicek iOS side looks 👍 to me. LGTM |
|
Also, just FYI martin, we've been using this internally and it's working great on both platforms :) |
|
Oh cool, good to know! |
There was a problem hiding this comment.
This should be more obvious to the reader, something like ** NOTE ** or even "Experimental" would help here
|
@jesseruder updated the pull request. |
|
@jesseruder updated the pull request. |
There was a problem hiding this comment.
Can you add a short example here showing how I would extend the area by n pixels in each direction? What's a reasonable number?
|
@jesseruder updated the pull request. |
|
Looks good! Just two small nits and would be nice to add a small example: https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/TouchableExample.js |
6db6921 to
6cdf128
Compare
|
@jesseruder updated the pull request. |
|
@mkonicek @andreicoman11 Added an example and more comments. Thanks! |
6cdf128 to
d13c51a
Compare
|
@jesseruder updated the pull request. |
1 similar comment
|
@jesseruder updated the pull request. |
d13c51a to
54dcde6
Compare
|
@jesseruder updated the pull request. |
54dcde6 to
8211582
Compare
|
@jesseruder updated the pull request. |
8211582 to
951c8bd
Compare
|
The example looks good and this is working on both platforms. |
|
@facebook-github-bot shipit |
|
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1041390565903389/int_phab to review. |
New prop
hitSlopallows extending the touch area of Touchable components. This makes it easier to touch small buttons without needing to change your styles.It takes
top,bottom,left, andrightsame as thepressRetentionOffsetprop. When a touch is moved,hitSlopis combined withpressRetentionOffsetto determine how far the touch can move off the button before deactivating the button.On Android I had to add a new file
ids.xmlto generate a unique ID to use for the tag where I store thehitSlopstate. The iOS side is more straightforward.@terribleben worked on the iOS and JS parts of this diff.
Fixes #110