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

Reconcile handling of mouse and touch drag start events #545

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/DraggableCore.js
Expand Up @@ -243,6 +243,7 @@ export default class DraggableCore extends React.Component<DraggableCoreProps, D
// https://developers.google.com/web/updates/2017/01/scrolling-intervention
const thisNode = this.findDOMNode();
if (thisNode) {
addEvent(thisNode, eventsFor.mouse.start, this.onMouseDown, {passive: false});
addEvent(thisNode, eventsFor.touch.start, this.onTouchStart, {passive: false});
}
}
Expand All @@ -258,6 +259,7 @@ export default class DraggableCore extends React.Component<DraggableCoreProps, D
removeEvent(ownerDocument, eventsFor.touch.move, this.handleDrag);
removeEvent(ownerDocument, eventsFor.mouse.stop, this.handleDragStop);
removeEvent(ownerDocument, eventsFor.touch.stop, this.handleDragStop);
removeEvent(thisNode, eventsFor.mouse.start, this.onMouseDown, {passive: false});
removeEvent(thisNode, eventsFor.touch.start, this.onTouchStart, {passive: false});
if (this.props.enableUserSelectHack) removeUserSelectStyles(ownerDocument);
}
Expand Down Expand Up @@ -447,7 +449,7 @@ export default class DraggableCore extends React.Component<DraggableCoreProps, D
return React.cloneElement(React.Children.only(this.props.children), {
// Note: mouseMove handler is attached to document so it will still function
// when the user drags quickly and leaves the bounds of the element.
onMouseDown: this.onMouseDown,
// onMouseDown is added on `componentDidMount` so the click can be cancelled
onMouseUp: this.onMouseUp,
// onTouchStart is added on `componentDidMount` so they can be added with
// {passive: false}, which allows it to cancel. See
Expand Down