Commit bea6baf
committed
Make TouchTargetHelper hit-test the parallelogram, not the rectangle
`View.setAnimationMatrix(Matrix)` composes for drawing but `View.getMatrix()`
does not include `mAnimationMatrix` in its return value. RN's hit test
in `TouchTargetHelper.getChildPoint` inverse-maps touch coordinates
through `child.matrix` and falls back to the original rectangular
bounds. Net result: after the rendering fix, skewed Views render as
parallelograms but tip taps that fall outside the rectangular bounds
miss, and rect-corner taps that are visually empty post-skew still
register. iOS gets parity for free because UIKit hit-testing
inverse-maps through the layer's `CATransform3D`.
Store the affine `Matrix` on `R.id.skew_animation_matrix` (instead of
`Boolean.TRUE`) and have `TouchTargetHelper.getChildPoint` consult the
tag, falling back to `child.matrix` when absent. Net effect: hit
testing follows the rendered parallelogram on both platforms.
Verified empirically by sweeping tap coordinates 1 px on either side
of every parallelogram edge:
- (100, 555): inside parallelogram top-left tip / outside rect bounds.
Before this commit: missed. After: registers as `skewX 20deg`.
- (330, 731): inside parallelogram bottom-right tip / outside rect.
Same flip.
- (208, 640): rect center / parallelogram center. Registers in both
states.
- (350, 640): outside parallelogram at vertical-pivot y. Misses in both
states (correct).1 parent ab88d5a commit bea6baf
3 files changed
Lines changed: 17 additions & 5 deletions
File tree
- packages
- react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager
- rn-tester/js/examples/Transform
packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
600 | 600 | | |
601 | 601 | | |
602 | 602 | | |
603 | | - | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
604 | 607 | | |
605 | 608 | | |
606 | 609 | | |
| |||
packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.kt
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
298 | 299 | | |
299 | 300 | | |
300 | 301 | | |
301 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
302 | 307 | | |
303 | 308 | | |
304 | 309 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
255 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
256 | 259 | | |
257 | 260 | | |
258 | 261 | | |
259 | 262 | | |
260 | 263 | | |
261 | | - | |
| 264 | + | |
| 265 | + | |
262 | 266 | | |
263 | 267 | | |
264 | 268 | | |
| |||
0 commit comments