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

Drag not working on mobile, scrolls the viewport instead #1

Closed
lioneltay opened this issue Jan 9, 2019 · 1 comment
Closed

Drag not working on mobile, scrolls the viewport instead #1

lioneltay opened this issue Jan 9, 2019 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@lioneltay
Copy link
Owner

Dragging doesn't work on mobile since that is the gesture for scrolling on mobile.

@lioneltay lioneltay added the bug Something isn't working label Jan 9, 2019
@lioneltay
Copy link
Owner Author

Issue is that preventDefault needs to be called on the touchstart event to prevent the default scrolling behaviour while dragging.

Second issue is around Chrome defaulting document level event listeners to being passive (https://www.chromestatus.com/features/5093566007214080). Passive handlers cannot call preventDefault() as to improve scrolling performance by allowing the browser to know that scrolling will not be interrupted. React happens to bind its event handlers at the document level and then delegates the events to the appropriate handlers instead of attaching them directly to the node the listener was defined on (strange).

Solution is to get a ref of the draggable element and attach a touchstart listener manually which calls preventDefault() (look to cleaning this up in the future when react comes up with a solution facebook/react#8968

@lioneltay lioneltay changed the title Not working in mobile, scrolling viewport instead Drag not working on mobile, scrolls the viewport instead Jan 10, 2019
@lioneltay lioneltay self-assigned this Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant