Skip to content
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

[Touches] Translated components receive touches at their non-translated position #3557

Closed
ide opened this issue Oct 21, 2015 · 21 comments
Closed
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ide
Copy link
Contributor

ide commented Oct 21, 2015

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) {
@ide ide added the Android label Oct 21, 2015
@ide
Copy link
Contributor Author

ide commented Oct 21, 2015

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.

@PhilippKrone
Copy link
Contributor

Ah
@ide is this basically the reason for expo/react-native-invertible-scroll-view#16?

@ide
Copy link
Contributor Author

ide commented Oct 31, 2015

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.

@mkonicek
Copy link
Contributor

mkonicek commented Nov 6, 2015

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?

@satya164
Copy link
Contributor

This regression was introduced in c805157

@mkonicek
Copy link
Contributor

@dmmiller Is now working on making the payload of touch events consistent between iOS and Android.

@PhilippKrone
Copy link
Contributor

@dmmiller thanks a lot! :)

@PhilippKrone
Copy link
Contributor

@dmmiller Sorry to ask again, but is there any ETA on this? Or any hotfix I could test?

@satya164
Copy link
Contributor

@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.

@PhilippKrone
Copy link
Contributor

@satya164 OK, I understand. I'm currently checking whether the following PR by @dmmiller might fix this issue: 0c2ee5d, but it seems not to. :(

@PhilippKrone
Copy link
Contributor

I've now implemented this fix but the issue is not gone yet.

@satya164
Copy link
Contributor

@PhilippKrone Which fix?

@PhilippKrone
Copy link
Contributor

@satya164 Sorry, I guess the message didnt come through: 0c2ee5d

@dmmiller
Copy link

I have a fix internally that I should be pushing in the next day or so.

@ide
Copy link
Contributor Author

ide commented Nov 25, 2015

@dmmiller thanks for the update. Much appreciated I'm sure.

@dmmiller
Copy link

@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.

@satya164
Copy link
Contributor

@dmmiller Looking forward to the fix. Thanks a lot :)

@satya164
Copy link
Contributor

@dmmiller Would be totally awesome if we could get it to 0.16.0 #4327

@PhilippKrone
Copy link
Contributor

@dmmiller Anything new concerning this fix for transformed views?

@dmmiller
Copy link

Waiting on @andreicoman11 to get back from holiday and accept it :) He should be back today so hopefully, we can get it pushed today.

@satya164
Copy link
Contributor

@dmmiller That would be awesome. Thank you :D

sunnylqm pushed a commit to sunnylqm/react-native that referenced this issue Dec 2, 2015
Summary: public

Our view handling for determining if a touch was in a view was not transform aware.  This updates it to be
transform aware (by borrowing the code from ViewGroup).

Now, touches will be correctly translated to the view if the view is transformed.  They will also have the correct
local touch point.

This fixes facebook#3557

Reviewed By: andreicoman11

Differential Revision: D2696063

fb-gh-sync-id: 291f6b9884c610c29f8f8b9992c98d59863ab481
dmmiller pushed a commit that referenced this issue Dec 4, 2015
Summary: public

Our view handling for determining if a touch was in a view was not transform aware.  This updates it to be
transform aware (by borrowing the code from ViewGroup).

Now, touches will be correctly translated to the view if the view is transformed.  They will also have the correct
local touch point.

This fixes #3557

Reviewed By: andreicoman11

Differential Revision: D2696063

fb-gh-sync-id: 291f6b9884c610c29f8f8b9992c98d59863ab481
@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

7 participants