Commit 64158aa
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).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent ae2b5ba commit 64158aa
3 files changed
Lines changed: 11 additions & 3 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 | |
|---|---|---|---|
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
609 | | - | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
610 | 613 | | |
611 | 614 | | |
612 | 615 | | |
| |||
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 | | |
| |||
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
291 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
292 | 297 | | |
293 | 298 | | |
294 | 299 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| |||
0 commit comments