[Touches] Translated components receive touches at their non-translated position
When translating a View on Android (0.14.0-dev), it continues to receive touches at its original position which is probably not what you want. Here's the repro with PanResponderExample in the UIExplorer (you need to touch the top-left of the scene to move the circle):
diff --git a/Examples/UIExplorer/PanResponderExample.js b/Examples/UIExplorer/PanResponderExample.js
index c2e6a66..f469439 100644
--- a/Examples/UIExplorer/PanResponderExample.js
+++ b/Examples/UIExplorer/PanResponderExample.js
@@ -53,8 +53,10 @@ var PanResponderExample = React.createClass({
this._previousTop = 84;
this._circleStyles = {
style: {
- left: this._previousLeft,
- top: this._previousTop
+ transform: [
+ { translateY: this._previousTop },
+ { translateX: this._previousLeft },
+ ],
}
};
},
@@ -112,8 +114,10 @@ var PanResponderExample = React.createClass({
this._highlight();
},
_handlePanResponderMove: function(e: Object, gestureState: Object) {
- this._circleStyles.style.left = this._previousLeft + gestureState.dx;
- this._circleStyles.style.top = this._previousTop + gestureState.dy;
+ this._circleStyles.style.transform = [
+ { translateY: this._previousTop + gestureState.dy },
+ { translateX: this._previousLeft + gestureState.dx },
+ ];
this._updatePosition();
},
_handlePanResponderEnd: function(e: Object, gestureState: Object) {
cc @mkonicek @kmagiera is this simply how Android behaves? I can use absolute positioning instead, but if it's possible for RN to fix this in a nice way, that would be great too.
Ah @ide is this basically the reason for https://github.com/exponentjs/react-native-invertible-scroll-view/issues/16?
Yeah I think so. It might just be Android clowniness but perhaps RN is doing something to disable hitbox translation or can change this behavior on Android.
Interesting, thanks for reporting it. @andreicoman11 do you think it's related to the issue where touch coordinates are absolute instead of relative on Android?
This regression was introduced in https://github.com/facebook/react-native/commit/c805157cac6acbb74690f209fe7bfd9ea51f8e55
@dmmiller Is now working on making the payload of touch events consistent between iOS and Android.
@dmmiller thanks a lot! :)
@dmmiller Sorry to ask again, but is there any ETA on this? Or any hotfix I could test?
@PhilippKrone Currently I've reverted the commit I've linked to and building from source. I needed to use adjustResize for the keyboard since reverting the commit re-surfaces the bug where touch points will be wrong if view is moved up due to keyboard focus. Really waiting for the fix.
@satya164 OK, I understand. I'm currently checking whether the following PR by @dmmiller might fix this issue: https://github.com/facebook/react-native/commit/0c2ee5d480e696f8621252c936a8773e8de9f8b6, but it seems not to. :(
I've now implemented this fix but the issue is not gone yet.
@PhilippKrone Which fix?
@satya164 Sorry, I guess the message didnt come through: https://github.com/facebook/react-native/commit/0c2ee5d480e696f8621252c936a8773e8de9f8b6
I have a fix internally that I should be pushing in the next day or so.
@dmmiller thanks for the update. Much appreciated I'm sure.
@PhilippKrone @satya164 That fix you mentioned was not a fix for this issue. That fix fixed the values passed in the touch events to be local to the targeted view. The fix for this is currently in review and is explicitly for transformed views.
@dmmiller Looking forward to the fix. Thanks a lot :)
@dmmiller Would be totally awesome if we could get it to 0.16.0 #4327
@dmmiller Anything new concerning this fix for transformed views?
Waiting on @andreicoman11 to get back from holiday and accept it :) He should be back today so hopefully, we can get it pushed today.