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

PanResponder: 'move' is called before mouse is pressed #701

Closed
JakeCoxon opened this issue Nov 1, 2017 · 4 comments
Closed

PanResponder: 'move' is called before mouse is pressed #701

JakeCoxon opened this issue Nov 1, 2017 · 4 comments
Labels

Comments

@JakeCoxon
Copy link

I believe this is a bug

I have a carousel style component where the responder should be granted when the user presses and drags for at least 50px horizontally. It shouldn't be granted on press because it can be contained in a vertical scrollview, and also it should let buttons be pressed inside.

In react-native I can use onMoveShouldSetPanResponder: (evt, g) => Math.abs(g.dx) > 50,.
On mobile it's impossible to cause a move before a start due to using touches, but using a mouse pointer things are different.

I think in react native web the PanResponder shouldn't grant move until the mouse has been pressed, in order to mirror how touch events works. Otherwise doing what I want doesn't seem possible.

Glitch example:
https://glitch.com/edit/#!/bold-bit?path=src/App/index.js

As you can see the responder gets granted as soon as you move over the red box

  • OS: osx
  • Device: all
  • Browser: chrome
  • React Native for Web (version): 0.1.9
  • React (version): 16
@necolas
Copy link
Owner

necolas commented Nov 1, 2017

Yeah that shouldn't be the case. You can see the PanResponder demo doesn't have this issue. Let me know if you figure out what the root cause is

@necolas necolas added the bug label Nov 1, 2017
@JakeCoxon
Copy link
Author

The difference is that the PanResponder demo doesn't request grant for mouse move, only for mouse press:

  _handleStartShouldSetPanResponder = (e: Object, gestureState: Object): boolean => {
    // Should we become active when the user presses down on the circle?
    return true;
  };

  _handleMoveShouldSetPanResponder = (e: Object, gestureState: Object): boolean => {
    // Should we become active when the user moves a touch over the circle?
    return false;
  };

whereas in my code I want mouse move, but only after mouse press

@necolas
Copy link
Owner

necolas commented Nov 1, 2017

I see. Thanks

@necolas necolas changed the title PanResponder 'move' is called before mouse is pressed PanResponder: 'move' is called before mouse is pressed Dec 18, 2017
@necolas
Copy link
Owner

necolas commented Feb 13, 2018

I tried your demo (thanks for making one) against master. The problem looks to have been fixed by this patch - 9ee89bc. This makes the mouse work like touch in the responder system - press and drag is a move. The fix should be in the next release. Thanks again

@necolas necolas closed this as completed Feb 13, 2018
necolas referenced this issue Feb 13, 2018
Exclude middle, wheel, and right click mouse events from the responder
system. This fixes the Touchables incorrectly triggering 'onPress' in
response to these events.

Filter mousemove events in the 'extractEvents' methods, and check for
active touches rather than the length of the touch bank. This fixes the
PanResponder not functioning after the first touch in Firefox.

Fix #719
Fix #729
Close #804
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants